From 3675d8803579a275831816cd68b2dc1430f0763f Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Thu, 12 Jun 2008 16:23:32 -0500 Subject: [PATCH] Fix upgrade-child: could not update child unless guarantor was defined. Also, limit upgrade path to C -> A . Signed-off-by: Joshua Ferraro --- C4/Members.pm | 3 ++- members/moremember.pl | 25 ++++++++++++------------- members/update-child.pl | 4 +++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 0fd01f2dab..9c343513dd 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1322,13 +1322,14 @@ to category descriptions. #' sub GetborCatFromCatType { my ( $category_type, $action ) = @_; + # FIXME - This API seems both limited and dangerous. my $dbh = C4::Context->dbh; my $request = qq| SELECT categorycode,description FROM categories $action ORDER BY categorycode|; my $sth = $dbh->prepare($request); - if ($action) { + if ($action) { $sth->execute($category_type); } else { diff --git a/members/moremember.pl b/members/moremember.pl index 723bb74aaa..5989627335 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -131,19 +131,18 @@ $data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} ); $data->{ "sex_".$data->{'sex'}."_p" } = 1; my $catcode; -if ( $category_type eq 'C' and $data->{'guarantorid'} ne '0' ) { - my $data2 = GetMember( $data->{'guarantorid'} ,'borrowernumber'); - foreach (qw(address city B_address B_city phone mobile zipcode)) { - $data->{$_} = $data2->{$_}; - } - my ( $catcodes, $labels ) = - GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); - my $cnt = scalar(@$catcodes); - -# $cnt = 1; - $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; - - $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; +if ( $category_type eq 'C') { + if ($data->{'guarantorid'} ne '0' ) { + my $data2 = GetMember( $data->{'guarantorid'} ,'borrowernumber'); + foreach (qw(address city B_address B_city phone mobile zipcode)) { + $data->{$_} = $data2->{$_}; + } + } + my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); + my $cnt = scalar(@$catcodes); + + $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; + $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; } diff --git a/members/update-child.pl b/members/update-child.pl index 70452997ce..cdfc5ffdb7 100755 --- a/members/update-child.pl +++ b/members/update-child.pl @@ -57,7 +57,9 @@ my $op = $input->param('op'); if ( $op eq 'multi' ) { my ( $catcodes, $labels ) = - GetborCatFromCatType( 'C', 'WHERE category_type <> ?' ); + # FIXME - what are the possible upgrade paths? C -> A , C -> S ... + # currently just allowing C -> A because of limitation of API. + GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); my @rows; foreach my $k ( keys %$labels ) { my $row; -- 2.39.5