From 70d72e3d9c072dd5e59c57026898bbd44fe7e1a7 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 20 Apr 2017 01:50:38 +0000 Subject: [PATCH] Bug 17214: Add records to lists by biblionumber MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit To test: 1) Apply patch and go to Lists 2) Click on an existing list or create a new list 3) Add items by barcode, confirm this functionality still works 4) Trigger error messages (adding duplicate barcodes, barcodes that don't exist) to confirm they still show as appropriate 5) Test adding by biblionumber, confirm this works as expected 6) Trigger error messages (adding duplicate biblionumbers, biblionumbers that don't exist). Confirm wording is appropriate in messages. 7) Add both barcodes and biblionumbers at the same time, confirm this works as expected Sponsored-by: Catalyst IT Signed-off-by: Israelex A Veleña for KohaCon17 Signed-off-by: Israelex A Veleña for KohaCon17 Signed-off-by: Harold Signed-off-by: macon lauren KohaCon2017 Signed-off-by: Katrin Fischer Bug 17214: [FOLLOW-UP] Using Koha::Biblios instead of GetBiblio Ready to test Signed-off-by: Katrin Fischer Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- .../prog/en/modules/virtualshelves/shelves.tt | 25 ++++++++++++++++--- virtualshelves/shelves.pl | 24 ++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index 6786c247f7..a81214f418 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -379,7 +379,11 @@ function AdjustRemark() { [% CASE 'error_on_delete' %] An error occurred when deleting this list. [% CASE 'error_on_add_biblio' %] - The item ([% m.item_barcode %]) has not been added to the list. Please verify it is not already in the list. + [% IF m.item_barcode %] + The item ([% m.item_barcode %]) has not been added to the list. Please verify it is not already in the list. + [% ELSE %] + The record ([% m.bibnum %]) has not been added to the list. Please verify it is not already in the list. + [% END %] [% CASE 'success_on_update' %] List updated. [% CASE 'success_on_insert' %] @@ -387,13 +391,21 @@ function AdjustRemark() { [% CASE 'success_on_delete' %] List deleted. [% CASE 'success_on_add_biblio' %] - The item ([% m.item_barcode %]) has been added to the list. + [% IF m.item_barcode %] + The item ([% m.item_barcode %]) has been added to the list. + [% ELSE %] + The record ([% m.bibnum %]) has been added to the list. + [% END %] [% 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' %] - The item ([% m.item_barcode %]) does not exist. + [% IF m.item_barcode %] + The item ([% m.item_barcode %]) does not exist. + [% ELSE %] + The record ([% m.bibnum %]) does not exist. + [% END %] [% CASE 'unauthorized_on_view' %] You do not have permission to view this list. [% CASE 'unauthorized_on_update' %] @@ -687,6 +699,13 @@ function AdjustRemark() { +
  • + + + + + +
  • diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl index d3aea7e8cd..192580f857 100755 --- a/virtualshelves/shelves.pl +++ b/virtualshelves/shelves.pl @@ -169,6 +169,30 @@ if ( $op eq 'add_form' ) { push @messages, { type => 'alert', code => 'unauthorized_on_add_biblio' }; } } + if ( my $biblionumbers = $query->param('biblionumbers') ) { + if ( $shelf->can_biblios_be_added( $loggedinuser ) ) { + my @biblionumbers = split /\n/, $biblionumbers; + foreach my $biblionumber (@biblionumbers) { + $biblionumber =~ s/\r$//; # strip any naughty return chars + next if $biblionumber eq ''; + my $biblio = Koha::Biblios->find($biblionumber); + if (defined $biblio) { + my $added = eval { $shelf->add_biblio( $biblionumber, $loggedinuser ); }; + if ($@) { + push @messages, { bibnum => $biblionumber, type => 'alert', code => ref($@), msg => $@ }; + } elsif ( $added ) { + push @messages, { bibnum => $biblionumber, type => 'message', code => 'success_on_add_biblio' }; + } else { + push @messages, { bibnum => $biblionumber, type => 'message', code => 'error_on_add_biblio' }; + } + } else { + push @messages, { bibnum => $biblionumber, type => 'alert', code => 'item_does_not_exist' }; + } + } + } else { + push @messages, { type => 'alert', code => 'unauthorized_on_add_biblio' }; + } + } } else { push @messages, { type => 'alert', code => 'does_not_exist' }; } -- 2.39.5