From 116920d2da2bf8d1c808ce60cac547a5ae3bc3eb Mon Sep 17 00:00:00 2001 From: Shi Yao Wang Date: Thu, 31 Aug 2023 13:31:16 -0400 Subject: [PATCH] Bug 34668: Add popup warn librarians of waiting holds when checking out When there are holds waiting for patrons, sometimes the librarian misses the "Holds waiting here" display. This patch adds a modal popup warning when checking out an item for a patron with waiting holds. Test plan: 1) find a user (user1) 2) find a biblio (biblio1) 3) add a hold for biblio1 to user1 (search biblio1 > Holds > find user1 > Place hold) 4) checkout biblio1 to another user if not already checked out and checkin through circulation page (not through the user page) > confirm hold 5) there should be a "Holds waiting here (1)" section added on user1 page 6) checkout any items that isn't the one on hold for user1 -> notice it just checks out as normal 7) apply patch and update database 8) go to administration > system preferences > switch "WaitingNotifyAtCheckout" to "Notify" 9) refresh page and redo step 6 -> notice there is now a modal to warn the librarian of a waiting hold click Ok to proceed with the checkout, click outside the modal to not do anything 10) additionnally, the popup shouldn't appear if we checkout any of user1's waiting hold --- circ/circulation.pl | 10 +++ ...668-add_WaitingNotifyAtCheckout_syspref.pl | 16 +++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/circulation.pref | 6 ++ .../prog/en/modules/circ/circulation.tt | 64 ++++++++++++++++++- 5 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_34668-add_WaitingNotifyAtCheckout_syspref.pl diff --git a/circ/circulation.pl b/circ/circulation.pl index 9b925e29ad..4d4649bb53 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -547,6 +547,16 @@ if ( $patron ) { ); $template->param( patron_messages => $patron_messages ); + if (C4::Context->preference("WaitingNotifyAtCheckout") ) { + #Check for waiting holds + my $waiting_holds = $patron->holds->search({ found => 'W', branchcode => $branch }); + my @waiting_holds_barcodes = (); + while (my $hold = $waiting_holds->next) { + push(@waiting_holds_barcodes, $hold->item->barcode); + } + + $template->param( waiting_holds_barcodes => \@waiting_holds_barcodes ); + } } my $fast_cataloging = 0; diff --git a/installer/data/mysql/atomicupdate/bug_34668-add_WaitingNotifyAtCheckout_syspref.pl b/installer/data/mysql/atomicupdate/bug_34668-add_WaitingNotifyAtCheckout_syspref.pl new file mode 100644 index 0000000000..d7a8848ed3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_34668-add_WaitingNotifyAtCheckout_syspref.pl @@ -0,0 +1,16 @@ +use Modern::Perl; + +return { + bug_number => "34668", + description => "Add syspref WaitingNotifyAtCheckout", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Do you stuffs here + $dbh->do(q{INSERT IGNORE INTO `systempreferences` (variable,value,options,explanation,type) VALUES('WaitingNotifyAtCheckout','0',NULL,'If ON, notify librarians of waiting holds for the patron whose items they are checking out.','YesNo') }); + + say $out "Added new system preference 'WaitingNotifyAtCheckout'"; + + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 30197591a8..a3eeae93c2 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -793,6 +793,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('viewMARC','1','','Allow display of MARC view of bibiographic records','YesNo'), ('virtualshelves','1','','If ON, enables Lists management','YesNo'), ('WaitingNotifyAtCheckin','0',NULL,'If ON, notify librarians of waiting holds for the patron whose items they are checking in.','YesNo'), +('WaitingNotifyAtCheckout','0',NULL,'If ON, notify librarians of waiting holds for the patron whose items they are checking out.','YesNo'), ('WebBasedSelfCheck','0',NULL,'If ON, enables the web-based self-check system','YesNo'), ('WhenLostChargeReplacementFee','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo'), ('WhenLostForgiveFine','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 55feb4d444..89f7ce8798 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -97,6 +97,12 @@ Circulation: 1: Notify 0: "Don't notify" - librarians of waiting holds for the patron whose items they are checking in. + - + - pref: WaitingNotifyAtCheckout + choices: + 1: Notify + 0: "Don't notify" + - librarians of waiting holds for the patron whose items they are checking out. - - pref: FilterBeforeOverdueReport choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 3388e387a5..17937d7ffb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -666,7 +666,11 @@ - + [% IF waiting_holds_barcodes %] + + [% ELSE %] + + [% END %]
@@ -865,6 +869,28 @@
+[% IF waiting_holds_barcodes %] + +[% END %] + [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -931,6 +957,42 @@ var newin = window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); } $(document).ready(function() { + [% IF waiting_holds_barcodes %] + $('#circ-warnwaitingholds-modal .btn-primary').on('click',function() { + $('#mainform').submit(); + }); + + var waiting_holds_barcodes = new Array(); + [% FOREACH b IN waiting_holds_barcodes %] + waiting_holds_barcodes.push("[% b %]"); + [% END %] + $('#barcode').on('keyup', function() { + $('#mainform .btn-primary').off('click'); + $('#barcode').off('keypress'); + if ( waiting_holds_barcodes.includes($('#barcode').val().trim()) ) { + $('#mainform .btn-primary').on('click',function() { + $('#mainform').submit(); + }); + + $('#barcode').on('keypress', function(e) { + if (e.which == 13) { + $('#mainform').submit(); + } + }); + } else { + $('#mainform .btn-primary').on('click',function() { + $('#circ-warnwaitingholds-modal').modal(); + }); + + $('#barcode').on('keypress', function(e) { + if (e.which == 13) { + $('#circ-warnwaitingholds-modal').modal(); + } + }); + } + }); + [% END %] + $('#mainform').on('submit',function() { if ($("#barcode") && $("#barcode").val()) { $('#barcode').on('keypress',function(event) { -- 2.34.1