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 <gmcharlt@gmail.com>
This commit is contained in:
Galen Charlton 2009-08-23 12:49:17 -04:00
parent 8219d79f5a
commit 4b71494f19

View file

@ -58,6 +58,16 @@ sub get_item_from_barcode {
return($result); 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 $input = new CGI;
my $dbh = C4::Context->dbh; my $dbh = C4::Context->dbh;
my $error = $input->param('error'); my $error = $input->param('error');
@ -130,7 +140,10 @@ if ($op eq "additem") {
my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'}); my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
push @errors,"barcode_not_unique" if($exist_itemnumber); push @errors,"barcode_not_unique" if($exist_itemnumber);
# if barcode exists, don't create, but report The problem. # 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"; $nextop = "additem";
if ($exist_itemnumber) { if ($exist_itemnumber) {
$itemrecord = $record; $itemrecord = $record;
@ -200,17 +213,12 @@ if ($op eq "additem") {
# Adding the item # Adding the item
if (!$exist_itemnumber) { if (!$exist_itemnumber) {
my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber); my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber);
set_item_default_location($oldbibitemnum);
# We count the item only if it was really added # We count the item only if it was really added
# That way, all items are added, even if there was some already existing barcodes # 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 # FIXME : Please note that there is a risk of infinite loop here if we never find a suitable barcode
$i++; $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 # Preparing the next iteration