From 4b71494f19f02a5037ab536b748c3f6f017cea99 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sun, 23 Aug 2009 12:49:17 -0400 Subject: [PATCH] bug 3481 followup - set temporary processing location Ensure that the temporary processing location is always set regardless of whether one item is added or multiple copies are added at once. Signed-off-by: Galen Charlton --- cataloguing/additem.pl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index d5bf07e731..e25bb44dcb 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -58,6 +58,16 @@ sub get_item_from_barcode { return($result); } +sub set_item_default_location { + my $itemnumber = shift; + if ( C4::Context->preference('NewItemsDefaultLocation') ) { + my $item = GetItem( $itemnumber ); + $item->{'permanent_location'} = $item->{'location'}; + $item->{'location'} = C4::Context->preference('NewItemsDefaultLocation'); + ModItem( $item, undef, $itemnumber); + } +} + my $input = new CGI; my $dbh = C4::Context->dbh; my $error = $input->param('error'); @@ -130,7 +140,10 @@ if ($op eq "additem") { my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'}); push @errors,"barcode_not_unique" if($exist_itemnumber); # if barcode exists, don't create, but report The problem. - my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber) unless ($exist_itemnumber); + unless ($exist_itemnumber) { + my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber); + set_item_default_location($oldbibitemnum); + } $nextop = "additem"; if ($exist_itemnumber) { $itemrecord = $record; @@ -200,17 +213,12 @@ if ($op eq "additem") { # Adding the item if (!$exist_itemnumber) { my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber); + set_item_default_location($oldbibitemnum); # We count the item only if it was really added # That way, all items are added, even if there was some already existing barcodes # FIXME : Please note that there is a risk of infinite loop here if we never find a suitable barcode $i++; - if ( C4::Context->preference('NewItemsDefaultLocation') ) { - my $item = GetItem( $oldbibitemnum ); - $item->{'permanent_location'} = $item->{'location'}; - $item->{'location'} = C4::Context->preference('NewItemsDefaultLocation'); - ModItem( $item, $oldbiblionumber, $oldbibitemnum ); - } } # Preparing the next iteration -- 2.39.5