From ab72ae6f3786f94d2ae97ce3b473399f1f70f9ad Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 15 Dec 2017 17:26:12 +0000 Subject: [PATCH] Bug 19837 - Add multiple patrons to a list by barcode This patch adds the interface change and basic functionality for an option to add multiple patrons to a patron list by scanning barcodes. To test, apply the patch and go to Tools -> Patron lists. - Create a patron list if necessary, and got to the "Add patrons" screen. - Test the process for adding patrons using the "Patron search" text input. - Test the process for adding patrons using the "Enter multiple card numbers" option. This should really have some error-handling added to it: Onscreen messages when a non-existing patron card number is submitted or when a patron already exists on the list. --- .../prog/en/modules/patron_lists/list.tt | 69 +++++++++++++++++----- patron_lists/list.pl | 9 +++ 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt index e0092fb..d18bf6f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt @@ -3,8 +3,21 @@ [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Patron lists › [% list.name %] › Add patrons [% INCLUDE 'doc-head-close.inc' %] - + @@ -18,25 +31,41 @@

[% list.name |html %]

-
-
+ +
Add patrons +
    +
  1. + + +
  2. + +
  3. +   + Enter multiple card numbers
  4. +
  5. + + +
  6. +
+
+
+ +
- - -
+
-
- Patrons to be added -
+
+ Patrons to be added +
-
- - - Cancel -
+
+ + + Cancel
-
@@ -159,6 +188,16 @@ return false; } }); + + $("#add_patrons_by_barcode a").on("click", function(){ + $("#add_patrons_by_barcode, #patron_search_line").hide(); + $("#add_patrons_by_search, #patron_barcodes_line, #patron_barcodes_submit").show(); + }); + + $("#add_patrons_by_search a").on("click", function(){ + $("#add_patrons_by_barcode, #patron_search_line").show(); + $("#add_patrons_by_search, #patron_barcodes_line, #patron_barcodes_submit").hide(); + }); }); [% END %] diff --git a/patron_lists/list.pl b/patron_lists/list.pl index 9a21681..91e6370 100755 --- a/patron_lists/list.pl +++ b/patron_lists/list.pl @@ -24,6 +24,7 @@ use CGI qw ( -utf8 ); use C4::Auth; use C4::Output; use Koha::List::Patron; +use List::MoreUtils qw/uniq/; my $cgi = new CGI; @@ -40,6 +41,14 @@ my ( $template, $logged_in_user, $cookie ) = get_template_and_user( my ($list) = GetPatronLists( { patron_list_id => scalar $cgi->param('patron_list_id') } ); +my $cardnumbers = $cgi->param('patrons_by_barcode'); +my @patrons_by_barcode; + +if ( $cardnumbers ){ + push my @patrons_by_barcode, uniq( split(/\s\n/, $cardnumbers) ); + AddPatronsToList( { list => $list, cardnumbers => \@patrons_by_barcode } ); +} + my @patrons_to_add = $cgi->multi_param('patrons_to_add'); if (@patrons_to_add) { AddPatronsToList( { list => $list, cardnumbers => \@patrons_to_add } ); -- 2.1.4