- if ($add_submit || $add_duplicate_submit) {
- # check for item barcode # being unique
- 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.
- unless ($exist_itemnumber) {
- my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = AddItemFromMarc($record,$biblionumber);
- set_item_default_location($oldbibitemnum);
- }
- $nextop = "additem";
- if ($exist_itemnumber) {
- $itemrecord = $record;
- }
+ if ( $add_submit || $add_duplicate_submit ) {
+
+ # check for item barcode # being unique
+ 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.
+ unless ($exist_itemnumber) {
+ my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
+ set_item_default_location($oldbibitemnum);
+
+ # Pushing the last created item cookie back
+ if ($prefillitem && defined $record) {
+ my $itemcookie = $input->cookie(
+ -name => 'LastCreatedItem',
+ # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
+ -value => uri_escape_utf8( freeze( $record ) ),
+ -HttpOnly => 1,
+ -expires => ''
+ );
+
+ $cookie = [ $cookie, $itemcookie ];
+ }
+
+ }
+ $nextop = "additem";
+ if ($exist_itemnumber) {
+ $itemrecord = $record;
+ }