From 49b5f77194ccf688e95b3fbb5f08ea5ba18f7f7e Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Mon, 31 Jan 2011 16:19:49 +0000 Subject: [PATCH] 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 --- members/memberentry.pl | 11 +++++------ members/moremember.pl | 2 +- members/update-child.pl | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) 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'}; -- 2.39.5