Bug 11498 - Prevent bypassing sco timeout with print dialog

This patch prevents bypassing the self check timeout with the print dialog.

To test:
- Set syspref 'WebVasedSelfCheck' to 'Enable'
- Set syspref 'SelfCheckoutReceivePrompt' to 'Show'
- Set syspref 'SelfCheckTimeout' to 20 seconds
- Apply patch
- Go to SCO page (/cgi-bin/koha/sco/sco-main.pl)
- Enter card number
- Click 'Finish'. Dialog "Would you like to pritn a receipt?' appears.
- Confirm printing without waiting 20 seconds
  => Result: Print slip, SCO page shows 'Please enter your card number'
- Enter card number again
- Click 'Finish'. Dialog "Would you like to pritn a receipt?' appears.
- Wait > 20 seconds (value of SelfCheckTimeout) and then confirm.
  => Result: Message appears "Timeout while waiting for print confirmation"
- Click on OK.
  => Result: Self checkout page refreshes (shows 'Please enter your card number')

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

https://bugs.koha-community.org/show_bug.cgi?id=11497

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
(cherry picked from commit 7f8037f642)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
Marc Véron 2016-02-10 17:21:40 +01:00 committed by Julian Maurice
parent 107e6de672
commit 80737996ec
1 changed files with 6 additions and 1 deletions

View File

@ -370,8 +370,13 @@
$("#logout_form").submit(function(){
clearTimeout(mainTimeout);
[% IF Koha.Preference('SelfCheckReceiptPrompt') %]
var confirmStart = Date.now();
if(confirm(_("Would you like to print a receipt?"))){
window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&amp;print=qslip");
if ( (Date.now() - confirmStart) < [% SelfCheckTimeout %] ) {
window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&amp;print=qslip");
} else {
alert(_("Timeout while waiting for print confirmation"));
}
}
[% END %]