From 7e053bf5462494cf91f2f2be745416d2d7ad261b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 28 Apr 2022 10:32:28 +0200 Subject: [PATCH] Bug 30628: Fix patron selection in batch patron modification tool bug 28014 added Datatables to this view, but the form is submitted with only the checkboxes from the first page. Solution adapted from https://stackoverflow.com/questions/33240409/how-to-submit-checkboxes-from-all-pages-with-jquery-datatables Test plan: Have more than 20 cardnumbers, use the batch patron modification tool Select (not all) patrons from the first page and second page Submit the form Notice that the patrons you have selected appear on the confirmation page. Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall --- .../prog/en/modules/tools/modborrowers.tt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt index f60a917a9b..14dab4267b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -424,7 +424,7 @@ [% END %] $(document).ready(function() { [% IF borrowers %] - KohaTable("borrowerst", { + let patron_table = KohaTable("borrowerst", { "order": [[ 1, "asc" ]], "autoWidth": false, }, table_settings); @@ -488,6 +488,23 @@ $("#borrowernumberuploadfile, #cardnumberuploadfile, #borrowernumberlist, #cardnumberlist").val(""); } }); + + $('form[name="f"]').on("submit", function(){ + // Add the checkboxes to the DOM before we submit the form + var form = this; + var checkboxes = patron_table.$('input:checkbox:checked').serializeArray(); + $.each(checkboxes, function(){ + let borrowernumber = this.value; + if(!$(form).find('input[name="borrowernumber"][value="'+borrowernumber+'"]').length){ + $(form).append( + $('') + .attr('type', 'hidden') + .attr('name', 'borrowernumber') + .val(borrowernumber) + ); + } + }); + }); }); function updateAttrValues (select_attr) { -- 2.39.5