@@ -, +, @@ value at cataloguing/additem.pl 3.1 empty: /cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=384&itemnumber= 3.2 an itemnumber that doesn't exist: /cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=384&itemnumber=9999999999 3.3 whatever else you come up with.. --- cataloguing/additem.pl | 33 ++++++++++++------- .../prog/en/modules/cataloguing/additem.tt | 15 ++++++++- 2 files changed, 36 insertions(+), 12 deletions(-) --- a/cataloguing/additem.pl +++ a/cataloguing/additem.pl @@ -156,6 +156,13 @@ my ($template, $loggedinuser, $cookie) flagsrequired => {editcatalogue => $userflags}, }); +if ( $op eq "edititem" || $op eq "dupeitem" ) { + my $item = Koha::Items->find($itemnumber); + if ( !$item ) { + $itemnumber = undef; + $template->param( item_doesnt_exist => 1 ); + } +} # Does the user have a restricted item editing permission? my $uid = Koha::Patrons->find( $loggedinuser )->userid; @@ -462,21 +469,25 @@ if ($op eq "additem") { } elsif ($op eq "edititem") { #------------------------------------------------------------------------------- # retrieve item if exist => then, it's a modif - $current_item = Koha::Items->find($itemnumber)->unblessed; - # FIXME Handle non existent item - $nextop = "saveitem"; + $nextop = "additem"; + if ($itemnumber) { + $current_item = Koha::Items->find($itemnumber)->unblessed; + $nextop = "saveitem"; + } #------------------------------------------------------------------------------- } elsif ($op eq "dupeitem") { #------------------------------------------------------------------------------- # retrieve item if exist => then, it's a modif - $current_item = Koha::Items->find($itemnumber)->unblessed; - # FIXME Handle non existent item - if (C4::Context->preference('autoBarcode') eq 'incremental') { - my ( $barcode ) = C4::Barcodes::ValueBuilder::incremental::get_barcode; - $current_item->{barcode} = $barcode; - } - else { - $current_item->{barcode} = undef; # Don't save it! + if ($itemnumber) { + $current_item = Koha::Items->find($itemnumber)->unblessed; + if ( C4::Context->preference('autoBarcode') eq 'incremental' ) { + my ($barcode) = + C4::Barcodes::ValueBuilder::incremental::get_barcode; + $current_item->{barcode} = $barcode; + } + else { + $current_item->{barcode} = undef; # Don't save it! + } } $nextop = "additem"; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -25,7 +25,14 @@ [% INCLUDE 'str/cataloging_additem.inc' %] [% Asset.js("js/cataloging_additem.js") | $raw %] @@ -70,6 +77,12 @@ [% IF ( linked_analytics ) %]
Cannot delete: item has linked analytics..
[% END %] [% IF last_item_for_hold %]
Cannot delete: Last item for bibliographic record with biblio-level hold on it.
[% END %] [% IF item_not_found %]
Cannot delete: Item not found.
[% END %] +[% IF item_doesnt_exist %] +
+The item you are trying to access doesn't exist.
+Add a new item or go to the records holdings. +
+[% END %]
[% IF items %] --