From 9153b79c34ee6c7219960d212c133cb5e474d756 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 17 Aug 2010 12:58:33 -0400 Subject: [PATCH] Fix for Bug 3319 - Need error message when adding patron and libraries are defined - Hiding patron add toolbar when branches or categories are undefined - Blocking patron entry form if branches or categories are undefined - Removing nonfunctional template logic for displaying missing category error message. --- .../prog/en/includes/patron-toolbar.inc | 2 + .../prog/en/modules/members/member.tmpl | 5 +++ .../prog/en/modules/members/memberentrygen.tmpl | 12 ++++---- members/memberentry.pl | 28 +++++++++++++++---- members/members-home.pl | 26 +++++++++++++++--- 5 files changed, 56 insertions(+), 17 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc index c508af0..bc4dbc4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc @@ -1,3 +1,4 @@ +
@@ -70,7 +70,11 @@
+

Cannot add patron

+

There are no libraries defined. Please add a library.An administrator must define at least one library.

+

There are no patron categories defined. Please add a patron category.An administrator must define at least one patron category.

+

Add patron Organization patron Adult patron Child patron Professional patron Staff patron @@ -728,7 +732,6 @@ Required
  • - - - There is no category type to add an Adulta Childan Institutiona professionnala Staff Member. - Please create one -
  • @@ -1063,5 +1062,6 @@
    +
  • diff --git a/members/memberentry.pl b/members/memberentry.pl index 6ec6d8e..2228fa3 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -415,9 +415,12 @@ if ($ethnicitycategoriescount>=0) { } my @typeloop; +my $no_categories = 1; +my $no_add; foreach (qw(C A S P I X)) { my $action="WHERE category_type=?"; ($categories,$labels)=GetborCatFromCatType($_,$action); + if(scalar(@$categories) > 0){ $no_categories = 0; } my @categoryloop; foreach my $cat (@$categories){ push @categoryloop,{'categorycode' => $cat, @@ -432,9 +435,10 @@ foreach (qw(C A S P I X)) { $typehash{'categoryloop'}=\@categoryloop; push @typeloop,{'typename' => $_, 'categoryloop' => \@categoryloop}; -} -$template->param('typeloop' => \@typeloop); - +} +$template->param('typeloop' => \@typeloop, + no_categories => $no_categories); +if($no_categories){ $no_add = 1; } # test in city $select_city=getidcity($data{'city'}) if defined $guarantorid and ($guarantorid ne '0'); ($default_city=$select_city) if ($step eq 0); @@ -525,17 +529,18 @@ my $onlymine=(C4::Context->preference('IndependantBranches') && my $branches=GetBranches($onlymine); my $default; - +my $CGIbranch; for my $branch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { push @select_branch,$branch; $select_branches{$branch} = $branches->{$branch}->{'branchname'}; $default = C4::Context->userenv->{'branch'} if (C4::Context->userenv && C4::Context->userenv->{'branch'}); } +if(scalar(@select_branch) > 0){ # -------------------------------------------------------------------------------------------------------- #in modify mod :default value from $CGIbranch comes from borrowers table #in add mod: default value come from branches table (ip correspendence) $default=$data{'branchcode'} if ($op eq 'modify' || ($op eq 'add' && $category_type eq 'C')); -my $CGIbranch = CGI::scrolling_list(-id => 'branchcode', +$CGIbranch = CGI::scrolling_list(-id => 'branchcode', -name => 'branchcode', -values => \@select_branch, -labels => \%select_branches, @@ -544,6 +549,17 @@ my $CGIbranch = CGI::scrolling_list(-id => 'branchcode', -multiple =>0, -default => $default, ); +} + +if(!$CGIbranch){ + $no_add = 1; + $template->param(no_branches => 1); +} +if($no_categories){ + $no_add = 1; + $template->param(no_categories => 1); +} +$template->param(no_add => $no_add); my $CGIorganisations; my $member_of_institution; if (C4::Context->preference("memberofinstitution")){ @@ -634,6 +650,7 @@ $template->param( check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0) "op$op" => 1); +$template->param(CGIbranch=>$CGIbranch) if ($CGIbranch); $template->param( nodouble => $nodouble, borrowernumber => $borrowernumber, #register number @@ -650,7 +667,6 @@ $template->param( check_categorytype =>$check_categorytype,#to recover the category type with checkcategorytype function modify => $modify, nok => $nok,#flag to konw if an error - CGIbranch => $CGIbranch, memberofinstution => $member_of_institution, CGIorganisations => $CGIorganisations, NoUpdateLogin => $NoUpdateLogin diff --git a/members/members-home.pl b/members/members-home.pl index 04fc557..e6468c1 100755 --- a/members/members-home.pl +++ b/members/members-home.pl @@ -51,13 +51,29 @@ if($quicksearch){ debug => 1, }); } -my @categories=C4::Category->all; -$template->param( - branchloop=>(defined $branch?GetBranchesLoop($branch):GetBranchesLoop()), - categories=>\@categories, -); +my @categories; +my $no_categories; +my $no_add = 0; +my $branchloop = (defined $branch?GetBranchesLoop($branch):GetBranchesLoop()); +if(scalar(@$branchloop) < 1){ + $no_add = 1; + $template->param(no_branches => 1); +} else { + $template->param(branchloop=>\@$branchloop); +} + +@categories=C4::Category->all; +if(scalar(@categories) < 1){ $no_categories = 1; } +if($no_categories && C4::Context->preference("AddPatronLists")=~/code/){ + $no_add = 1; + $template->param(no_categories => 1); +} else { + $template->param(categories=>\@categories); +} + $template->param( "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1", + no_add => $no_add, ); my @letters = map { {letter => $_} } ( 'A' .. 'Z'); $template->param( letters => \@letters ); -- 1.7.0.4