Bugzilla – Attachment 134003 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.
0001-Bug-28726-Add-sort1-and-sort2-to-patron-card-creator.patch (text/plain), 11.96 KB, created by
Michael Hafen
on 2022-04-26 23:30:38 UTC
(
hide
)
Description:
Bug 28726 - Add sort1 and sort2 to patron card creator - patron search.
Filename:
MIME Type:
Creator:
Michael Hafen
Created:
2022-04-26 23:30:38 UTC
Size:
11.96 KB
patch
obsolete
>From 568327592a5ba1f1699c1bd108bc64c97882738b 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. >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. >--- > .../prog/en/includes/patron-search.inc | 54 +++++++++++++++++-- > .../prog/en/modules/members/search.tt | 45 +++++++++++++++- > .../prog/en/modules/patroncards/edit-batch.tt | 2 +- > members/search.pl | 16 ++++++ > 4 files changed, 112 insertions(+), 5 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 7212814b25..cda497c66b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -55,12 +55,32 @@ > [% END %] > </select> > </li> >+ [% CASE 'sort1' %] >+ <li> >+ <label for="sort1_filter">Sort1:</label> >+ <select 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 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> > <select name="searchfieldstype" id="searchfieldstype_filter"> > [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %] >- [% default_fields = [ 'firstname,surname,othernames,cardnumber,userid', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %] >+ [% default_fields = [ 'firstname,surname,othernames,cardnumber,userid', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth' ] %] > [% search_options = default_fields.merge(pref_fields).unique %] > [% FOREACH s_o IN search_options %] > [% display_name = PROCESS patron_fields name=s_o %] >@@ -295,10 +315,30 @@ > 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 filter = $("#search_patron_filter").val(); >- if (!filter) return ""; >+ if (!filter) { >+ if ( filters.length == 0 ) { >+ return ""; >+ } >+ else { >+ return filters; >+ } >+ } > >- let filters = []; > let search_type = $("#searchtype_filter").val() || "contain"; > let search_fields = $("#searchfieldstype_filter").val(); > if ( !search_fields ) { >@@ -710,6 +750,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(); > } >@@ -745,6 +791,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 ba77fb046e..8097cb46e6 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" class="yui-t7"> > <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 4ef824d5ed..99f943efb9 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 >@@ -185,7 +185,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..0ef1360ced 100755 >--- a/members/search.pl >+++ b/members/search.pl >@@ -19,6 +19,7 @@ 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 Koha::Patron::Attribute::Types; >@@ -39,6 +40,18 @@ 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 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort1') ); >+ push @form_filters, 'sort1'; >+} >+if ( $input->param('filter_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 +62,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.25.1 >
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