From 5c8ab275027f85f0c082e88c5ae5af4ccf89275a Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 3 Jul 2025 17:03:17 +0000 Subject: [PATCH] Bug 36135: Make modified_holds table not use the API --- .../en/modules/tools/batch_modify_holds.tt | 177 +++++------------- tools/batch_modify_holds.pl | 8 +- 2 files changed, 57 insertions(+), 128 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 1b3c2ca8f7d..4850a8a01a3 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,7 +103,53 @@ [% 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 %]
@@ -582,131 +628,10 @@ //Modified holds table var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %]; - 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); + $("#modified_holds").kohaTable({ + pagingType: "full", + autoWidth: false + }, table_settings); }); diff --git a/tools/batch_modify_holds.pl b/tools/batch_modify_holds.pl index c73b1f332e8..ea0ab14f091 100755 --- a/tools/batch_modify_holds.pl +++ b/tools/batch_modify_holds.pl @@ -59,6 +59,7 @@ 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" ] } ); @@ -95,11 +96,14 @@ 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 ), - view => 'report', + updated_holds => to_json( \@hold_ids ), + updated_holds_obj => \@holds_data, + total_updated => scalar @holds_data, + view => 'report', ); } -- 2.39.5