From 0b730bb14cc6e0c79904a7da138a1bb741f90c4e Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Thu, 25 Sep 2025 15:54:28 +0200 Subject: [PATCH] Revert "Bug 36135: Make modified_holds table not use the API" This reverts commit cf14a4a7e8be22fe68d34071b449ada4490afc36. Signed-off-by: Paul Derscheid --- .../en/modules/tools/batch_modify_holds.tt | 177 +++++++++++++----- tools/batch_modify_holds.pl | 8 +- 2 files changed, 128 insertions(+), 57 deletions(-) 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 4850a8a01a..1b3c2ca8f7 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 @@ -103,53 +103,7 @@ [% ELSIF view == "report" %]
- - - - - - - - - - - - - - - - - [% FOREACH hold IN updated_holds_obj %] - - - - - - - - - - - - [% END %] - -
TitlePatronPickup LocationPriorityExpiration DateStatusSuspendedSuspended UntilNotes
[% hold.biblio.title | html %][% hold.borrower.firstname | html %] [% hold.borrower.surname | html %][% hold.branch.branchname | html %][% hold.priority | html %][% hold.expirationdate | $KohaDates %] - [% IF hold.found == 'F' %] - Fulfilled - [% ELSIF hold.cancellationdate %] - Cancelled - [% ELSIF hold.found == 'W' %] - [% IF hold.cancellation_requests.count == 0 %] - Waiting - [% ELSE %] - Cancelled - [% END %] - [% ELSIF hold.found == 'T' %] - In transit - [% ELSE %] - Pending - [% END %] - [% IF hold.suspend %]Yes[% ELSE %]No[% END %][% IF hold.suspend_until %][% hold.suspend_until | $KohaDates %][% ELSE %]-[% END %][% hold.reservenotes | html %]
+
@@ -628,10 +582,131 @@ //Modified holds table var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %]; - $("#modified_holds").kohaTable({ - pagingType: "full", - autoWidth: false - }, table_settings); + var filters = { + "me.hold_id": function(){ + return {"-in": hold_ids}; + } + } + + var holds_modified_table = $("#modified_holds").kohaTable({ + "ajax": { + "url": "/api/v1/holds" + }, + "embed": [ + "biblio", + "item", + "pickup_library", + "patron" + ], + "destroy": true, + "autoWidth": false, + "processing": true, + "columns": [ + { + "data": "expiration_date", + "name": "expiration_date", + "type": "date", + "title": _("Expiration date"), + "orderable": true, + "render": function( data, type, row, meta ) { + return $date(data); + } + }, + { + "data": "biblio.title", + "name": "title", + "title": _("Title"), + "orderable": true, + "render": function( data, type, row, meta ) { + return '' + escape_str( data ) + ''; + } + }, + { + "data": "item.external_id", + "name": "barcode", + "title": _("Barcode"), + "defaultContent": _(""), + "orderable": true, + "render": function( data, type, row, meta ) { + if( row.item ){ + let item_id = encodeURIComponent( row.item_id ); + let biblio_id = encodeURIComponent( row.biblio_id ); + return '' + escape_str( data ) + '' + } + } + }, + { + "data": "patron_id", + "name": "patron", + "title": _("Patron"), + "orderable": true, + "render": function( data, type, row, meta ) { + let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name }); + return patron_to_html; + } + }, + { + "data": "status", + "name": "status", + "className": "found_status", + "title": _("Status"), + "orderable": true, + "render": function( data, type, row, meta ) { + let status = _("No status"); + if ( data == "T" ) { + status = _("In transit"); + } else if( data == "P" ) { + status = _("In processing"); + } else if( data == "W" ) { + status = _("Waiting"); + } + return status; + } + }, + { + "data": "pickup_library_id", + "name": "pickup_library", + "title": _("Hold pickup library"), + "orderable": true, + "render": function( data, type, row, meta ) { + return escape_str( row.pickup_library.name ); + } + }, + { + "data": "suspended", + "name": "suspended", + "title": _("Suspended"), + "orderable": true, + "render": function( data, type, row, meta ) { + return data == 0 ? _("No") : _("Yes"); + } + }, + { + "data": "suspended_until", + "name": "suspended_until", + "title": _("Suspended until"), + "orderable": true, + "render": function( data, type, row, meta ) { + return $date( data ); + } + }, + { + "data": "notes", + "name": "notes", + "title": _("Notes"), + "orderable": true, + "render": function( data, type, row, meta ) { + return escape_str( data ); + } + } + ] + }, table_settings, 0, filters); + + var modified_message = '
'+hold_ids.length+' hold(s) have been modified!
'; + $("#modified_holds_results-wrapper").prepend(modified_message); }); diff --git a/tools/batch_modify_holds.pl b/tools/batch_modify_holds.pl index ea0ab14f09..c73b1f332e 100755 --- a/tools/batch_modify_holds.pl +++ b/tools/batch_modify_holds.pl @@ -59,7 +59,6 @@ if ( $op eq 'cud-form' ) { my $clear_hold_notes = $input->param('clear_hold_notes'); @hold_ids = $input->multi_param('hold_id'); - my @holds_data = (); my $holds_to_update = Koha::Holds->search( { reserve_id => { -in => \@hold_ids } }, { join => [ "item", "biblio" ] } ); @@ -96,14 +95,11 @@ if ( $op eq 'cud-form' ) { if ($clear_hold_notes) { $hold->reservenotes(undef)->store; } - push @holds_data, $hold; } $template->param( - updated_holds => to_json( \@hold_ids ), - updated_holds_obj => \@holds_data, - total_updated => scalar @holds_data, - view => 'report', + updated_holds => to_json( \@hold_ids ), + view => 'report', ); }