From 9d92ff11d1c9399ca972f783cebc4c1cd7d3c921 Mon Sep 17 00:00:00 2001 From: Michael Hafen Date: Tue, 20 Jul 2021 12:12:42 -0600 Subject: [PATCH] Bug 28726: Add sort1 and sort2 to patron card creator - patron search. Also adds a select all / clear all and checkboxes. Test plan: 1. start a new batch in the patron card creator (Tools -> Patron card creator -> New -> card batch) 2. click the Add patron(s) button. Observe that Category and Library are the only options. 3. Close search for patron window. 4. Apply patch. 5. click the Add patron(s) button. Observe that you can now search for patrons by their sort1 and sort2 values. 6. perform a search and observe the 'Select all | Clear all | Add selected patrons' links and button. 7. use the Select all link to select all the patrons found by the search. 8. use the Add selected patrons button to add the selected patrons to the card batch's Add by borrowernumber(s) text input field. 9. close the search for patron window. Signed-off-by: Laura Escamilla --- .../prog/en/includes/patron-search.inc | 58 ++++++++++++++++++- .../prog/en/modules/members/search.tt | 45 +++++++++++++- .../prog/en/modules/patroncards/edit-batch.tt | 2 +- members/search.pl | 19 ++++++ 4 files changed, 120 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index 3d1de0eb15..84f83a41f8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -56,6 +56,26 @@ [% END %] + [% CASE 'sort1' %] +
  • + + +
  • + [% CASE 'sort2' %] +
  • + + +
  • [% CASE 'search_field' %]
  • @@ -209,6 +229,8 @@ [% IF redirect_if_one_result && !redirect_url %] [% END %] + + [% INCLUDE 'select2.inc' %] [% INCLUDE 'datatables.inc' %] @@ -308,11 +334,31 @@ return { "like": start_with + "%" } }, "-and": function(){ + let filters = []; + let f_sort1 = $("#sort1_filter").val(); + if ( f_sort1 ) { + filters.push({ + "me.sort1": f_sort1 + }); + } + let f_sort2 = $("#sort2_filter").val(); + if ( f_sort2 ) { + filters.push({ + "me.sort2": f_sort2 + }); + } + let pattern = $("#search_patron_filter").val(); - if (!pattern) return ""; + if (!pattern) { + if ( filters.length == 0 ) { + return ""; + } + else { + return filters; + } + } let patterns = pattern.split(' ').filter(function(s){ return s.length }); - let filters = []; let search_type = $("#searchtype_filter").val() || "contain"; let search_fields = $("#searchfieldstype_filter").val(); if ( !search_fields ) { @@ -731,6 +777,12 @@ if ( $("#branchcode_filter").val() ) { searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text(); } + if ( $("#sort1_filter").val() ) { + searched += _(" with sort1 ") + $("#sort1_filter").find("option:selected").text(); + } + if ( $("#sort2_filter").val() ) { + searched += _(" with sort2 ") + $("#sort2_filter").find("option:selected").text(); + } $("#searchpattern").text(searched); $("#searchpattern").parent().show(); } @@ -788,6 +840,8 @@ $("#searchtype_filter option[value='contain']").prop("selected", true); $("#categorycode_filter option:first").prop("selected", true); $("#branchcode_filter option:first").prop("selected", true); + $("#sort1_filter option:first").prop("selected", true); + $("#sort2_filter option:first").prop("selected", true); $("#firstletter_filter").val(''); $("#search_patron_filter").val(''); /* remove any search string added by firstletter search */ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt index fecba041ea..18e0aedd46 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt @@ -17,10 +17,24 @@