From 2cc7450a1b7c65e0d0822b761187136da53b09f5 Mon Sep 17 00:00:00 2001 From: Emmi Takkinen Date: Wed, 22 Jan 2025 13:50:26 +0200 Subject: [PATCH 13/14] Bug 36135: Use API and datatables to display holds to modify --- admin/columns_settings.yml | 47 +- .../en/modules/tools/batch_modify_holds.tt | 648 +++++++++++++----- tools/batch_modify_holds.pl | 103 +-- 3 files changed, 514 insertions(+), 284 deletions(-) diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 2a632acc25..4a9bcbc70a 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -1955,7 +1955,52 @@ modules: columnname: suspend - columnname: print_slip - + holds_to_modify: + default_display_length: 20 + columns: + - + columnname: checkbox + cannot_be_toggled: 1 + cannot_be_modified: 1 + - + columnname: expiration_date + - + columnname: title + - + columnname: barcode + - + columnname: patron + - + columnname: status + - + columnname: pickup_library + - + columnname: suspended + - + columnname: suspended_until + - + columnname: notes + modified_holds: + default_display_length: 20 + columns: + - + columnname: expiration_date + - + columnname: title + - + columnname: barcode + - + columnname: patron + - + columnname: status + - + columnname: pickup_library + - + columnname: suspended + - + columnname: suspended_until + - + columnname: notes holdsratios: holds-ratios: default_display_length: 20 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 166bdd04bc..c92914f9cb 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 @@ -5,6 +5,8 @@ [% USE Categories %] [% USE KohaDates %] [% USE ItemTypes %] +[% USE TablesSettings %] +[% USE To %] [% PROCESS 'html_helpers.inc' %] [% INCLUDE 'doc-head-open.inc' %] @@ -35,22 +37,20 @@ [% END #/ WRAPPER breadcrumbs %] [% END #/ WRAPPER sub-header.inc %] -
-
-
-
- -

Batch modify holds

- - [% IF view == 'form' %] +
+
+
+
+

Batch modify holds

+ [% IF view == "form" %] + + [% ELSIF view == "report" %] + + [% END %] +
-
- - -
- -
-
+ +
+
+ + + Cancel +
+ +
+ +
+
+ +
[% MACRO jsinclude BLOCK %] [% Asset.js("js/tools-menu.js") | $raw %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'js-patron-format.inc' %] [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] [% END %] diff --git a/tools/batch_modify_holds.pl b/tools/batch_modify_holds.pl index 8d3f29a59a..3c057e5559 100755 --- a/tools/batch_modify_holds.pl +++ b/tools/batch_modify_holds.pl @@ -19,10 +19,11 @@ # use Modern::Perl; - use CGI; -use C4::Auth qw( get_template_and_user ); +use JSON qw( to_json ); + +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,98 +45,12 @@ my @hold_ids; if ( $op eq 'form' ) { $template->param( view => 'form', ); -} elsif ( $op eq 'list' ) { - - my @reserve_ids = $input->multi_param('reserve_ids'); - my $expirationdate_from = $input->param('expirationdate_from'); - my $expirationdate_to = $input->param('expirationdate_to'); - my @branchcodes = $input->multi_param('branchcodes'); - my @found_status = $input->multi_param('found_status'); - my $suspend_status = $input->param('suspend_status'); - my $suspend_until_from = $input->param('suspend_until_from'); - my $suspend_until_to = $input->param('suspend_until_to'); - my $reservenotes = $input->param('reservenotes'); - - my $search_params; - - if (@reserve_ids) { - $search_params->{'me.reserve_id'} = { -in => \@reserve_ids }; - } else { - if ( $expirationdate_from && $expirationdate_to ) { - my $expirationdate_params = { - -or => { - patron_expiration_date => { - -between => [ - $expirationdate_from, - $expirationdate_to - ] - }, - expirationdate => { - -between => [ - $expirationdate_from, - $expirationdate_to - ] - } - } - }; - - $search_params = $expirationdate_params; - } - - if (@branchcodes) { - $search_params->{'me.branchcode'} = { -in => \@branchcodes }; - } - - if (@found_status) { - my $found_params = {}; - - # if NULL is used as filter, use it as "is" param - if ( grep { $_ eq "NULL" } @found_status ) { - $found_params->{'-or'}{'-is'} = undef; - $found_params->{'-or'}{'-in'} = \@found_status; - } else { - $found_params = { -in => \@found_status }; - } - - $search_params->{'me.found'} = $found_params; - } - - if ( $suspend_status ne "none" ) { - $search_params->{'me.suspend'} = $suspend_status; - } - - if ( $suspend_until_from && $suspend_until_to ) { - $search_params->{'me.suspend_until'} = { - -between => [ - $suspend_until_from, - $suspend_until_to, - ] - }; - } - - if ($reservenotes) { - $search_params->{'me.reservenotes'} = { -like => "%" . $reservenotes . "%" }; - } - } - - my $holds = Koha::Holds->search( - $search_params, - { join => [ "item", "biblio" ] } - ); - - $template->param( - holds => $holds, - view => 'list', - ); -} - -if ( $op eq 'cud-modify' ) { - +} elsif ( $op eq 'cud-modify' ) { my $new_expiration_date = $input->param('new_expiration_date'); my $new_pickup_loc = $input->param('new_pickup_loc'); my $new_suspend_status = $input->param('new_suspend_status'); my $new_suspend_date = $input->param('new_suspend_date'); - my $new_reserve_note = $input->param('new_reserve_note'); + my $new_hold_note = $input->param('new_hold_note'); @hold_ids = $input->multi_param('hold_id'); @@ -153,7 +68,7 @@ if ( $op eq 'cud-modify' ) { } if ( $new_suspend_status && !$hold->is_found ) { - if ( $new_suspend_status eq "suspend" ) { + if ($new_suspend_status) { $hold->suspend(1)->store; if ($new_suspend_date) { $hold->suspend_until($new_suspend_date)->store; @@ -166,13 +81,13 @@ if ( $op eq 'cud-modify' ) { } } - if ($new_reserve_note) { - $hold->reservenotes($new_reserve_note)->store; + if ($new_hold_note) { + $hold->reservenotes($new_hold_note)->store; } } $template->param( - updated_holds => $holds_to_update, + updated_holds => to_json( \@hold_ids ), view => 'report', ); -- 2.34.1