Bug 40158 - SCO receipt doesnt print when SelfCheckReceiptPrompt is on
Summary: SCO receipt doesnt print when SelfCheckReceiptPrompt is on
Status: RESOLVED DUPLICATE of bug 40108
Alias: None
Product: Koha
Classification: Unclassified
Component: Self checkout (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on: 36586
Blocks:
  Show dependency treegraph
 
Reported: 2025-06-17 22:05 UTC by Lucas Gass (lukeg)
Modified: 2025-06-18 23:14 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40158: Multiply scotimeout x 1000 to restore old logic (1.66 KB, patch)
2025-06-17 22:38 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 40158: Multiply scotimeout x 1000 to restore old logic (1.71 KB, patch)
2025-06-17 23:21 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review
Bug 40158: [alternate] Remove unnecessary timeout check on sco slip print (2.31 KB, patch)
2025-06-18 02:00 UTC, David Cook
Details | Diff | Splinter Review
Bug 40158: [alternate] Remove unnecessary timeout check on sco slip print (2.37 KB, patch)
2025-06-18 13:59 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 40158: [alternate] Remove unnecessary timeout check on sco slip print (2.42 KB, patch)
2025-06-18 19:47 UTC, Biblibre Sandboxes
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Gass (lukeg) 2025-06-17 22:05:18 UTC
To recreate:

1. Have SelfCheckReceiptPrompt on
2. GO to the self checkout module
3. Login and press 'Finish'
4. Click 'Print receipt and end session'
5. No print dialogue
Comment 1 Christopher Brannon 2025-06-17 22:08:40 UTC
I am suspect of the bug 36586 patch section that reads:

                         [% IF Koha.Preference('SelfCheckReceiptPrompt') %]
                             var confirmStart = Date.now();
                             confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function(result) {
-                                if ( result && (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {
+                                if ( result && (Date.now() - confirmStart) < [% Koha.Preference('SelfCheckTimeout') | html %] ) {
                                     var win = window.open("/cgi-bin/koha/sco/printslip.pl?print=qslip");
                                     location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
                                 } else {
                                     location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
                                 }
                             })
-                        sco_init();
                         [% ELSE %]
                             location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
                         [% END %]
Comment 2 Lucas Gass (lukeg) 2025-06-17 22:30:42 UTC
Christopher,

That looks like the right section:

Prior to Bug 36586 there was this in the Perl file: 

$selfchecktimeout = C4::Context->preference('SelfCheckTimeout') * 1000;

and then the following check with JS: 

if ( result && (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {

that line was replaced with:

if ( result && (Date.now() - confirmStart) < [% Koha.Preference('SelfCheckTimeout') | html %] ) {


So now this will not evaluate to true.
Comment 3 Lucas Gass (lukeg) 2025-06-17 22:38:16 UTC
Created attachment 183313 [details] [review]
Bug 40158: Multiply scotimeout x 1000 to restore old logic

1. Have SelfCheckReceiptPrompt on
2. Go to the self checkout module
3. Login and press 'Finish'
4. Click 'Print receipt and end session'
5. No print dialogue
6. APPLY PATCH
7. Try again, it should behave as excepeted
Comment 4 David Cook 2025-06-17 23:20:51 UTC
The patch looks like it does restore the old logic, but do we actually need the logic at all? 

I'll try with this patch and without that datetime handling at all.
Comment 5 Biblibre Sandboxes 2025-06-17 23:21:43 UTC
Created attachment 183314 [details] [review]
Bug 40158: Multiply scotimeout x 1000 to restore old logic

1. Have SelfCheckReceiptPrompt on
2. Go to the self checkout module
3. Login and press 'Finish'
4. Click 'Print receipt and end session'
5. No print dialogue
6. APPLY PATCH
7. Try again, it should behave as excepeted

Signed-off-by: Christopher <cbrannon@cdalibrary.org>
Comment 6 Christopher Brannon 2025-06-17 23:22:21 UTC
Works as described.  Thanks for fixing this so quickly!!!!!
Comment 7 David Cook 2025-06-18 02:00:49 UTC
Created attachment 183315 [details] [review]
Bug 40158: [alternate] Remove unnecessary timeout check on sco slip print

This change removes an unnecessary/buggy SelfCheckTimeout check when
using SelfCheckReceiptPrompt slip printing.

To test:
1. Have SelfCheckReceiptPrompt enabled
2. Go to the self checkout module
3. Login and press 'Finish'
4. Click 'Print receipt and end session'
5. The print screen isn't shown and the user is just logged out
6. APPLY PATCH and refresh the page
7. Login and press 'Finish' then click "Print receipt and end session"
8. You should now see a print screen

Notes: Set SelfCheckTimeout to a small value like 10 to see that
not choosing an option for the SelfCheckReceiptPrompt will mean you're
automatically logged out by the timer. If you do choose "Print receipt and end session",
the original window will redirect to the logout endpoint, but it won't completely load
until after the print screen is actioned - at least in Chrome.
Comment 8 David Cook 2025-06-18 02:01:52 UTC
Christopher and Lucas, could you try out my alternate patch?

If there is some quirk to it that I can't see, I'm happy to go with Lucas's patch. But overall I don't see a point in having the old logic there either.
Comment 9 David Cook 2025-06-18 02:04:19 UTC
(In reply to David Cook from comment #8)
> Christopher and Lucas, could you try out my alternate patch?
> 
> If there is some quirk to it that I can't see, I'm happy to go with Lucas's
> patch. But overall I don't see a point in having the old logic there either.

I've tested both and I think that they work the same? So I figure the less code the better?
Comment 10 Lucas Gass (lukeg) 2025-06-18 13:59:47 UTC
Created attachment 183332 [details] [review]
Bug 40158: [alternate] Remove unnecessary timeout check on sco slip print

This change removes an unnecessary/buggy SelfCheckTimeout check when
using SelfCheckReceiptPrompt slip printing.

To test:
1. Have SelfCheckReceiptPrompt enabled
2. Go to the self checkout module
3. Login and press 'Finish'
4. Click 'Print receipt and end session'
5. The print screen isn't shown and the user is just logged out
6. APPLY PATCH and refresh the page
7. Login and press 'Finish' then click "Print receipt and end session"
8. You should now see a print screen

Notes: Set SelfCheckTimeout to a small value like 10 to see that
not choosing an option for the SelfCheckReceiptPrompt will mean you're
automatically logged out by the timer. If you do choose "Print receipt and end session",
the original window will redirect to the logout endpoint, but it won't completely load
until after the print screen is actioned - at least in Chrome.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 11 Brendan Lawlor 2025-06-18 15:56:41 UTC
Bug 40108 has the same patch, except it also adds a semicolon to the end of the confirmModal function

*** This bug has been marked as a duplicate of bug 40108 ***
Comment 12 Biblibre Sandboxes 2025-06-18 19:47:07 UTC
Created attachment 183347 [details] [review]
Bug 40158: [alternate] Remove unnecessary timeout check on sco slip print

This change removes an unnecessary/buggy SelfCheckTimeout check when
using SelfCheckReceiptPrompt slip printing.

To test:
1. Have SelfCheckReceiptPrompt enabled
2. Go to the self checkout module
3. Login and press 'Finish'
4. Click 'Print receipt and end session'
5. The print screen isn't shown and the user is just logged out
6. APPLY PATCH and refresh the page
7. Login and press 'Finish' then click "Print receipt and end session"
8. You should now see a print screen

Notes: Set SelfCheckTimeout to a small value like 10 to see that
not choosing an option for the SelfCheckReceiptPrompt will mean you're
automatically logged out by the timer. If you do choose "Print receipt and end session",
the original window will redirect to the logout endpoint, but it won't completely load
until after the print screen is actioned - at least in Chrome.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Christopher <cbrannon@cdalibrary.org>
Comment 13 David Cook 2025-06-18 23:14:51 UTC
(In reply to Brendan Lawlor from comment #11)
> Bug 40108 has the same patch, except it also adds a semicolon to the end of
> the confirmModal function
> 
> *** This bug has been marked as a duplicate of bug 40108 ***

Nice one, Brendan!