From 9fb4a72122fbb008fd642074dfb7f47fa820ca02 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Mon, 12 May 2008 16:29:45 +0200 Subject: [PATCH] Bug Fixing 1782 patch Adding a new routine GetBorrowercategoryList in C4/Member Displaying categoryname when listing categories in memberentrygen.pl using categorytype returned with GetMember wherever it is possible. Signed-off-by: Joshua Ferraro --- C4/Members.pm | 34 ++++++---- circ/circulation.pl | 4 +- .../en/modules/members/memberentrygen.tmpl | 19 +++--- members/boraccount.pl | 4 +- members/borrowers_details.pl | 29 ++++----- members/mancredit.pl | 62 ++++++++----------- members/maninvoice.pl | 4 +- members/member-flags.pl | 38 ++++++------ members/member-password.pl | 4 +- members/member.pl | 2 +- members/memberentry.pl | 8 ++- members/members-home.pl | 2 +- members/moremember.pl | 5 +- members/pay.pl | 4 +- members/readingrec.pl | 4 +- 15 files changed, 103 insertions(+), 120 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index a1ca5072d6..3aa3a7183a 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -67,6 +67,7 @@ BEGIN { &GetborCatFromCatType &GetBorrowercategory + &GetBorrowercategoryList &GetBorrowersWhoHaveNotBorrowedSince &GetBorrowersWhoHaveNeverBorrowed @@ -1367,18 +1368,29 @@ sub GetBorrowercategory { $sth->finish(); return $data; } - else { - my $sth = - $dbh->prepare( - "SELECT * - FROM categories order by description" + return; +} # sub getborrowercategory + +=head2 GetBorrowercategoryList + + $arrayref_hashref = &GetBorrowercategoryList; +If no category code provided, the function returns all the categories. + +=cut + +sub GetBorrowercategoryList { + my $dbh = C4::Context->dbh; + my $sth = + $dbh->prepare( + "SELECT * + FROM categories + ORDER BY description" ); - $sth->execute; - my $data = - $sth->fetchall_arrayref({}); - $sth->finish(); - return $data; - } + $sth->execute; + my $data = + $sth->fetchall_arrayref({}); + $sth->finish(); + return $data; } # sub getborrowercategory =head2 ethnicitycategories diff --git a/circ/circulation.pl b/circ/circulation.pl index add047d923..9904e62ee8 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -399,9 +399,7 @@ if ($borrowernumber) { reservloop => \@reservloop , WaitingReserveLoop => \@WaitingReserveLoop, ); - $borrowercategory = GetBorrowercategory( $borrower->{'categorycode'} ); - $category_type = $borrowercategory->{'category_type'}; - ( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); + $template->param( adultborrower => 1 ) if ( $borrower->{'category_type'} eq 'A' ); } # make the issued books table. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl index ab93c57598..611fb7fd24 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tmpl @@ -1,8 +1,6 @@ Koha › Patrons › -<!-- TMPL_IF NAME="opadd" --> Add<!--TMPL_IF Name="I"--> Organisation <!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult <!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child <!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional <!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff <!--/TMPL_IF --> -patron <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!-- TMPL_ELSE -->Modify<!--TMPL_IF Name="I"--> Organisation <!--/TMPL_IF --><!--TMPL_IF Name="A"--> Adult <!--/TMPL_IF --><!--TMPL_IF Name="C"--> Child <!--/TMPL_IF --><!--TMPL_IF Name="P"--> Professional <!--/TMPL_IF --><!--TMPL_IF Name="S"--> Staff<!--/TMPL_IF --> -patron <!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR name="firstname" --><!-- /TMPL_IF --> + Add Modify patron Organisation patron Adult patron Child patron Professional patron Staff patron , @@ -57,11 +55,11 @@ patron , - Add Organisation Adult Child Professional Staff -patron + Add patron Organisation patron Adult patron Child patron Professional patron Staff patron + -"> Modify Organisation Adult Child Professional Staff -patron +"> Modify patron Organisation patron Adult patron Child patron Professional patron Staff patron +
@@ -72,12 +70,11 @@ patron

- Add Organisation patron Add Adult patron Add Child patron Add Professional patron Add Staff patron - + Add patron Organisation patron Adult patron Child patron Professional patron Staff patron

-

- Modify Organisation patron Modify Adult patron Modify Child patron Modify Professional patron Modify Staff patron +

+ Modify patron Organisation patron Adult patron Child patron Professional patron Staff patron

diff --git a/members/boraccount.pl b/members/boraccount.pl index 6617e846e0..253983c090 100755 --- a/members/boraccount.pl +++ b/members/boraccount.pl @@ -86,9 +86,7 @@ for (my $i=0;$i<$numaccts;$i++){ push(@accountrows, \%row); } -my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} ); -my $category_type = $borrowercategory->{'category_type'}; -( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); +$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'}); $template->param( picture => 1 ) if $picture; diff --git a/members/borrowers_details.pl b/members/borrowers_details.pl index 2f150ad1aa..21ad48c659 100755 --- a/members/borrowers_details.pl +++ b/members/borrowers_details.pl @@ -53,26 +53,21 @@ my $borrowernumber=$input->param('borrowernumber'); my $description=$input->param('description'); my $category_type=$input->param('category_type'); - if ( $data{'surname'} eq '') - { - $data=GetMember($borrowernumber,'borrowernumber'); - %data=%$data; - } - my $borrowercategory = GetBorrowercategory($data{'categorycode'}); +$data=GetMember($borrowernumber,'borrowernumber'); $template->param( borrowernumber => $borrowernumber,#register number #transform value in capital or capital for first letter of the word - firstname => ucfirst($data{'firstname'}), - surname => uc($data{'surname'}), - categorycode => $data{'categorycode'}, - title => $data{'title'}, - category_type => $borrowercategory ->{'category_type'}, - "title_".$data{'title'} => " SELECTED ", - dateofbirth => format_date($data{'dateofbirth'}), - description => $borrowercategory->{'description'} - ); - $template->param(Institution => 1) if ($category_type eq "I"); - output_html_with_http_headers $input, $cookie, $template->output; + firstname => ucfirst($data->{'firstname'}), + surname => uc($data->{'surname'}), + categorycode => $data->{'categorycode'}, + title => $data->{'title'}, + category_type => $data->{'category_type'}, + "title_".$data->{'title'} => " SELECTED ", + dateofbirth => format_date($data->{'dateofbirth'}), + description => $data->{'description'} + ); +$template->param(Institution => 1) if ($category_type eq "I"); +output_html_with_http_headers $input, $cookie, $template->output; # Local Variables: # tab-width: 8 diff --git a/members/mancredit.pl b/members/mancredit.pl index 2705b7dae8..d3d182d70b 100755 --- a/members/mancredit.pl +++ b/members/mancredit.pl @@ -45,42 +45,32 @@ if ($add){ manualinvoice($borrowernumber,$itemnum,$desc,$type,$amount); print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber"); } else { - - - my ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "members/mancredit.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {borrowers => 1}, - debug => 1, - }); - -my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} ); -my $category_type = $borrowercategory->{'category_type'}; -( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); -my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'}); -$template->param( picture => 1 ) if $picture; - + = get_template_and_user({template_name => "members/mancredit.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {borrowers => 1}, + debug => 1, + }); + $template->param( adultborrower => 1 ) if ( $data->{category_type} eq 'A' ); + my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'}); + $template->param( picture => 1 ) if $picture; + $template->param( - borrowernumber => $borrowernumber, - firstname => $data->{'firstname'}, - surname => $data->{'surname'}, - cardnumber => $data->{'cardnumber'}, - categorycode => $data->{'categorycode'}, - category_type => $data->{'category_type'}, - category_description => $data->{'description'}, - address => $data->{'address'}, - address2 => $data->{'address2'}, - city => $data->{'city'}, - zipcode => $data->{'zipcode'}, - phone => $data->{'phone'}, - email => $data->{'email'}, - ); - print $input->header( - -type => 'utf-8', - -cookie => $cookie - ),$template->output; - + borrowernumber => $borrowernumber, + firstname => $data->{'firstname'}, + surname => $data->{'surname'}, + cardnumber => $data->{'cardnumber'}, + categorycode => $data->{'categorycode'}, + category_type => $data->{'category_type'}, + category_description => $data->{'description'}, + address => $data->{'address'}, + address2 => $data->{'address2'}, + city => $data->{'city'}, + zipcode => $data->{'zipcode'}, + phone => $data->{'phone'}, + email => $data->{'email'}, + ); + print $input->header( -type => 'utf-8', -cookie => $cookie),$template->output; } diff --git a/members/maninvoice.pl b/members/maninvoice.pl index fcb59fced9..18371aa344 100755 --- a/members/maninvoice.pl +++ b/members/maninvoice.pl @@ -75,9 +75,7 @@ if ($add){ debug => 1, }); -my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} ); -my $category_type = $borrowercategory->{'category_type'}; -( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); +$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'}); $template->param( picture => 1 ) if $picture; diff --git a/members/member-flags.pl b/members/member-flags.pl index 8901ed73e3..b7ede0e3e3 100755 --- a/members/member-flags.pl +++ b/members/member-flags.pl @@ -153,27 +153,25 @@ if ($input->param('newflags')) { push @loop, \%row; } - my $borrowercategory = GetBorrowercategory( $bor->{'categorycode'} ); -my $category_type = $borrowercategory->{'category_type'}; -( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); +$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' ); - $template->param(borrowernumber => $member, - borrowernumber => $bor->{'borrowernumber'}, - cardnumber => $bor->{'cardnumber'}, - surname => $bor->{'surname'}, - firstname => $bor->{'firstname'}, - categorycode => $bor->{'categorycode'}, - category_type => $bor->{'category_type'}, - category_description => $bor->{'description'}, - address => $bor->{'address'}, - address2 => $bor->{'address2'}, - city => $bor->{'city'}, - zipcode => $bor->{'zipcode'}, - phone => $bor->{'phone'}, - email => $bor->{'email'}, - branchcode => $bor->{'branchcode'}, - loop => \@loop, - ); +$template->param( + borrowernumber => $bor->{'borrowernumber'}, + cardnumber => $bor->{'cardnumber'}, + surname => $bor->{'surname'}, + firstname => $bor->{'firstname'}, + categorycode => $bor->{'categorycode'}, + category_type => $bor->{'category_type'}, + category_description => $bor->{'description'}, + address => $bor->{'address'}, + address2 => $bor->{'address2'}, + city => $bor->{'city'}, + zipcode => $bor->{'zipcode'}, + phone => $bor->{'phone'}, + email => $bor->{'email'}, + branchcode => $bor->{'branchcode'}, + loop => \@loop, + ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/members/member-password.pl b/members/member-password.pl index 4bd4f1ff48..9f5629fbc3 100755 --- a/members/member-password.pl +++ b/members/member-password.pl @@ -76,9 +76,7 @@ if ( $newpassword && ! $errormsg ) { $defaultnewpassword.=substr($chars, int(rand(length($chars))),1); } - my $borrowercategory = GetBorrowercategory( $bor->{'categorycode'} ); -my $category_type = $borrowercategory->{'category_type'}; -( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); +$template->param( adultborrower => 1 ) if ( $bor->{'category_type'} eq 'A' ); my ($picture, $dberror) = GetPatronImage($bor->{'cardnumber'}); $template->param( picture => 1 ) if $picture; diff --git a/members/member.pl b/members/member.pl index 1d33191a74..6d42b450c2 100755 --- a/members/member.pl +++ b/members/member.pl @@ -61,7 +61,7 @@ $template->param( "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1", ); if (C4::Context->preference("AddPatronLists")=~/code/){ - my $categories=GetBorrowercategory(); + my $categories=GetBorrowercategoryList; $categories->[0]->{'first'}=1; $template->param(categories=>$categories); } diff --git a/members/memberentry.pl b/members/memberentry.pl index 0634d48fe2..3ee30c6d5f 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -102,6 +102,8 @@ my $new_c_type = $category_type; #if we have input param, then we've already cho unless ($category_type or !($categorycode)){ my $borrowercategory= GetBorrowercategory($categorycode); $category_type = $borrowercategory->{'category_type'}; + my $category_name = $borrowercategory->{'description'}; + $template->param("categoryname"=>$category_name); } $category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error ! @@ -149,8 +151,10 @@ if ($op eq 'insert'){ ); # recover the category type if the borrowers is a doublon - my $tmpborrowercategory=GetBorrowercategory($check_category); - $check_categorytype=$tmpborrowercategory->{'category_type'}; + if ($check_category) { + my $tmpborrowercategory=GetBorrowercategory($check_category); + $check_categorytype=$tmpborrowercategory->{'category_type'}; + } } #recover all data from guarantor address phone ,fax... diff --git a/members/members-home.pl b/members/members-home.pl index 212c97b17b..32531c2fa0 100755 --- a/members/members-home.pl +++ b/members/members-home.pl @@ -50,7 +50,7 @@ $template->param( "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1", ); if (C4::Context->preference("AddPatronLists")=~/code/){ - my $categories=GetBorrowercategory(); + my $categories=GetBorrowercategoryList; $categories->[0]->{'first'}=1; $template->param(categories=>$categories); } diff --git a/members/moremember.pl b/members/moremember.pl index 1b66b4475c..f2dea4f843 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -102,8 +102,7 @@ if ( $reregistration eq 'y' ) { $data->{'dateexpiry'} = ExtendMemberSubscriptionTo( $borrowernumber ); } -my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} ); -my $category_type = $borrowercategory->{'category_type'}; +my $category_type = $data->{'category_type'}; ### $category_type @@ -346,7 +345,7 @@ $template->param( DHTMLcalendar_dateformat=>C4::Dates->DHTMLcalendar(), roaddetails => $roaddetails, borrowernumber => $borrowernumber, - categoryname => $borrowercategory->{description}, + categoryname => $data->{'description'}, reregistration => $reregistration, branch => $branch, totalprice => sprintf( "%.2f", $totalprice ), diff --git a/members/pay.pl b/members/pay.pl index f9bdd14532..35faea3c59 100755 --- a/members/pay.pl +++ b/members/pay.pl @@ -131,9 +131,7 @@ if ( $check == 0 ) { }; } -my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} ); -my $category_type = $borrowercategory->{'category_type'}; -( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); +$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'}); $template->param( picture => 1 ) if $picture; diff --git a/members/readingrec.pl b/members/readingrec.pl index 5d737d1419..86564bf336 100755 --- a/members/readingrec.pl +++ b/members/readingrec.pl @@ -77,9 +77,7 @@ for (my $i=0;$i<$count;$i++){ push(@loop_reading,\%line); } - my $borrowercategory = GetBorrowercategory( $data->{'categorycode'} ); - my $category_type = $borrowercategory->{'category_type'}; - ( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' ); +$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); if (! $limit){ $limit = 'full'; } -- 2.39.5