Bug 21565: Add modal to SCO confirm

This patch uses the confirmModal framework to add a modal confirm to
SCO Finish.

TO TEST:

1. Enable SCO and go to /cgi-bin/koha/sco/sco-main.pl. Make sure
   SelfCheckReceiptPrompt is set to 'show'
2. Login and click 'Finish' to see the old print alert box.
3. Apply patch and repeat steps 1 and 2.
4. Make sure the modal works for confirming and denying a receipt.
   Checkout some items and make sure everything still functions the
   same.
5. Make sure when printing a receipt that the print dialog automatally
   shows
6. Set SelfCheckReceiptPrompt to 'Don't show' and confirm behavior is
   acceptable.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Lucas Gass 2020-04-24 18:39:02 +00:00 committed by Martin Renvoize
parent 3e44091553
commit 4317229ae9
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -473,17 +473,22 @@
]
}));
$("#logout_form").submit(function(){
$("#logout_form").submit(function(e){
e.preventDefault(e);
clearTimeout(mainTimeout);
[% IF Koha.Preference('SelfCheckReceiptPrompt') %]
var confirmStart = Date.now();
if(confirm(_("Would you like to print a receipt?"))){
if ( (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {
window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber | html %]&amp;print=qslip");
confirmModal("", _("Would you like to print a receipt?"), _("Yes"), _("No"), function(result) {
if ( result && (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {
var win = window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber | html %]&amp;print=qslip");
win.print();
location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
} else {
alert(_("Timeout while waiting for print confirmation"));
location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
}
}
})
[% ELSE %]
location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
[% END %]
return true;