From 1af6432206a1178e190922f8d0bae252a0266d00 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 24 Apr 2020 18:39:02 +0000 Subject: [PATCH] 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 --- .../opac-tmpl/bootstrap/en/modules/sco/sco-main.tt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 274c2c9521..6383a7a1a0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -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 %]&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 %]&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; -- 2.11.0