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

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Signed-off-by: Mia Kujala <mia.kujala@xamk.fi>
Signed-off-by: Kelly <kelly@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Shi Yao Wang 2023-08-31 13:31:16 -04:00 committed by Katrin Fischer
parent 75275ec291
commit 92c17fc3cd
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
5 changed files with 97 additions and 1 deletions

View File

@ -629,6 +629,17 @@ 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;

View File

@ -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'";
},
};

View File

@ -828,6 +828,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'),

View File

@ -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:

View File

@ -762,7 +762,11 @@
<a href="#" title="Checkout settings"><i class="fa-solid fa-sliders"></i></a>
</div>
<button type="submit" class="btn btn-primary">Check out</button>
[% IF waiting_holds_barcodes %]
<button type="button" class="btn btn-primary">Check out</button>
[% ELSE %]
<button type="submit" class="btn btn-primary">Check out</button>
[% END %]
<div class="circ-settings">
@ -961,6 +965,28 @@
</div> <!-- /.modal-dialog -->
</div> <!-- /#barcodeSubmittedModal -->
[% IF waiting_holds_barcodes %]
<div id="circ-warnwaitingholds-modal" class="modal fade audio-alert-action block">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3>This patron has waiting holds</h3>
</div>
<div class="modal-body">
<ul>
<li>
This patron has waiting holds that are available for checkout
</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Ok</button>
</div>
</div>
</div>
</div>
[% END %]
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'datatables.inc' %]
[% INCLUDE 'columns_settings.inc' %]
@ -1028,6 +1054,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 | html %]");
[% 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) {