Bug 37205

Summary: Printing patron cards causes error
Product: Koha Reporter: Eric Garcia <cubingguy714>
Component: ToolsAssignee: Sam Lau <samalau>
Status: RESOLVED WORKSFORME QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: lucas, samalau
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:
Circulation function:
Attachments: Bug 37205: Fix printing patron cards from the patron lists page
Bug 37205: Fix printing patron cards from the patron lists page

Description Eric Garcia 2024-06-26 18:38:23 UTC
To recreate:

1. Go to Tools -> Patron lists
2. Create a new patron list
3. Populate with patrons
4. Go back to Tools -> Patron lists
5. Find your list, click on 'Action' and select 'Print patron cards'
6. Use browser dev tools to see error

jquery-3.6.0.min_24.0600008.js:2 
       
GET http://localhost:8081/cgi-bin/koha/patroncards/print.pl?csrf_token=1222474d665d5fe8bc17f7ff3c321feb404279c1%2C6447ff3c0650e78a6529508001b489d1ad3df6ac%2C1719427013&op=cud-export&referer=%2Fcgi-bin%2Fkoha%2Fpatron_lists%2Flists.pl&patronlist_id=1&template_id=23&layout_id=20&layout_back_id=0&start_card=1 403 (Forbidden)
Comment 1 Sam Lau 2024-06-26 22:43:16 UTC
Created attachment 168184 [details] [review]
Bug 37205: Fix printing patron cards from the patron lists page

This patch allows for the printing of patron cards from the patron lists page. Previously when attempting to do this, some errors show up, saying : "Programming error - op 'cud-export' must not start with 'cud-' for GET ...". To fix this issue, rather than send this info as a GET request, we can send it as a POST request to print.pl and extract the correct html code.

To test:
1) Go to Tools -> Patron lists
2) Create a new patron list
3) Populate with patrons
4) Go back to Tools -> Patron lists
5) Find your list, click on 'Action' and select 'Print patron cards', then select "Export"
6) Notice infinite load as well as error in dev tools
7) Apply patch
8) Go back to your patron list and attempt to print patron cards again.
9) When you select "Export" this time, it should load properly giving you a pdf of the patron cards like requested.
Comment 2 Eric Garcia 2024-06-27 19:43:02 UTC
Created attachment 168215 [details] [review]
Bug 37205: Fix printing patron cards from the patron lists page

This patch allows for the printing of patron cards from the patron lists page. Previously when attempting to do this, some errors show up, saying : "Programming error - op 'cud-export' must not start with 'cud-' for GET ...". To fix this issue, rather than send this info as a GET request, we can send it as a POST request to print.pl and extract the correct html code.

To test:
1) Go to Tools -> Patron lists
2) Create a new patron list
3) Populate with patrons
4) Go back to Tools -> Patron lists
5) Find your list, click on 'Action' and select 'Print patron cards', then select "Export"
6) Notice infinite load as well as error in dev tools
7) Apply patch
8) Go back to your patron list and attempt to print patron cards again.
9) When you select "Export" this time, it should load properly giving you a pdf of the patron cards like requested.

Signed-off-by: Eric Garcia <cubingguy714@gmail.com>
Comment 3 Lucas Gass (lukeg) 2024-09-24 16:16:20 UTC
Doesn't apply cleanly anymore, likely because of Bootstrap5 changes.
Comment 4 Lucas Gass (lukeg) 2024-09-26 17:26:08 UTC
This now works for me without the patch.