@@ -, +, @@ 1 - Create a list 2 - Add some items 3 - Verify items are added and success reported 4 - Add these items again 5 - Verify you are notified they were not added 6 - Type invalid barcodes into the text area and submit 7 - Verify you are notifed of failure to add 8 - Try going to a list that doesn't exist and adding barcodes i.e. http://localhost:8081/cgi-bin/koha/virtualshelves/shelves.pl?op=add_biblio&shelfnumber=9999&barcodes=4 9 - Verify correct error without lists permission: i.e. http://localhost:8080/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=3 --- .../prog/en/modules/virtualshelves/shelves.tt | 12 ++++---- virtualshelves/shelves.pl | 32 ++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -333,7 +333,7 @@ function placeHold () { [% CASE 'error_on_delete' %] An error occurred when deleting this list. [% CASE 'error_on_add_biblio' %] - The item has not been added to the list. Please verify it is not already in the list. + The item ([% m.item_barcode %]) has not been added to the list. Please verify it is not already in the list. [% CASE 'success_on_update' %] List updated. [% CASE 'success_on_insert' %] @@ -341,13 +341,13 @@ function placeHold () { [% CASE 'success_on_delete' %] List deleted. [% CASE 'success_on_add_biblio' %] - The item has been added to the list. + The item ([% m.item_barcode %]) has been added to the list. [% CASE 'success_on_remove_biblios' %] The item has been removed from the list. [% CASE 'does_not_exist' %] This list does not exist. [% CASE 'item_does_not_exist' %] - This item does not exist. + The item ([% m.item_barcode %]) does not exist. [% CASE 'unauthorized_on_view' %] You do not have permission to view this list. [% CASE 'unauthorized_on_update' %] @@ -659,11 +659,11 @@ function placeHold () {
- Add an item + Add items
  1. - - + + --- a/virtualshelves/shelves.pl +++ a/virtualshelves/shelves.pl @@ -137,24 +137,28 @@ if ( $op eq 'add_form' ) { $shelfnumber = $query->param('shelfnumber'); $shelf = Koha::Virtualshelves->find($shelfnumber); if ($shelf) { - if( my $barcode = $query->param('barcode') ) { - my $item = GetItem( 0, $barcode); - if (defined $item && $item->{itemnumber}) { - my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); - if ( $shelf->can_biblios_be_added( $loggedinuser ) ) { - my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); }; - if ($@) { - push @messages, { type => 'error', code => ref($@), msg => $@ }; - } elsif ( $added ) { - push @messages, { type => 'message', code => 'success_on_add_biblio' }; + if( my $barcodes = $query->param('barcodes') ) { + if ( $shelf->can_biblios_be_added( $loggedinuser ) ) { + my @barcodes = split /\n/, $barcodes; # Entries are effectively passed in as a separated list + foreach my $barcode (@barcodes){ + $barcode =~ s/\r$//; # strip any naughty return chars + my $item = GetItem( 0, $barcode); + if (defined $item && $item->{itemnumber}) { + my $biblio = GetBiblioFromItemNumber( $item->{itemnumber} ); + my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); }; + if ($@) { + push @messages, { item_barcode => $barcode, type => 'error', code => ref($@), msg => $@ }; + } elsif ( $added ) { + push @messages, { item_barcode => $barcode, type => 'message', code => 'success_on_add_biblio' }; + } else { + push @messages, { item_barcode => $barcode, type => 'message', code => 'error_on_add_biblio' }; + } } else { - push @messages, { type => 'message', code => 'error_on_add_biblio' }; + push @messages, { item_barcode => $barcode, type => 'error', code => 'item_does_not_exist' }; } - } else { - push @messages, { type => 'error', code => 'unauthorized_on_add_biblio' }; } } else { - push @messages, { type => 'error', code => 'item_does_not_exist' }; + push @messages, { type => 'error', code => 'unauthorized_on_add_biblio' }; } } } else { --