Bugzilla – Attachment 60632 Details for
Bug 7663
batch add barcodes to a list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7663 - batch add barcodes to a list
Bug-7663---batch-add-barcodes-to-a-list.patch (text/plain), 6.68 KB, created by
Jonathan Druart
on 2017-02-24 07:46:52 UTC
(
hide
)
Description:
Bug 7663 - batch add barcodes to a list
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-02-24 07:46:52 UTC
Size:
6.68 KB
patch
obsolete
>From 7397a3743c3981fe5cacf4b5e7f3c39a0f8aa3a8 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 1 Dec 2016 11:47:31 +0000 >Subject: [PATCH] Bug 7663 - batch add barcodes to a list > >This patch changes the barcode input on add list to a textarea and >process multiples barcodes to allow for adding many items to a list >at once > >To test: > 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 >10 - Try the above but with a list that exists while signed in as a patron > without lists permission: > i.e. http://localhost:8080/cgi-bin/koha/opac-shelves.pl?op=view&shelfnumber=3 >11 - Verify correct error: "You do not have permission to view this list." > >Signed-off-by: Chris Kirby <chris.kirby@ilsleypubliclibrary.org> >Works as advertised. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/en/modules/virtualshelves/shelves.tt | 12 ++++---- > virtualshelves/shelves.pl | 32 ++++++++++++---------- > 2 files changed, 24 insertions(+), 20 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 a276236..2044754 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -333,7 +333,7 @@ function placeHold () { > [% CASE 'error_on_delete' %] > <span>An error occurred when deleting this list.</span> > [% CASE 'error_on_add_biblio' %] >- <span>The item has not been added to the list. Please verify it is not already in the list.</span> >+ <span>The item ([% m.item_barcode %]) has not been added to the list. Please verify it is not already in the list.</span> > [% CASE 'success_on_update' %] > <span>List updated.</span> > [% CASE 'success_on_insert' %] >@@ -341,13 +341,13 @@ function placeHold () { > [% CASE 'success_on_delete' %] > <span>List deleted.</span> > [% CASE 'success_on_add_biblio' %] >- <span>The item has been added to the list.</span> >+ <span>The item ([% m.item_barcode %]) has been added to the list.</span> > [% CASE 'success_on_remove_biblios' %] > <span>The item has been removed from the list.</span> > [% CASE 'does_not_exist' %] > <span>This list does not exist.</span> > [% CASE 'item_does_not_exist' %] >- <span>This item does not exist.</span> >+ <span>The item ([% m.item_barcode %]) does not exist.</span> > [% CASE 'unauthorized_on_view' %] > <span>You do not have permission to view this list.</span> > [% CASE 'unauthorized_on_update' %] >@@ -659,11 +659,11 @@ function placeHold () { > <div class="yui-b"> > <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post"> > <fieldset class="brief noprint"> >- <legend>Add an item</legend> >+ <legend>Add items</legend> > <ol> > <li> >- <label for="barcode">Barcode:</label> >- <input name="barcode" type="text" id="barcode" class="focus" autocomplete="off" /> >+ <label for="barcodes">Barcodes:</label> >+ <textarea name="barcodes" id="barcodes" class="focus" autocomplete="off" rows="5"></textarea> > <input type="hidden" name="op" value="add_biblio" /> > <input type="hidden" name="referer" value="view" /> > <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber %]" /> >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index 3faa0e5..3e03e6d 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -140,24 +140,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 => 'alert', 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 <cr> 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 => 'alert', code => 'unauthorized_on_add_biblio' }; > } > } else { >- push @messages, { type => 'alert', code => 'item_does_not_exist' }; >+ push @messages, { type => 'error', code => 'unauthorized_on_add_biblio' }; > } > } > } else { >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7663
:
57855
|
57865
|
57868
|
60627
|
60628
| 60632 |
60633
|
60634