Bugzilla – Attachment 122991 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]
Proposed fix
0001-Bug-28726-Add-sort1-and-sort2-to-patron-card-creator.patch (text/plain), 9.88 KB, created by
Michael Hafen
on 2021-07-20 18:17:55 UTC
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Michael Hafen
Created:
2021-07-20 18:17:55 UTC
Size:
9.88 KB
patch
obsolete
>From a55eb983a6ef9406cf452f187ad76be8ac667b94 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. >--- > C4/Utils/DataTables/Members.pm | 10 ++++ > .../prog/en/modules/common/patron_search.tt | 52 +++++++++++++++++++ > .../patroncards/tables/members_results.tt | 2 + > patroncards/add_user_search.pl | 8 ++- > svc/members/search | 4 ++ > 5 files changed, 75 insertions(+), 1 deletion(-) > >diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm >index 3d677b8e01..18d37cd7fd 100644 >--- a/C4/Utils/DataTables/Members.pm >+++ b/C4/Utils/DataTables/Members.pm >@@ -11,6 +11,8 @@ sub search { > my $firstletter = $params->{firstletter}; > my $categorycode = $params->{categorycode}; > my $branchcode = $params->{branchcode}; >+ my $sort1 = $params->{sort1}; >+ my $sort2 = $params->{sort2}; > my $searchtype = $params->{searchtype} || 'contain'; > my $searchfieldstype = $params->{searchfieldstype} || 'standard'; > my $has_permission = $params->{has_permission}; >@@ -111,6 +113,14 @@ sub search { > push @where_strs, "borrowers.branchcode IN (" . join( ',', ('?') x @restricted_branchcodes ) . ")"; > push @where_args, @restricted_branchcodes; > } >+ if(defined $sort1 and $sort1 ne '') { >+ push @where_strs, "borrowers.sort1 = ?"; >+ push @where_args, $sort1; >+ } >+ if(defined $sort2 and $sort2 ne '') { >+ push @where_strs, "borrowers.sort2 = ?"; >+ push @where_args, $sort2; >+ } > > my $searchfields = { > standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid', >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt >index 9009d7a187..d6a128f6c3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt >@@ -42,6 +42,24 @@ > [% END %] > </select> > </li> >+ <li> >+ <label for="sort1_filter">Sort1:</label> >+ <select id="sort1_filter"> >+ <option value="">Any</option> >+ [% FOREACH sor IN sort1 %] >+ <option value="[% sor | html %]">[% sor | html %]</option> >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="sort2_filter">Sort2:</label> >+ <select id="sort2_filter"> >+ <option value="">Any</option> >+ [% FOREACH sor IN sort2 %] >+ <option value="[% sor | html %]">[% sor | html %]</option> >+ [% END %] >+ </select> >+ </li> > </ol> > <fieldset class="action"> > <input type="submit" value="Search" /> >@@ -69,11 +87,21 @@ > > <input type="hidden" id="firstletter_filter" value="" /> > <div id="searchresults"> >+ <div class="searchheader fh-fixedHeader" id="searchheader"> >+ <div> >+ <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a> >+ | >+ <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a> >+ | >+ <a href="#" class="btn btn-default btn-xs" id="add-selected">Add selected patrons</a> >+ </div> >+ </div> > <table id="memberresultst"> > <thead> > <tr> > [% FOR column IN columns %] > [% SWITCH column %] >+ [% CASE 'select' %]<th> </th> > [% CASE 'cardnumber' %]<th>Card</th> > [% CASE 'dateofbirth' %]<th>Date of birth</th> > [% CASE 'address' %]<th>Address</th> >@@ -150,6 +178,12 @@ > },{ > 'name': 'branchcode', > 'value': $("#branchcode_filter").val() >+ },{ >+ 'name': 'sort1', >+ 'value': $("#sort1_filter").val() >+ },{ >+ 'name': 'sort2', >+ 'value': $("#sort2_filter").val() > },{ > 'name': 'name_sorton', > 'value': 'borrowers.surname borrowers.firstname' >@@ -204,6 +238,8 @@ > [% FOR column IN columns %] > [% IF column == 'action' %] > { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' } >+ [% ELSIF column == 'select' %] >+ { 'mDataProp': 'dt_select', 'bSortable': false, 'sClass': 'selections' } > [% ELSIF column == 'address' %] > { 'mDataProp': 'dt_address', 'bSortable': false } > [% ELSE %] >@@ -225,6 +261,22 @@ > e.preventDefault(); > filterByFirstLetterSurname($(this).text()); > }); >+ $("#select_all").on("click",function(e){ >+ e.preventDefault(); >+ $("#searchresults .selection").prop("checked", true).change(); >+ }); >+ $("#clear_all").on("click",function(e){ >+ e.preventDefault(); >+ $("#searchresults .selection").prop("checked", false).change(); >+ }); >+ $("#add-selected").on('click', function(e){ >+ $("#searchresults .selection:checked").each(function(){ >+ var borrowernumber = $(this).data("borrowernumber"); >+ var firstname = $(this).data("firstname"); >+ var surname = $(this).data("surname"); >+ add_user( borrowernumber, firstname + " " + surname ); >+ }); >+ }); > $("body").on("click",".add_user",function(e){ > e.preventDefault(); > var borrowernumber = $(this).data("borrowernumber"); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/tables/members_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/tables/members_results.tt >index f4af6752af..9bb18308c8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/tables/members_results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/tables/members_results.tt >@@ -6,6 +6,8 @@ > "aaData": [ > [% FOREACH data IN aaData %] > { >+ "dt_select": >+ "<input type=\"checkbox\" class=\"selection\" data-borrowernumber=\"[% data.borrowernumber | html %]\" data-firstname=\"[% data.firstname | html %]\" data-surname=\"[% data.surname | html %]\">", > "dt_cardnumber": > "[% data.cardnumber | html %]", > "dt_name": >diff --git a/patroncards/add_user_search.pl b/patroncards/add_user_search.pl >index 04bc0eb5b3..e40c2852a2 100755 >--- a/patroncards/add_user_search.pl >+++ b/patroncards/add_user_search.pl >@@ -20,6 +20,7 @@ > use Modern::Perl; > > use CGI qw ( -utf8 ); >+use List::MoreUtils qw(uniq); > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Members; >@@ -44,13 +45,18 @@ my $op = $input->param('op') || ''; > my $referer = $input->referer(); > > my $patron_categories = Koha::Patron::Categories->search_with_library_limits; >+my $sort_filter = { ( C4::Context->only_my_library ? (branchcode => C4::Context->userenv->{branch}) : () ) }; >+my @sort1 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort1') ); >+my @sort2 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort2') ); > $template->param( > view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", >- columns => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'], >+ columns => ['select', 'cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'], > json_template => 'patroncards/tables/members_results.tt', > selection_type => 'add', > alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ), > categories => $patron_categories, >+ sort1 => \@sort1, >+ sort2 => \@sort2, > aaSorting => 1, > ); > output_html_with_http_headers( $input, $cookie, $template->output ); >diff --git a/svc/members/search b/svc/members/search >index 7cad0e8ab0..005a788f64 100755 >--- a/svc/members/search >+++ b/svc/members/search >@@ -42,6 +42,8 @@ my $searchmember = $input->param('searchmember'); > my $firstletter = $input->param('firstletter'); > my $categorycode = $input->param('categorycode'); > my $branchcode = $input->param('branchcode'); >+my $sort1 = $input->param('sort1'); >+my $sort2 = $input->param('sort2'); > my $searchtype = $input->param('searchtype'); > my $searchfieldstype = $input->param('searchfieldstype') || 'standard'; > my $has_permission = $input->param('has_permission'); >@@ -83,6 +85,8 @@ $results = C4::Utils::DataTables::Members::search( > firstletter => $firstletter, > categorycode => $categorycode, > branchcode => $branchcode, >+ sort1 => $sort1, >+ sort2 => $sort2, > searchtype => $searchtype, > searchfieldstype => $searchfieldstype, > dt_params => \%dt_params, >-- >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