From deb0c58ca3d75ec897a335cb8471693462a66efc 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. Content-Type: text/plain; charset=utf-8 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: Solene Ngamga Signed-off-by: Marcel de Rooy --- .../prog/en/includes/patron-search.inc | 60 ++++++++++++++++++- .../prog/en/modules/members/search.tt | 45 +++++++++++++- .../prog/en/modules/patroncards/edit-batch.tt | 2 +- 3 files changed, 103 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 6ae5ebb9e2..731448b381 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,16 @@ [% END %] + [% CASE 'sort1' %] +
  • + + [% PROCESS 'av-build-dropbox.inc' name="sort1_filter", category="Bsort1", empty=1, size = 20 %] +
  • + [% CASE 'sort2' %] +
  • + + [% PROCESS 'av-build-dropbox.inc' name="sort2_filter", category="Bsort2", empty=1, size = 20 %] +
  • [% CASE 'search_field' %]
  • [% INCLUDE patron_fields_dropdown %] @@ -197,6 +207,8 @@ [% IF redirect_if_one_result && !redirect_url %] [% END %] + + [% INCLUDE 'select2.inc' %] [% INCLUDE 'datatables.inc' %] @@ -298,11 +314,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(/[\s,]+/).filter(function(s){ return s.length }); - let filters = []; let search_type = $("#searchtype_filter").val() || "contain"; let search_fields = $("#searchfieldstype_filter").val(); if ( !search_fields ) { @@ -733,6 +769,24 @@ if ( $("#branchcode_filter").val() ) { searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text(); } + if ( $("#sort1_filter").val() ) { + searched += _(" with sort1 ") + if ( $("select#sort1_filter") ) { + searched += $("select#sort1_filter").find("option:selected").text(); + } + else { + searched += $("#sort1_filter").val(); + } + } + if ( $("#sort2_filter").val() ) { + searched += _(" with sort2 "); + if ( $("select#sort2_filter") ) { + searched += $("select#sort2_filter").find("option:selected").text(); + } + else { + searched += $("#sort2_filter").val(); + } + } $("#searchpattern").text(searched); $("#searchpattern").parent().show(); } @@ -790,6 +844,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").val('').trigger("change"); + $("#sort2_filter").val('').trigger("change"); $("#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..6146eebe5c 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 @@