Bugzilla – Attachment 183298 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: (follow-up) Fix link style on guided report page
Bug-36135-follow-up-Fix-link-style-on-guided-repor.patch (text/plain), 52.52 KB, created by
Lucas Gass (lukeg)
on 2025-06-16 22:09:52 UTC
(
hide
)
Description:
Bug 36135: (follow-up) Fix link style on guided report page
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-06-16 22:09:52 UTC
Size:
52.52 KB
patch
obsolete
>From 9d5cf0a66764324e190b04e74b9f49a7bbad2e17 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Fri, 7 Mar 2025 14:49:36 +0000 >Subject: [PATCH] Bug 36135: (follow-up) Fix link style on guided report page > >Sponsored-by: Koha-Suomi Oy >--- > .../modules/reports/guided_reports_start.tt | 21 +- > .../en/modules/tools/batch_modify_holds.tt | 780 +++++++++--------- > tools/batch_modify_holds.pl | 30 +- > 3 files changed, 436 insertions(+), 395 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 406834a8463..76221287328 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 >@@ -1071,17 +1071,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="cud-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 %] >@@ -1227,7 +1224,7 @@ > data-toggle="tooltip" > data-placement="right" > title="Send visible results to batch hold modification" >- class="batch_op send_to_hold_mod" >+ class="batch_op send_to_hold_mod dropdown-item" > >Batch hold modification</a > > > </li> >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 d1493f81a10..b0fe375af1b 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 >@@ -42,7 +42,7 @@ > <div class="col-sm-10 col-sm-push-2 order-sm-1"> > <main> > <h1>Batch modify holds</h1> >- [% IF view == "form" %] >+ [% IF view == "cud-form" %] > <div id="modify_holds_search"> > <form method="get" action="/cgi-bin/koha/tools/batch_modify_holds.pl" id="modify_holds_form"> > <fieldset class="rows"> >@@ -50,11 +50,11 @@ > <ol> > <li> > <label for="expirationdate_from">Expiration date from:</label> >- <input type="text" size="10" id="expirationdate_from" name="expirationdate_from" class="flatpickr" data-date_to="expirationdate_to" /> >+ <input type="text" size="10" id="expirationdate_from" name="expirationdate_from" class="flatpickr" /> > </li> > <li> > <label for="expirationdate_to">Expiration date to:</label> >- <input type="text" size="10" id="expirationdate_to" name="expirationdate_to" class="flatpickr"/> >+ <input type="text" size="10" id="expirationdate_to" name="expirationdate_to" class="flatpickr" /> > </li> > <li> > <label for="branchcodes">Libraries:</label> >@@ -85,33 +85,38 @@ > </li> > <li> > <label for="suspend_until_to">Suspended until to:</label> >- <input type="text" size="10" id="suspend_until_to" name="suspend_until_to" class="flatpickr"/> >+ <input type="text" size="10" id="suspend_until_to" name="suspend_until_to" class="flatpickr" /> > </li> > <li> > <label for="holdnotes">Hold note:</label> >- <input type="text" id="holdnotes" name="holdnotes"/> >+ <input type="text" id="holdnotes" name="holdnotes" /> > </li> > </ol> > </fieldset> > <fieldset class="action"> >- <input type="submit" class="btn btn-primary" value="Search"/> >+ <input type="submit" class="btn btn-primary" value="Search" /> > </fieldset> >- </form> <!-- /#modify_holds_form --> >- </div> <!-- /#modify_holds_search --> >+ </form> >+ <!-- /#modify_holds_form --> >+ </div> >+ <!-- /#modify_holds_search --> > [% ELSIF view == "report" %] > <div id="modified_holds_results-wrapper"> > <div id="modified_holds_results" class="page-section"> > <table id="modified_holds"></table> >- </div> <!-- /#modified_holds_results --> >+ </div> >+ <!-- /#modified_holds_results --> > <fieldset class="action"> > <a href="/cgi-bin/koha/tools/batch_modify_holds.pl">Return to batch hold modification</a> >- </fieldset > >- </div> <!-- /#modified_holds_results-wrapper --> >+ </fieldset> >+ </div> >+ <!-- /#modified_holds_results-wrapper --> > [% END %] > <div id="modify_holds_results-wrapper" style="display:none;"> > <div id="toolbar" class="btn-toolbar"> > <a href="#" id="edit_search" class="btn btn-default"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit search</a> >- </div> <!-- /#toolbar --> >+ </div> >+ <!-- /#toolbar --> > <form action="/cgi-bin/koha/tools/batch_modify_holds.pl" method="post" id="process_mods"> > [% INCLUDE 'csrf-token.inc' %] > <div id="modify_holds_results" class="page-section"> >@@ -122,10 +127,12 @@ > <span></span> > <a href="#" id="clear-row-selection"><i class="fa fa-times"></i> Clear</a> > </div> >- </div> <!-- /#searchheader --> >+ </div> >+ <!-- /#searchheader --> > <h3>Holds found for: <span class="searchpattern"></span></h3> > <table id="holds_to_modify"></table> >- </div> <!-- /#modify_holds_results --> >+ </div> >+ <!-- /#modify_holds_results --> > <div id="modify_holds_form_options" class="page-section"> > <h2>Modify holds</h2> > <table id="modify_holds_options"> >@@ -161,208 +168,427 @@ > <input type="text" id="new_suspend_date" name="new_suspend_date" class="flatpickr" data-flatpickr-futuredate="true" /> > </td> > <td> >- <input type="text" id="new_hold_note" name="new_hold_note"/> >+ <input type="text" id="new_hold_note" name="new_hold_note" /> > </td> > <td> >- <input class="selection" type="checkbox" id="clear_hold_notes" name="clear_hold_notes" value="1"/> >+ <input class="selection" type="checkbox" id="clear_hold_notes" name="clear_hold_notes" value="1" /> > </td> > </tr> > </tbody> >- </table> <!-- /#modify_holds_options --> >- </div> <!-- /#modify_holds_options --> >+ </table> >+ <!-- /#modify_holds_options --> >+ </div> >+ <!-- /#modify_holds_options --> > <fieldset class="action"> > <input type="hidden" name="op" value="cud-modify" /> > <input type="submit" class="btn btn-primary" value="Modify holds" /> > <a class="cancel" href="/cgi-bin/koha/tools/batch_modify_holds.pl">Cancel</a> > </fieldset> >- </form> <!-- /#process_mods --> >- </div> <!-- /#modify_holds_results-wrapper --> >+ </form> >+ <!-- /#process_mods --> >+ </div> >+ <!-- /#modify_holds_results-wrapper --> > </main> >- </div> <!-- /.col-sm-10 col-sm-push-2 --> >+ </div> >+ <!-- /.col-sm-10 col-sm-push-2 --> > <div class="col-sm-2 col-sm-pull-10"> >- <aside> >- [% INCLUDE 'tools-menu.inc' %] >- </aside> >- </div> <!-- /.col-sm-2 col-sm-pull-10 --> >+ <aside> [% INCLUDE 'tools-menu.inc' %] </aside> >+ </div> >+ <!-- /.col-sm-2 col-sm-pull-10 --> > </div> >-[% MACRO jsinclude BLOCK %] >- [% Asset.js("js/tools-menu.js") | $raw %] >- [% INCLUDE 'calendar.inc' %] >- [% INCLUDE 'datatables.inc' %] >- [% INCLUDE 'select2.inc' %] >- [% INCLUDE 'js-patron-format.inc' %] >- [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] >- <script> >- let hide_patron_name = [% IF Koha.Preference('HidePatronName') %]true[% ELSE %]false[% END %]; >- let hold_ids = [% IF updated_holds %] [% updated_holds | $raw %] [% ELSE %] [] [% END %]; >- >- $(document).ready(function() { >- >- // Apply select2 to all select fields having a "multiple" attribute >- let selectFields = document.querySelectorAll('select[multiple]'); >- selectFields.forEach((selectField) => { >- selectField.style.minWidth = '200px'; >- $(selectField).select2(); >- }); >+ [% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/tools-menu.js") | $raw %] >+ [% INCLUDE 'calendar.inc' %] >+ [% INCLUDE 'datatables.inc' %] >+ [% INCLUDE 'select2.inc' %] >+ [% INCLUDE 'js-patron-format.inc' %] >+ [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] >+ <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() { >+ >+ // Apply select2 to all select fields having a "multiple" attribute >+ let selectFields = document.querySelectorAll('select[multiple]'); >+ selectFields.forEach((selectField) => { >+ selectField.style.minWidth = '200px'; >+ $(selectField).select2(); >+ }); > >- //Empty local storage from previous selections >- localStorage.removeItem("holds_modify_selections"); >- >- $("#holds_to_modify").on("change", "input[type='checkbox']", function(){ >- var holds_modify_selections = JSON.parse(localStorage.getItem("holds_modify_selections")) || []; >- var hold_id = $(this).val(); >- if ($(this).prop("checked")) { >- holds_modify_selections.push($(this).val()); >- localStorage.setItem("holds_modify_selections", JSON.stringify(holds_modify_selections)); >- showHoldSelections(holds_modify_selections.length); >- } else { >- var filtered = holds_modify_selections.filter(function( value ){ >- return value !== hold_id; >- }); >- if( filtered.length > 0 ){ >- localStorage.setItem("holds_modify_selections", JSON.stringify( filtered )); >- holds_modify_selections = filtered; >- showHoldSelections( filtered.length ); >+ //Empty local storage from previous selections >+ localStorage.removeItem("holds_modify_selections"); >+ >+ $("#holds_to_modify").on("change", "input[type='checkbox']", function(){ >+ var holds_modify_selections = JSON.parse(localStorage.getItem("holds_modify_selections")) || []; >+ var hold_id = $(this).val(); >+ if ($(this).prop("checked")) { >+ >+ hold_data = { >+ hold_id: hold_id, >+ found_status: $(this).closest('tr').find('.found_status').children('span').data('found-status'), >+ suspended: $(this).closest('tr').find('.suspended').children('span').data('suspended'), >+ } >+ >+ holds_modify_selections.push(hold_data); >+ localStorage.setItem("holds_modify_selections", JSON.stringify(holds_modify_selections)); >+ showHoldSelections(holds_modify_selections.length); > } else { >- holds_modify_selections = []; >- localStorage.removeItem("holds_modify_selections"); >- showHoldSelections( 0 ); >+ var filtered = holds_modify_selections.filter(function( hold_obj ){ >+ return hold_obj.hold_id !== hold_id; >+ }); >+ if( filtered.length > 0 ){ >+ localStorage.setItem("holds_modify_selections", JSON.stringify( filtered )); >+ holds_modify_selections = filtered; >+ showHoldSelections( filtered.length ); >+ } else { >+ holds_modify_selections = []; >+ localStorage.removeItem("holds_modify_selections"); >+ showHoldSelections( 0 ); >+ } > } >- } >- }); >- >- $("#select_all").on("click", function(e){ >- e.preventDefault(); >- $("#holds_to_modify input[type='checkbox']").each(function(){ >- $(this).prop("checked", true).change(); > }); >- }); > >- $("#clear_all").on("click", function(e){ >- e.preventDefault(); >- $("#holds_to_modify input[type='checkbox']").each(function(){ >- $(this).prop("checked", false).change(); >+ $("#select_all").on("click", function(e){ >+ e.preventDefault(); >+ $("#holds_to_modify input[type='checkbox']").each(function(){ >+ $(this).prop("checked", true).change(); >+ }); > }); >- }); > >- $("#clear-row-selection").on("click", function (e) { >- e.preventDefault(); >- $("input[type='checkbox']").prop("checked", false).change(); >- localStorage.removeItem("holds_modify_selections"); >- $("#table_search_selections").hide(); >- }); >- >- $('#modify_holds_form').submit(function() { >- var modify_holds_form = $(this); >- search_holds(modify_holds_form); >- $("#modify_holds_search").hide(); >- $('#edit_search').show(); >- return false; >- }); >- >- $("#edit_search").on("click", function(e){ >- e.preventDefault(); >- $('#modify_holds_search').show(); >- $('#edit_search').hide(); >- }); >- >- function prepSelections(){ >- let holds_modify_selections = JSON.parse( localStorage.getItem("holds_modify_selections") ) || []; >- if( holds_modify_selections.length > 0 ){ >- showHoldSelections( holds_modify_selections.length ); >+ $("#clear_all").on("click", function(e){ >+ e.preventDefault(); > $("#holds_to_modify input[type='checkbox']").each(function(){ >- var hold_id = $(this).val(); >- if( holds_modify_selections.indexOf( hold_id ) >= 0 ){ >- $(this).prop("checked", true ); >- } >+ $(this).prop("checked", false).change(); > }); >- } >- } >+ }); > >- function showHoldSelections( number ){ >- if (number === 0) { >+ $("#clear-row-selection").on("click", function (e) { >+ e.preventDefault(); >+ $("input[type='checkbox']").prop("checked", false).change(); >+ localStorage.removeItem("holds_modify_selections"); > $("#table_search_selections").hide(); >- } else { >- $("#table_search_selections") >- .show() >- .find("span") >- .text(__("Holds selected: %s").format(number)); >+ }); >+ >+ $('#modify_holds_form').submit(function() { >+ var modify_holds_form = $(this); >+ search_holds(modify_holds_form); >+ $("#modify_holds_search").hide(); >+ $('#edit_search').show(); >+ return false; >+ }); >+ >+ if(hold_ids_from_sql.length > 0){ >+ $('#modify_holds_form').trigger('submit'); > } >- } > >- function search_holds(modify_holds_form){ >- var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'holds_to_modify', 'json' ) | $raw %]; >- var searchpattern = ""; >- var filters = { >- "me.expirationdate": function(){ >- var expirationdate_from = modify_holds_form.find("#expirationdate_from").val(); >- var expirationdate_to = modify_holds_form.find("#expirationdate_to").val(); >+ $("#edit_search").on("click", function(e){ >+ e.preventDefault(); >+ $('#modify_holds_search').show(); >+ $('#edit_search').hide(); >+ }); > >- searchpattern += expirationdate_from && expirationdate_to ? _("expiration date between ")+ expirationdate_from + " and " + expirationdate_to + " ": ""; >+ function showHoldSelections( number ){ >+ if (number === 0) { >+ $("#table_search_selections").hide(); >+ } else { >+ $("#table_search_selections") >+ .show() >+ .find("span") >+ .text(__("Holds selected: %s").format(number)); >+ } >+ } > >- return expirationdate_from && expirationdate_to ? {"-between": [expirationdate_from, expirationdate_to]} : ""; >- }, >- "me.branchcode": function(){ >- var branchcodes = modify_holds_form.find("#branchcodes").val(); >- if( branchcodes.length > 0 ){ >- searchpattern += _("from libraries "); >- var selected_libraries = modify_holds_form.find("#branchcodes option:selected"); >- $.each(selected_libraries, function(key, value) { >- searchpattern += value.text + " "; >- }); >- return {"-in": branchcodes }; >- } >- }, >- "me.status": function(){ >- var found_status = modify_holds_form.find("#found_status").val(); >- if( found_status.length > 0 ){ >- var filters = [{"-in": found_status}]; >- if(jQuery.inArray("NULL", found_status) !== -1){ >- filters.push({"=": null}); >+ function search_holds(modify_holds_form){ >+ var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'holds_to_modify', 'json' ) | $raw %]; >+ var searchpattern = ""; >+ var filters = { >+ "me.expirationdate": function(){ >+ var expirationdate_from = modify_holds_form.find("#expirationdate_from").val(); >+ var expirationdate_to = modify_holds_form.find("#expirationdate_to").val(); >+ >+ if (expirationdate_from && expirationdate_to){ >+ searchpattern += _("expiration date between ") + expirationdate_from + " and " + expirationdate_to + " "; >+ return {"-between": [expirationdate_from, expirationdate_to]}; >+ } >+ else if (expirationdate_from && !expirationdate_to){ >+ searchpattern += _("expiration date from ") + expirationdate_from + " "; >+ return {">=": expirationdate_from }; >+ } else if (!expirationdate_from && expirationdate_to){ >+ searchpattern += _("expiration date to ") + expirationdate_to + " "; >+ return {"<=": expirationdate_to }; >+ } >+ }, >+ "me.branchcode": function(){ >+ var branchcodes = modify_holds_form.find("#branchcodes").val(); >+ if( branchcodes.length > 0 ){ >+ searchpattern += _("from libraries "); >+ var selected_libraries = modify_holds_form.find("#branchcodes option:selected"); >+ $.each(selected_libraries, function(key, value) { >+ searchpattern += value.text + " "; >+ }); >+ return {"-in": branchcodes }; > } >- searchpattern += _("found status in "); >- $.each(found_status, function(key, value) { >- let status = _("No status "); >- if ( value == "T" ) { >- status = _("In transit "); >- } else if( value == "P" ) { >- status = _("In processing "); >- } else if( value == "W" ) { >- status = _("Waiting "); >+ }, >+ "me.status": function(){ >+ var found_status = modify_holds_form.find("#found_status").val(); >+ if( found_status.length > 0 ){ >+ var filters = [{"-in": found_status}]; >+ if(jQuery.inArray("NULL", found_status) !== -1){ >+ filters.push({"=": null}); > } >- searchpattern += status; >- }); >- return filters; >+ searchpattern += _("found status in "); >+ $.each(found_status, function(key, value) { >+ let status = _("No status "); >+ if ( value == "T" ) { >+ status = _("In transit "); >+ } else if( value == "P" ) { >+ status = _("In processing "); >+ } else if( value == "W" ) { >+ status = _("Waiting "); >+ } >+ searchpattern += status; >+ }); >+ return filters; >+ } >+ }, >+ "me.suspended": function(){ >+ var suspend_status = modify_holds_form.find("#suspend_status").val(); >+ >+ if(suspend_status != "none"){ >+ var suspended_text = suspend_status == 0 ? _("Not suspended") : _("Suspended"); >+ searchpattern += _("with suspend status ") + suspended_text; >+ >+ return {"=": suspend_status}; >+ } >+ }, >+ "me.suspend_until": function(){ >+ var suspend_until_from = modify_holds_form.find("#suspend_until_from").val(); >+ var suspend_until_to = modify_holds_form.find("#suspend_until_to").val(); >+ >+ searchpattern += suspend_until_from && suspend_until_to ? _("suspend date between ")+ suspend_until_from +" and "+suspend_until_to : ""; >+ >+ return suspend_until_from && suspend_until_to ? {"-between": [suspend_until_from, suspend_until_to]} : ""; >+ }, >+ "me.notes": function(){ >+ var holdnotes = modify_holds_form.find("#holdnotes").val(); >+ >+ 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 } : ""; > } >- }, >- "me.suspended": function(){ >- var suspend_status = modify_holds_form.find("#suspend_status").val(); >+ } > >- if(suspend_status != "none"){ >- var suspended_text = suspend_status == 0 ? _("Not suspended") : _("Suspended"); >- searchpattern += _("with suspend status ") + suspended_text; >+ var holds_modify_table = $("#holds_to_modify").kohaTable({ >+ "ajax": { >+ "url": "/api/v1/holds" >+ }, >+ "embed": [ >+ "biblio", >+ "item", >+ "pickup_library", >+ "patron" >+ ], >+ "destroy": true, >+ "autoWidth": false, >+ "processing": true, >+ "columns": [ >+ { >+ "data": "hold_id", >+ "name": "checkbox", >+ "orderable": false, >+ "render": function(data, type, row, meta) { >+ return '<input class="selection" type="checkbox" value="'+ encodeURIComponent(data) +'"/>' >+ } >+ }, >+ { >+ "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 '<a href="/cgi-bin/koha/catalogue/detail.pl?' + >+ 'biblionumber=' + encodeURIComponent( row.biblio_id ) + '">' + escape_str( data ) + '</a>'; >+ } >+ }, >+ { >+ "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 '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + >+ 'itemnumber='+ item_id +'&biblionumber='+ biblio_id +'&' + >+ 'bi='+ biblio_id +'#item'+ item_id +'">' + escape_str( data ) + '</a>' >+ } >+ } >+ }, >+ { >+ "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", >+ "title": _("Status"), >+ "className": "found_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 "<span data-found-status='" + escape_str( data ) + "'>" + status + "</span>"; >+ } >+ }, >+ { >+ "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", >+ "className": "suspended", >+ "title": _("Suspended"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ var suspended_string = data == 0 ? _("No") : _("Yes"); >+ return "<span data-suspended='" + data + "'>" + suspended_string + "</span>"; >+ } >+ }, >+ { >+ "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); > >- return {"=": suspend_status}; >+ $(".searchpattern").text(searchpattern); >+ >+ $("#modify_holds_results-wrapper").show(); >+ } >+ >+ $("#process_mods").on('submit', function(e) { >+ >+ var hold_ids = JSON.parse( localStorage.getItem("holds_modify_selections") ) || []; >+ >+ $("#process_mods input[name='hold_id']").remove(); >+ >+ hold_ids.forEach(function(hold) { >+ $('<input>').attr({ >+ type: 'hidden', >+ name: 'hold_id', >+ value: hold.hold_id >+ }).appendTo('#process_mods'); >+ }); >+ >+ var errors = []; >+ >+ var new_expiration_date = $("#new_expiration_date").val(); >+ var new_pickup_loc = $("#new_pickup_loc").val(); >+ var new_suspend_status = $("#new_suspend_status").val(); >+ var new_suspend_date = $("#new_suspend_date").val(); >+ var new_hold_note = $("#new_hold_note").val(); >+ var clear_hold_notes = $("#clear_hold_notes").val(); >+ >+ if ( hold_ids.length == 0 ) { >+ e.preventDefault(); >+ errors.push(_("Please select at least one hold to process.")); >+ } >+ >+ if( new_pickup_loc || new_suspend_status || new_suspend_date ){ >+ var found = false; >+ hold_ids.forEach(function(hold){ >+ if( hold.found_status ){ >+ e.preventDefault(); >+ found = true; >+ } >+ }); >+ if( ( new_suspend_status || new_suspend_date ) && found ){ >+ errors.push(_("One or more holds have found status and can't be suspended.")); > } >- }, >- "me.suspend_until": function(){ >- var suspend_until_from = modify_holds_form.find("#suspend_until_from").val(); >- var suspend_until_to = modify_holds_form.find("#suspend_until_to").val(); >+ if( new_pickup_loc && found ){ >+ errors.push(_("One or more holds have found status and their pick up location can't be changed.")); >+ } >+ } > >- searchpattern += suspend_until_from && suspend_until_to ? _("suspend date between ")+ suspend_until_from +"-"+suspend_until_to : ""; >+ var suspended = false; > >- return suspend_until_from && suspend_until_to ? {"-between": [suspend_until_from, suspend_until_to]} : ""; >- }, >- "me.notes": function(){ >- var holdnotes = modify_holds_form.find("#holdnotes").val(); >+ hold_ids.forEach(function(hold){ >+ if( hold.suspened ){ >+ suspended = true; >+ } >+ }); > >- searchpattern += holdnotes ? _("hold notes like ") + holdnotes : ""; >+ if( ( !new_suspend_status || new_suspend_status == "0" || !suspended ) && new_suspend_date ){ >+ new_suspend_status = 1; >+ } > >- return holdnotes ? {"-like": "%"+holdnotes+"%"} : ""; >+ if (errors.length > 0) { >+ e.preventDefault(); >+ $("#errorList").html(errors.map(error => `<li>${error}</li>`).join("")); >+ $("#errorModal").modal('show'); >+ return false; >+ } >+ return true; >+ }); >+ >+ //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_modify_table = $("#holds_to_modify").kohaTable({ >+ var holds_modified_table = $("#modified_holds").kohaTable({ > "ajax": { > "url": "/api/v1/holds" > }, >@@ -376,14 +602,6 @@ > "autoWidth": false, > "processing": true, > "columns": [ >- { >- "data": "hold_id", >- "name": "checkbox", >- "orderable": false, >- "render": function(data, type, row, meta) { >- return '<input class="selection" type="checkbox" name="hold_id" value="'+ encodeURIComponent(data) +'"/>' >- } >- }, > { > "data": "expiration_date", > "name": "expiration_date", >@@ -445,7 +663,7 @@ > } else if( data == "W" ) { > status = _("Waiting"); > } >- return "<span data-found-status='" + escape_str( data ) + "'>" + status + "</span>"; >+ return status; > } > }, > { >@@ -484,195 +702,15 @@ > return escape_str( data ); > } > } >- ], >- "drawCallback": function( settings ) { >- prepSelections(); >- }, >+ ] > }, table_settings, 0, filters); > >- $(".searchpattern").text(searchpattern); >- >- $("#modify_holds_results-wrapper").show(); >- } >- >- $("#process_mods").on('submit', function(e) { >- >- var hold_ids = []; >- var errors = []; >- var holds_checked = $("input[type=checkbox][name='hold_id']:checked"); >- >- var new_expiration_date = $("#new_expiration_date").val(); >- var new_pickup_loc = $("#new_pickup_loc").val(); >- var new_suspend_status = $("#new_suspend_status").val(); >- var new_suspend_date = $("#new_suspend_date").val(); >- var new_hold_note = $("#new_hold_note").val(); >- var clear_hold_notes = $("#clear_hold_notes").val(); >+ var modified_message = '<div class="alert alert-info">'+hold_ids.length+' hold(s) have been modified!</div>'; >+ $("#modified_holds_results-wrapper").prepend(modified_message); > >- if ( holds_checked.length == 0 ) { >- e.preventDefault(); >- errors.push(_("Please select at least one hold to process.")); >- } >- >- if( new_pickup_loc || new_suspend_status ){ >- var found = false; >- holds_checked.each(function(){ >- if($(this).parents("tr").children(".found_status").children("span").data("found-status")){ >- e.preventDefault(); >- found = true; >- } >- }); >- if( new_suspend_status && found ){ >- errors.push(_("One or more holds have found status and can't be suspended.")); >- } >- if( new_pickup_loc && found ){ >- errors.push(_("One or more holds have found status and their pick up location can't be changed.")); >- } >- } >- if( ( !new_suspend_status || new_suspend_status == "0") && new_suspend_date ){ >- e.preventDefault(); >- errors.push(_("You have to suspend holds if new suspend until date is set.")); >- } >- >- if (errors.length > 0) { >- e.preventDefault(); >- $("#errorList").html(errors.map(error => `<li>${error}</li>`).join("")); >- $("#errorModal").modal('show'); >- return false; >- } >- >- return true; > }); >+ </script> >+ [% END %] > >- //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 '<a href="/cgi-bin/koha/catalogue/detail.pl?' + >- 'biblionumber=' + encodeURIComponent( row.biblio_id ) + '">' + escape_str( data ) + '</a>'; >- } >- }, >- { >- "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 '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + >- 'itemnumber='+ item_id +'&biblionumber='+ biblio_id +'&' + >- 'bi='+ biblio_id +'#item'+ item_id +'">' + escape_str( data ) + '</a>' >- } >- } >- }, >- { >- "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 = '<div class="alert alert-info">'+hold_ids.length+' hold(s) have been modified!</div>'; >- $("#modified_holds_results-wrapper").prepend(modified_message); >- >- }); >- </script> >-[% END %] >- >-[% INCLUDE 'intranet-bottom.inc' %] >\ No newline at end of file >+ [% INCLUDE 'intranet-bottom.inc' %] >+</div> >diff --git a/tools/batch_modify_holds.pl b/tools/batch_modify_holds.pl >index a5a95948e54..c73b1f332e8 100755 >--- a/tools/batch_modify_holds.pl >+++ b/tools/batch_modify_holds.pl >@@ -30,7 +30,7 @@ use Koha::DateUtils qw( dt_from_string ); > use Koha::Holds; > > my $input = CGI->new; >-my $op = $input->param('op') // q|form|; >+my $op = $input->param('op') // q|cud-form|; > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >@@ -43,8 +43,13 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > > my @hold_ids; > >-if ( $op eq 'form' ) { >- $template->param( view => 'form', ); >+if ( $op eq 'cud-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 => 'cud-form', ); > } elsif ( $op eq 'cud-modify' ) { > my $new_expiration_date = $input->param('new_expiration_date'); > my $new_pickup_loc = $input->param('new_pickup_loc'); >@@ -68,18 +73,19 @@ if ( $op eq 'form' ) { > $hold->branchcode($new_pickup_loc)->store; > } > >- if ( $new_suspend_status ne "" && !$hold->is_found ) { >- if ($new_suspend_status) { >- $hold->suspend(1)->store; >- if ($new_suspend_date) { >- $hold->suspend_until($new_suspend_date)->store; >- } else { >- $hold->suspend_until(undef)->store; >- } >+ if ( $new_suspend_status && $new_suspend_status ne "" && !$hold->is_found ) { >+ $hold->suspend(1)->store; >+ if ($new_suspend_date) { >+ $hold->suspend_until($new_suspend_date)->store; > } else { >- $hold->suspend(0)->store; > $hold->suspend_until(undef)->store; > } >+ } elsif ( !$new_suspend_status && $new_suspend_date ) { >+ $hold->suspend(1)->store; >+ $hold->suspend_until($new_suspend_date)->store; >+ } else { >+ $hold->suspend(0)->store; >+ $hold->suspend_until(undef)->store; > } > > if ($new_hold_note) { >-- >2.39.5
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
|
183151
|
183294
|
183295
|
183296
|
183297
|
183298
|
183299
|
183300
|
183305
|
183306
|
183307
|
183308
|
183771