Fix upgrade-child: could not update child unless guarantor was defined. Also, limit upgrade path to C -> A .

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Ryan Higgins 2008-06-12 16:23:32 -05:00 committed by Joshua Ferraro
parent e70e3bcd6d
commit 3675d88035
3 changed files with 16 additions and 14 deletions

View file

@ -1322,13 +1322,14 @@ to category descriptions.
#' #'
sub GetborCatFromCatType { sub GetborCatFromCatType {
my ( $category_type, $action ) = @_; my ( $category_type, $action ) = @_;
# FIXME - This API seems both limited and dangerous.
my $dbh = C4::Context->dbh; my $dbh = C4::Context->dbh;
my $request = qq| SELECT categorycode,description my $request = qq| SELECT categorycode,description
FROM categories FROM categories
$action $action
ORDER BY categorycode|; ORDER BY categorycode|;
my $sth = $dbh->prepare($request); my $sth = $dbh->prepare($request);
if ($action) { if ($action) {
$sth->execute($category_type); $sth->execute($category_type);
} }
else { else {

View file

@ -131,19 +131,18 @@ $data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} );
$data->{ "sex_".$data->{'sex'}."_p" } = 1; $data->{ "sex_".$data->{'sex'}."_p" } = 1;
my $catcode; my $catcode;
if ( $category_type eq 'C' and $data->{'guarantorid'} ne '0' ) { if ( $category_type eq 'C') {
my $data2 = GetMember( $data->{'guarantorid'} ,'borrowernumber'); if ($data->{'guarantorid'} ne '0' ) {
foreach (qw(address city B_address B_city phone mobile zipcode)) { my $data2 = GetMember( $data->{'guarantorid'} ,'borrowernumber');
$data->{$_} = $data2->{$_}; 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); 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_MULTI' => 1) if $cnt > 1; $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
$template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
} }

View file

@ -57,7 +57,9 @@ my $op = $input->param('op');
if ( $op eq 'multi' ) { if ( $op eq 'multi' ) {
my ( $catcodes, $labels ) = 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; my @rows;
foreach my $k ( keys %$labels ) { foreach my $k ( keys %$labels ) {
my $row; my $row;