Bug 36475

Summary: "Print summary" tables cannot be column configured
Product: Koha Reporter: Lucas Gass (lukeg) <lucas>
Component: CirculationAssignee: Owen Leonard <oleonard>
Status: Pushed to oldstable --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: gmcharlt, kyle.m.hall, lchirlias, martin.renvoize, thibaud.guillot
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.04
Circulation function:
Attachments: Bug 36475: Enable table configurations on patrons print summary
Bug 36475: Enable table configurations on patrons print summary
Bug 36475: Enable table configurations on patrons print summary

Description Lucas Gass (lukeg) 2024-04-01 15:43:06 UTC
To recreate:

1. Have a patron with some checkouts and some holds. 
2. Go to Table settings > Circulation > print_summary and mark some of the columns as hidden.
3. Go to the patron account and click Print > Print summary
4. The hidden columns still appear.
Comment 1 Katrin Fischer 2024-04-01 15:53:29 UTC
I recently ran into this in 22.11 as well, but thought it was me :)
Comment 2 Owen Leonard 2024-04-02 16:14:03 UTC
I can reproduce this in master. Note that if you have anything in IntranetSlipPrinterJS or the default print-then-close JS isn't executed.

The problem is that "window.print()" fires before DataTables has a chance to load and format the table.
Comment 3 Katrin Fischer 2024-04-02 21:02:46 UTC
(In reply to Owen Leonard from comment #2)
> I can reproduce this in master. Note that if you have anything in
> IntranetSlipPrinterJS or the default print-then-close JS isn't executed.
> 
> The problem is that "window.print()" fires before DataTables has a chance to
> load and format the table.

Excellent detective work!
Comment 4 Owen Leonard 2024-06-18 17:03:17 UTC
Created attachment 167859 [details] [review]
Bug 36475: Enable table configurations on patrons print summary

This patch fixes table configuration to the tables shown on the
patron's print summary page, adding default display length and default
sort as well.

I removed the JS for moving around the DataTable controls to make them
display better and instead swapped the <caption>s for <h2>. It's not
perfect but it's better than it was.

Previously table configuration wasn't working because the window.print()
function was firing before the DataTables code had time to run. I've
added a use of onbeforeprint event to make sure we run the DataTables
initiation before automatic printing.

To test, apply the patch and restart services.

- In the staff client, go to Administration -> Table settings ->
  Circulation -> print_summary.
  - Configure the print-summary-checkouts, print-summary-fines, and
    print-summary-holds tables with some custom options (e.g. hide
    columns, change default sort).
- In the staff client, find a patron with checkouts, holds, and fines.
- In the toolbar, click Print -> Print summary. A new tab should appear
  with the print summary view. A print dialog should appear immediately.
- In the print preview you should see that the tables you configured are
  displayed correctly (sort is correct, columns correctly hidden, etc).
- If you print the page or cancel the tab should close.

- If you want to test the table configurations without having the tab
  automatically close you can go to Administration -> System preferences
  -> IntranetSlipPrinterJS and enter any dummy code, e.g.
  "console.log('Testing');" With that preference populated, the
  automatic closing isn't included.

- Test other pages which use the slip-print include, e.g. other patron
  print options and quick spine labels in Cataloging.

Sponsored-By: Athens County Public Libraries
Comment 5 Lucas 2024-06-19 13:24:14 UTC
> If you want to test the table configurations without having the tab
>  automatically close you can go to Administration -> System preferences
>  -> IntranetSlipPrinterJS and enter any dummy code, e.g.
>  "console.log('Testing');" With that preference populated, the
>  automatic closing isn't included.

I don't know if i really need to test this. But the septs before works

> - Test other pages which use the slip-print include, e.g. other patron
  print options and quick spine labels in Cataloging.

I didn' had the time to test that
Comment 6 Thibaud Guillot (thibaud_g) 2024-08-09 13:58:53 UTC
Created attachment 170196 [details] [review]
Bug 36475: Enable table configurations on patrons print summary

This patch fixes table configuration to the tables shown on the
patron's print summary page, adding default display length and default
sort as well.

I removed the JS for moving around the DataTable controls to make them
display better and instead swapped the <caption>s for <h2>. It's not
perfect but it's better than it was.

Previously table configuration wasn't working because the window.print()
function was firing before the DataTables code had time to run. I've
added a use of onbeforeprint event to make sure we run the DataTables
initiation before automatic printing.

To test, apply the patch and restart services.

- In the staff client, go to Administration -> Table settings ->
  Circulation -> print_summary.
  - Configure the print-summary-checkouts, print-summary-fines, and
    print-summary-holds tables with some custom options (e.g. hide
    columns, change default sort).
- In the staff client, find a patron with checkouts, holds, and fines.
- In the toolbar, click Print -> Print summary. A new tab should appear
  with the print summary view. A print dialog should appear immediately.
- In the print preview you should see that the tables you configured are
  displayed correctly (sort is correct, columns correctly hidden, etc).
- If you print the page or cancel the tab should close.

- If you want to test the table configurations without having the tab
  automatically close you can go to Administration -> System preferences
  -> IntranetSlipPrinterJS and enter any dummy code, e.g.
  "console.log('Testing');" With that preference populated, the
  automatic closing isn't included.

- Test other pages which use the slip-print include, e.g. other patron
  print options and quick spine labels in Cataloging.

Sponsored-By: Athens County Public Libraries
Signed-off-by: Thibaud Guillot <thibaud.guillot@biblibre.com>
Comment 7 Thibaud Guillot (thibaud_g) 2024-08-09 14:00:10 UTC
*** Bug 36974 has been marked as a duplicate of this bug. ***
Comment 8 Martin Renvoize (ashimema) 2024-08-21 08:36:17 UTC
Created attachment 170535 [details] [review]
Bug 36475: Enable table configurations on patrons print summary

This patch fixes table configuration to the tables shown on the
patron's print summary page, adding default display length and default
sort as well.

I removed the JS for moving around the DataTable controls to make them
display better and instead swapped the <caption>s for <h2>. It's not
perfect but it's better than it was.

Previously table configuration wasn't working because the window.print()
function was firing before the DataTables code had time to run. I've
added a use of onbeforeprint event to make sure we run the DataTables
initiation before automatic printing.

To test, apply the patch and restart services.

- In the staff client, go to Administration -> Table settings ->
  Circulation -> print_summary.
  - Configure the print-summary-checkouts, print-summary-fines, and
    print-summary-holds tables with some custom options (e.g. hide
    columns, change default sort).
- In the staff client, find a patron with checkouts, holds, and fines.
- In the toolbar, click Print -> Print summary. A new tab should appear
  with the print summary view. A print dialog should appear immediately.
- In the print preview you should see that the tables you configured are
  displayed correctly (sort is correct, columns correctly hidden, etc).
- If you print the page or cancel the tab should close.

- If you want to test the table configurations without having the tab
  automatically close you can go to Administration -> System preferences
  -> IntranetSlipPrinterJS and enter any dummy code, e.g.
  "console.log('Testing');" With that preference populated, the
  automatic closing isn't included.

- Test other pages which use the slip-print include, e.g. other patron
  print options and quick spine labels in Cataloging.

Sponsored-By: Athens County Public Libraries
Signed-off-by: Thibaud Guillot <thibaud.guillot@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize (ashimema) 2024-08-21 08:36:38 UTC
Thanks for the fix, working well.

Passing QA
Comment 10 Katrin Fischer 2024-08-21 17:15:17 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 11 Lucas Gass (lukeg) 2024-09-12 22:22:58 UTC
Backported to 24.05.x for upcoming 24.05.04