From: Colin Campbell Date: Mon, 31 Jan 2011 16:19:49 +0000 (+0000) Subject: Bug 5673: test guarantorid consistently X-Git-Tag: html_template_pro~422 X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=commitdiff_plain;h=49b5f77194ccf688e95b3fbb5f08ea5ba18f7f7e;p=koha_fer Bug 5673: test guarantorid consistently Incorrect checking of guarantorid was causing moremember.pl to try and construct addresses using data from non-existent guarantors ensure that test is consistently checking that value is defined and not '', '0' or 0 [ i.e. what perl does for you anyway!!] Signed-off-by: Chris Cormack --- diff --git a/members/memberentry.pl b/members/memberentry.pl index fbd8538ae5..9fb8011b5a 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -198,10 +198,7 @@ if (($op eq 'insert') and !$nodouble){ } #recover all data from guarantor address phone ,fax... -if ( defined($guarantorid) and - ( $category_type eq 'C' || $category_type eq 'P' ) and - $guarantorid ne '' and - $guarantorid ne '0' ) { +if ( $guarantorid and ( $category_type eq 'C' || $category_type eq 'P' )) { if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) { $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'}; if ( !defined($data{'contactname'}) or $data{'contactname'} eq '' or @@ -438,7 +435,9 @@ foreach (qw(C A S P I X)) { $template->param('typeloop' => \@typeloop); # test in city -$select_city=getidcity($data{'city'}) if defined $guarantorid and ($guarantorid ne '0'); +if ( $guarantorid ) { + $select_city = getidcity($data{city}); +} ($default_city=$select_city) if ($step eq 0); if (!defined($select_city) or $select_city eq '' ){ $default_city = &getidcity($data{'city'}); @@ -639,7 +638,7 @@ $template->param( $template->param( nodouble => $nodouble, borrowernumber => $borrowernumber, #register number - guarantorid => (defined($borrower_data->{'guarantorid'})) ? $borrower_data->{'guarantorid'} : $guarantorid, + guarantorid => (($borrower_data->{'guarantorid'})) ? $borrower_data->{'guarantorid'} : $guarantorid, ethcatpopup => $ethcatpopup, relshiploop => \@relshipdata, city_loop => $city_arrayref, diff --git a/members/moremember.pl b/members/moremember.pl index ac98e1e171..cc2f153f59 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -155,7 +155,7 @@ $data->{ "sex_".$data->{'sex'}."_p" } = 1; my $catcode; if ( $category_type eq 'C') { - if ($data->{'guarantorid'} ne '0' ) { + if ($data->{guarantorid} ) { my $data2 = GetMember( 'borrowernumber' => $data->{'guarantorid'} ); foreach (qw(address city B_address B_city phone mobile zipcode country B_country)) { $data->{$_} = $data2->{$_}; diff --git a/members/update-child.pl b/members/update-child.pl index 39e19a1f31..492219f483 100755 --- a/members/update-child.pl +++ b/members/update-child.pl @@ -81,7 +81,7 @@ if ( $op eq 'multi' ) { elsif ( $op eq 'update' ) { my $member = GetMember('borrowernumber'=>$borrowernumber); - $member->{'guarantorid'} = '0'; + $member->{'guarantorid'} = 0; $member->{'categorycode'} = $catcode; my $borcat = GetBorrowercategory($catcode); $member->{'category_type'} = $borcat->{'category_type'};