Bugzilla – Attachment 181049 Details for
Bug 36135
Add tool to batch modify holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36135: Fix ability to send SQL results in batch modify holds tool
0001-Bug-36135-Fix-ability-to-send-SQL-results-in-batch-m.patch (text/plain), 5.96 KB, created by
Emmi Takkinen
on 2025-04-17 06:33:20 UTC
(
hide
)
Description:
Bug 36135: Fix ability to send SQL results in batch modify holds tool
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2025-04-17 06:33:20 UTC
Size:
5.96 KB
patch
obsolete
>From aad3b5a3fc73e041abeaf335bd201089279bfb67 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Thu, 17 Apr 2025 09:05:24 +0300 >Subject: [PATCH] Bug 36135: Fix ability to send SQL results in batch modify > holds tool > >Ability to send SQL results to batch holds tool was broken >due use of API to fetch holds. This patch fixes this. > >To test: >1. Create SQL report which contains column for reserve_id. >=> e.g "SELECT reserve_id FROM reserves limit 10". >2. Run report. >3. Over report select "Batch operations" should be displayed >and under that there should be option "Batch modify holds". >4. Click "Batch modify holds" option. >=> Confirm that holds displayed in "Batch mofidy holds" tool >are same as found with your report. > >Note that when SQL results are send to the tool, search form >is displayed for a second before API call is launched. This >is expected behaviour since we need to first navigate to the >search form so we can then trigger the forms submit event >automatically. > >Also tidy some code to make QA tool happy. > >Sponsored-by: Koha-Suomi Oy >--- > .../modules/reports/guided_reports_start.tt | 19 ++++++++----------- > .../en/modules/tools/batch_modify_holds.tt | 8 ++++++++ > tools/batch_modify_holds.pl | 7 ++++++- > 3 files changed, 22 insertions(+), 12 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index 9905099f8f..3ba46a40e9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -1070,17 +1070,14 @@ > > > </form> > >- <form method="get" action="/cgi-bin/koha/tools/batch_modify_holds.pl" id="batch_modify_holds"> >- <input type="hidden" name="op" value="list" /> >- [% FOREACH result IN results %] >- [% FOREACH cells IN result.cells %] >- [% place = loop.index %] >- [% IF header_row.$place.cell == 'reserve_id' || header_types.item(header_row.$place.cell) == 'reserve_id' %] >- [% SET batch_reserve_ids = 1 %] >- <input type="hidden" name="reserve_ids" value="[% cells.cell | html %]" /> >- [% END %] >- [% END %] >- [% END %] >+ <form method="post" action="/cgi-bin/koha/tools/batch_modify_holds.pl" id="batch_modify_holds" target="_blank"> >+ [% INCLUDE 'csrf-token.inc' %] >+ <input type="hidden" name="op" value="form" /> >+ <textarea style="display:none" name="reserve_ids_list" id="reserve_ids_list"> >+ [%# Preserve the whitespace of the following textarea in order to format the values correctly %] >+ [%- reserve_ids = PROCESS batch_list results=results batch_type='reserve_id' | trim | html %][% IF reserve_ids %][% SET batch_reserve_ids = 1 %][% reserve_ids | html %][% END -%] >+ </textarea >+ > > </form> > > [% BLOCK batch_list %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >index d1493f81a1..622dd1b84b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >@@ -195,6 +195,7 @@ > <script> > let hide_patron_name = [% IF Koha.Preference('HidePatronName') %]true[% ELSE %]false[% END %]; > let hold_ids = [% IF updated_holds %] [% updated_holds | $raw %] [% ELSE %] [] [% END %]; >+ let hold_ids_from_sql = [% IF reserve_ids_list %] [% reserve_ids_list | $raw %] [% ELSE %] [] [% END %]; > > $(document).ready(function() { > >@@ -260,6 +261,10 @@ > return false; > }); > >+ if(hold_ids_from_sql.length > 0){ >+ $('#modify_holds_form').trigger('submit'); >+ } >+ > $("#edit_search").on("click", function(e){ > e.preventDefault(); > $('#modify_holds_search').show(); >@@ -359,6 +364,9 @@ > searchpattern += holdnotes ? _("hold notes like ") + holdnotes : ""; > > return holdnotes ? {"-like": "%"+holdnotes+"%"} : ""; >+ }, >+ "me.hold_id": function(){ >+ return hold_ids_from_sql.length > 0 ? { "-in": hold_ids_from_sql } : ""; > } > } > >diff --git a/tools/batch_modify_holds.pl b/tools/batch_modify_holds.pl >index a5a95948e5..58b1f45efc 100755 >--- a/tools/batch_modify_holds.pl >+++ b/tools/batch_modify_holds.pl >@@ -23,7 +23,7 @@ use CGI; > > use JSON qw( to_json ); > >-use C4::Auth qw( get_template_and_user ); >+use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > > use Koha::DateUtils qw( dt_from_string ); >@@ -44,6 +44,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > my @hold_ids; > > if ( $op eq 'form' ) { >+ my $reserve_ids_list = $input->param('reserve_ids_list') || undef; >+ if ($reserve_ids_list) { >+ my @reserve_ids = split /\n/, $reserve_ids_list; >+ $template->param( reserve_ids_list => to_json( \@reserve_ids ), ); >+ } > $template->param( view => 'form', ); > } elsif ( $op eq 'cud-modify' ) { > my $new_expiration_date = $input->param('new_expiration_date'); >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36135
:
163021
|
163022
|
163023
|
163024
|
163529
|
163530
|
163540
|
163541
|
163542
|
163543
|
163544
|
163796
|
164037
|
164051
|
164057
|
164058
|
164059
|
164060
|
164061
|
164062
|
164063
|
177518
|
177519
|
177959
|
177960
|
177961
|
177962
|
177963
|
177964
|
177965
|
177966
|
177967
|
177968
|
177969
|
177975
|
177976
|
177981
|
177982
|
178154
|
178155
|
178156
|
178157
|
178158
|
178159
|
178160
|
178161
|
178162
|
178163
|
178164
|
178165
|
178166
|
178167
|
178954
|
179028
|
179029
|
179030
|
179031
|
179032
|
179033
|
179034
|
179035
|
179036
|
179037
|
179038
|
179039
|
179040
|
179041
|
179042
|
179081
|
179082
| 181049