Bug 40108 - Self-checkout print receipt option not working
Summary: Self-checkout print receipt option not working
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Self checkout (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Owen Leonard
QA Contact: Brendan Lawlor
URL:
Keywords: release-notes-needed
: 40102 40158 (view as bug list)
Depends on: 36586
Blocks:
  Show dependency treegraph
 
Reported: 2025-06-10 11:47 UTC by Owen Leonard
Modified: 2025-07-25 13:02 UTC (History)
6 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:
25.11.00,25.05.01,24.11.08
Circulation function:


Attachments
Bug 40108: Fix print receipt option in self-checkout (3.28 KB, patch)
2025-06-10 12:44 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 40108: Fix print receipt option in self-checkout (3.28 KB, patch)
2025-06-10 12:53 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 40108: Fix print receipt option in self-checkout (3.33 KB, patch)
2025-06-10 15:52 UTC, David Flater
Details | Diff | Splinter Review
Bug 40108: Fix print receipt option in self-checkout (3.38 KB, patch)
2025-06-18 16:31 UTC, Brendan Lawlor
Details | Diff | Splinter Review
Bug 40108: [24.11.x] Fix print receipt option in self-checkout (3.16 KB, patch)
2025-07-11 16:44 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 40108: [24.11.x] Fix print receipt option in self-checkout (3.20 KB, patch)
2025-07-22 18:17 UTC, David Flater
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2025-06-10 11:47:05 UTC
In self-checkout, if I try to end my session by clicking the "Finish" button I get the "Would you like to print a receipt?" prompt but clicking the "Print receipt and end session" button doesn't trigger a new page with the receipt.
Comment 1 Owen Leonard 2025-06-10 12:44:40 UTC Comment hidden (obsolete)
Comment 2 Owen Leonard 2025-06-10 12:53:00 UTC Comment hidden (obsolete)
Comment 3 David Flater 2025-06-10 15:52:20 UTC Comment hidden (obsolete)
Comment 4 Owen Leonard 2025-06-10 16:01:09 UTC
*** Bug 40102 has been marked as a duplicate of this bug. ***
Comment 5 Brendan Lawlor 2025-06-18 15:56:41 UTC
*** Bug 40158 has been marked as a duplicate of this bug. ***
Comment 6 Brendan Lawlor 2025-06-18 16:31:27 UTC
Created attachment 183342 [details] [review]
Bug 40108: Fix print receipt option in self-checkout

The self-checkout logout process, with SelfCheckReceiptPrompt enabled,
asks the user if they want to print a receipt. Because of an error in
time calculation the system always believed the process had timed out
and wouldn't print the receipt.

Before we implemented a modal dialog to ask for confirmation upon
self-checkout logout, it was necessary to have a timeout function built
into the process. See Bug 11498.

The modal no longer blocks the page timeout function, so this time
calculation is obsolete and can be removed.

To test, apply the patch and go to the self-checkout module.

- Make sure the SelfCheckReceiptPrompt system preference is enabled.
- Log in as a user for doing self-checkout.
- Click the "Finish" button.
  - You should see a dialog, "Would you like to print a receipt?"
  - Clicking "Print receipt..." should open a new window with your
    receipt and log you out of the self-checkout system.
  - Clicking "End session" should end your session without triggering a
    popup.
- Set the SelfCheckTimeout system preference to something very low, like
  10 seconds.
  - Perform the same test as above, but after triggering the dialog wait
    10 seconds for the timeout to trigger.
  - The page should reload automatically and log you out.
- Disable the SelfCheckReceiptPrompt system preference.
  - Perform the same tests to confirm that clicking the "Finish" button
    logs you out immediately without offering to print a slip.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Flater <flaterdavid@gmail.com>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 7 Brendan Lawlor 2025-06-18 16:34:56 UTC
This patch works as described and removing the obsolete code makes sense. Nice work. Thanks for the detailed test plan. Passing QA.
Comment 8 Brendan Lawlor 2025-06-18 17:52:40 UTC
In the meantime until this gets backported, assuming you have SelfCheckReceiptPrompt enabled you can add this js snippet to SCOUserJS to override the finish button's click handler:

$(document).ready(function() {
  $("#logout_form").off("click");
  $("#logout_form").on("click", function(e){
    e.preventDefault(e);
    confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function(result) {
      if ( result ) {
        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';
        }
    });

    return true;
  });
});
Comment 9 David Cook 2025-06-18 23:17:15 UTC
Extra +1 from me. I ended up writing the same patch as Owen a week later 😅.

