Bugzilla – Attachment 143646 Details for
Bug 28726
Add sort1 and sort2 to patron card creator patron search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28726: Add sort1 and sort2 to patron card creator - patron search.
Bug-28726-Add-sort1-and-sort2-to-patron-card-creat.patch (text/plain), 12.17 KB, created by
ByWater Sandboxes
on 2022-11-10 13:17:42 UTC
(
hide
)
Description:
Bug 28726: Add sort1 and sort2 to patron card creator - patron search.
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2022-11-10 13:17:42 UTC
Size:
12.17 KB
patch
obsolete
>From 9d92ff11d1c9399ca972f783cebc4c1cd7d3c921 Mon Sep 17 00:00:00 2001 >From: Michael Hafen <michael.hafen@washk12.org> >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 <laura.escamilla@bywatersolutions.com> >--- > .../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 %] > </select> > </li> >+ [% CASE 'sort1' %] >+ <li> >+ <label for="sort1_filter">Sort1:</label> >+ <select class="select2" id="sort1_filter"> >+ <option value="">Any</option> >+ [% FOREACH s1 IN sort1 %] >+ <option value="[% s1 | html %]">[% s1 | html %]</option> >+ [% END %] >+ </select> >+ </li> >+ [% CASE 'sort2' %] >+ <li> >+ <label for="sort2_filter">Sort2:</label> >+ <select class="select2" id="sort2_filter"> >+ <option value="">Any</option> >+ [% FOREACH s2 IN sort2 %] >+ <option value="[% s2 | html %]">[% s2 | html %]</option> >+ [% END %] >+ </select> >+ </li> > [% CASE 'search_field' %] > <li> > <label for="searchfieldstype_filter">Search field:</label> >@@ -209,6 +229,8 @@ > [% IF redirect_if_one_result && !redirect_url %] > <script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script> > [% END %] >+ >+ [% INCLUDE 'select2.inc' %] > <script> > let categories = [% To.json(categories) | $raw %].map(e => { > e['_id'] = e.categorycode; >@@ -233,6 +255,10 @@ > let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; > [% END %] > >+ $(document).ready(function() { >+ $('sort1_filter').select2({allowClear:true}); >+ $('sort2_filter').select2({allowClear:true}); >+ }); > </script> > > [% 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 @@ > <div id="patron_search"> > <div class="container-fluid"> > >- [% PROCESS patron_search_filters categories => categories, libraries => libraries, filters => ['branch', 'category'], search_filter => searchmember %] >+ [% PROCESS patron_search_filters categories => categories, libraries => libraries, sort1 => sort1, sort2 => sort2, filters => form_filters, search_filter => searchmember %] > </form> > >+ <div id="searchresults"> >+ <div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;"> >+ <div> >+ [% IF columns.grep('checkbox').size %] >+ <a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a> >+ | >+ <a href="#" class="btn btn-link" id="clear_all"><i class="fa fa-remove"></i> Clear all</a> >+ [% IF selection_type == 'add' %] >+ <button id="add-selected" class="btn btn-sm btn-default" type="submit">Add selected patrons</button> >+ [% END %] >+ [% END %] >+ </div> >+ </div> > [% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %] >+ </div> > > <div id="closewindow"><a href="#" class="btn btn-default btn-default close">Close</a></div> > >@@ -28,6 +42,35 @@ > </div> > > [% MACRO jsinclude BLOCK %] >+<script> >+ $(document).ready(function() { >+ $("#select_all").on("click",function(e){ >+ e.preventDefault(); >+ $(".selection").prop("checked", true).change(); >+ }); >+ $("#clear_all").on("click",function(e){ >+ e.preventDefault(); >+ $(".selection").prop("checked", false).change(); >+ }); >+ $("#searchheader").hide(); >+ $("#patron_search_form").on('submit', function(){$("#searchheader").show();}); >+ $("#clear_search").on("click",function(e){$("#searchheader").hide();}); >+ >+ $('#add-selected').on('click', function(e) { >+ e.preventDefault(); >+ var counter = 0; >+ $('tr:has(.selection:checked) .add_user').each(function(){ >+ var borrowernumber = $(this).data('borrowernumber'); >+ var firstname = $(this).data('firstname'); >+ var surname = $(this).data('surname'); >+ add_user( borrowernumber, firstname + ' ' + surname ); >+ counter++; >+ }); >+ $('#info').html(_("%s Patrons added.").format(counter)); >+ }); >+ }); >+</script> >+ > [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, filter => filter, actions => [selection_type], preview_on_name_click => 1, callback => callback %] > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >index 31db0a0123..5766d80cc0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt >@@ -193,7 +193,7 @@ > function Add() { > var bor_nums = document.getElementById("bor_num_list"); > if (bor_nums.value == '') { >- window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add", >+ window.open("/cgi-bin/koha/members/search.pl?columns=checkbox,cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add&filter_sort1=1&filter_sort2=1", > 'PatronPopup', > 'width=1024,height=768,location=yes,toolbar=no,' > + 'scrollbars=yes,resize=yes'); >diff --git a/members/search.pl b/members/search.pl >index c3d80a2e4f..c9c23e9b56 100755 >--- a/members/search.pl >+++ b/members/search.pl >@@ -19,8 +19,10 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > use C4::Context; >+use List::MoreUtils qw(uniq); > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); >+use C4::Koha qw( GetAuthorisedValues ); > use Koha::Patron::Attribute::Types; > > my $input = CGI->new; >@@ -39,6 +41,20 @@ my @columns = split ',', $input->param('columns'); > my $callback = $input->param('callback'); > my $selection_type = $input->param('selection_type') || 'select'; > my $filter = $input->param('filter'); >+my @form_filters = ('branch','category'); >+ >+my $sort_filter = { ( C4::Context->only_my_library ? (branchcode => C4::Context->userenv->{branch}) : () ) }; >+my ( @sort1, @sort2 ); >+if ( $input->param('filter_sort1') ) { >+ @sort1 = map { $_->{lib} } @{ GetAuthorisedValues("Bsort1") }; >+ unless ( @sort1 ) { @sort1 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort1') ); } >+ push @form_filters, 'sort1'; >+} >+if ( $input->param('filter_sort2') ) { >+ @sort2 = map { $_->{lib} } @{ GetAuthorisedValues("Bsort2") }; >+ unless ( @sort2 ) { @sort2 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort2') ); } >+ push @form_filters, 'sort2'; >+} > > $template->param( > view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", >@@ -49,5 +65,8 @@ $template->param( > attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes') > ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ] > : [] ), >+ form_filters => \@form_filters, >+ sort1 => \@sort1, >+ sort2 => \@sort2, > ); > output_html_with_http_headers( $input, $cookie, $template->output ); >-- >2.30.2
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 28726
:
122991
|
129203
|
134003
|
137854
|
138552
|
138653
|
141405
|
143646
|
147477
|
148489
|
150650