Guess the title of bug 40158 was just different enough not to show as a duplicate at report time I imagine.
Comment 10 Lucas Gass (lukeg) 2025-06-23 15:53:27 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 11 Paul Derscheid 2025-06-24 09:31:25 UTC
Nice work everyone!

Pushed to 25.05.x for 25.05.03
Comment 12 Christopher Brannon 2025-07-11 16:04:08 UTC
Can this be backported to 24.11?
Comment 13 Owen Leonard 2025-07-11 16:44:41 UTC
Created attachment 184017 [details] [review]
Bug 40108: [24.11.x] Fix print receipt option in self-checkout

The self-checkout logout process, with SelfCheckReceiptPrompt enabled,
asks the user if they want to print a receipt. Because of an error in
time calculation the system always believed the process had timed out
and wouldn't print the receipt.

Before we implemented a modal dialog to ask for confirmation upon
self-checkout logout, it was necessary to have a timeout function built
into the process. See Bug 11498.

The modal no longer blocks the page timeout function, so this time
calculation is obsolete and can be removed.

To test, apply the patch and go to the self-checkout module.

- Make sure the SelfCheckReceiptPrompt system preference is enabled.
- Log in as a user for doing self-checkout.
- Click the "Finish" button.
  - You should see a dialog, "Would you like to print a receipt?"
  - Clicking "Print receipt..." should open a new window with your
    receipt and log you out of the self-checkout system.
  - Clicking "End session" should end your session without triggering a
    popup.
- Set the SelfCheckTimeout system preference to something very low, like
  10 seconds.
  - Perform the same test as above, but after triggering the dialog wait
    10 seconds for the timeout to trigger.
  - The page should reload automatically and log you out.
- Disable the SelfCheckReceiptPrompt system preference.
  - Perform the same tests to confirm that clicking the "Finish" button
    logs you out immediately without offering to print a slip.

Sponsored-by: Athens County Public Libraries
Comment 14 David Cook 2025-07-14 01:13:32 UTC
Bug 36586 is getting reverted so might be necessary to revert this too
Comment 15 Lucas Gass (lukeg) 2025-07-21 17:04:30 UTC
(In reply to David Cook from comment #14)
> Bug 36586 is getting reverted so might be necessary to revert this too

This fix still makes sense to me without Bug 36586. In main I left this fix as is after reverting Bug 36586.
Comment 16 David Flater 2025-07-22 18:17:33 UTC
Created attachment 184498 [details] [review]
Bug 40108: [24.11.x] Fix print receipt option in self-checkout

The self-checkout logout process, with SelfCheckReceiptPrompt enabled,
asks the user if they want to print a receipt. Because of an error in
time calculation the system always believed the process had timed out
and wouldn't print the receipt.

Before we implemented a modal dialog to ask for confirmation upon
self-checkout logout, it was necessary to have a timeout function built
into the process. See Bug 11498.

The modal no longer blocks the page timeout function, so this time
calculation is obsolete and can be removed.

To test, apply the patch and go to the self-checkout module.

- Make sure the SelfCheckReceiptPrompt system preference is enabled.
- Log in as a user for doing self-checkout.
- Click the "Finish" button.
  - You should see a dialog, "Would you like to print a receipt?"
  - Clicking "Print receipt..." should open a new window with your
    receipt and log you out of the self-checkout system.
  - Clicking "End session" should end your session without triggering a
    popup.
- Set the SelfCheckTimeout system preference to something very low, like
  10 seconds.
  - Perform the same test as above, but after triggering the dialog wait
    10 seconds for the timeout to trigger.
  - The page should reload automatically and log you out.
- Disable the SelfCheckReceiptPrompt system preference.
  - Perform the same tests to confirm that clicking the "Finish" button
    logs you out immediately without offering to print a slip.

Sponsored-by: Athens County Public Libraries
Signed-off-by: David Flater <flaterdavid@gmail.com>
Comment 17 David Flater 2025-07-22 18:18:15 UTC
Might not need a sign-off, but I did test this on 24.11.x and it both maintains all functionality and passes QA.
Comment 18 Fridolin Somers 2025-07-25 13:02:04 UTC
(In reply to David Flater from comment #17)
> Might not need a sign-off, but I did test this on 24.11.x and it both
> maintains all functionality and passes QA.

Thanks a lot for this dedicated patch
Comment 19 Fridolin Somers 2025-07-25 13:02:23 UTC
Pushed to 24.11.x for 24.11.08