Bugzilla – Attachment 38055 Details for
Bug 7380
Can't filter patron search on detail page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7380: Refactor the patron search box header
Bug-7380-Refactor-the-patron-search-box-header.patch (text/plain), 11.81 KB, created by
Nicole C. Engard
on 2015-04-17 13:16:00 UTC
(
hide
)
Description:
Bug 7380: Refactor the patron search box header
Filename:
MIME Type:
Creator:
Nicole C. Engard
Created:
2015-04-17 13:16:00 UTC
Size:
11.81 KB
patch
obsolete
>From 850993aff05371c10a5467102b6a4341aa21ca7d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 15 Jul 2014 12:44:23 +0200 >Subject: [PATCH] Bug 7380: Refactor the patron search box header >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >A lot of page uses the patron search box header include (git grep >patron-search.inc for the list) and the branch and category lists are >not generated for all of them. > >For instance, on a patron detail page, there is a [+] link, but nothing >append on clicking on it. > >This patch add a new template plugin "Categories" to get all patron >categories from the templates. > >Test plan: >1/ Verify the [+] is working on all patron page (if that works for 2, >that should work for all). >2/ Launch a search from the header box and verify the library and >category dropdown lists select the correct value. >3/ Launch a search on the patron search page (patron home) and verify >the search is working correctly on selecting a category and/or a library > >Followed test plan. Works as expected. >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Nicole Engard <nengard@bywatersolutions.com> >--- > Koha/Template/Plugin/Branches.pm | 30 ++++++++++ > Koha/Template/Plugin/Categories.pm | 63 ++++++++++++++++++++ > .../prog/en/includes/patron-search.inc | 54 ++++++++++------- > .../prog/en/modules/members/member.tt | 12 ++-- > members/member.pl | 33 ---------- > 5 files changed, 133 insertions(+), 59 deletions(-) > create mode 100644 Koha/Template/Plugin/Categories.pm > >diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm >index 92db535..db01679 100644 >--- a/Koha/Template/Plugin/Branches.pm >+++ b/Koha/Template/Plugin/Branches.pm >@@ -1,6 +1,7 @@ > package Koha::Template::Plugin::Branches; > > # Copyright ByWater Solutions 2012 >+# Copyright BibLibre 2014 > > # This file is part of Koha. > # >@@ -53,4 +54,33 @@ sub GetURL { > return $b->{branchurl}; > } > >+sub all { >+ my ( $self, $params ) = @_; >+ my $selected = $params->{selected}; >+ my $dbh = C4::Context->dbh; >+ my @params; >+ my $query = q| >+ SELECT branchcode, branchname >+ FROM branches >+ |; >+ if ( C4::Branch::onlymine >+ and C4::Context->userenv >+ and C4::Context->userenv->{branch} ) >+ { >+ $query .= q| WHERE branchcode = ? |; >+ push @params, C4::Context->userenv->{branch}; >+ } >+ $query .= q| ORDER BY branchname|; >+ my $branches = $dbh->selectall_arrayref( $query, { Slice => {} }, @params ); >+ >+ if ( $selected ) { >+ for my $branch ( @$branches ) { >+ if ( $branch->{branchcode} eq $selected ) { >+ $branch->{selected} = 1; >+ } >+ } >+ } >+ return $branches; >+} >+ > 1; >diff --git a/Koha/Template/Plugin/Categories.pm b/Koha/Template/Plugin/Categories.pm >new file mode 100644 >index 0000000..86630ca >--- /dev/null >+++ b/Koha/Template/Plugin/Categories.pm >@@ -0,0 +1,63 @@ >+package Koha::Template::Plugin::Categories; >+ >+# Copyright 2013-2014 BibLibre >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use C4::Category; >+ >+sub all { >+ my ( $self, $params ) = @_; >+ my $selected = $params->{selected}; >+ >+ my @categories = C4::Category->all; >+ if ( $selected ) { >+ for my $category ( @categories ) { >+ if ( $category->{categorycode} eq $selected ) { >+ $category->{selected} = 1; >+ } >+ } >+ } >+ return @categories; >+} >+ >+1; >+ >+=head1 NAME >+ >+Koha::Template::Plugin::Categories - TT Plugin for categories >+ >+=head1 SYNOPSIS >+ >+[% USE Categories %] >+ >+[% Categories.all() %] >+ >+=head1 ROUTINES >+ >+=head2 all >+ >+In a template, you can get the all categories with >+the following TT code: [% Categories.all() %] >+ >+=head1 AUTHOR >+ >+Jonathan Druart <jonathan.druart@biblibre.com> >+ >+=cut >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 7739cc3..7723e3a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -1,4 +1,6 @@ > [% USE Koha %] >+[% USE Branches %] >+[% USE Categories %] > <div class="gradient"> > <h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Patrons Resident Search Box --> > <div id="header_search"> >@@ -71,29 +73,37 @@ > </select> > </p> > >+ <p> >+ <label for="branchcode">Library: </label> >+ [% SET branches = Branches.all( selected => branchcode ) %] >+ <select name="branchcode" id="branchcode"> >+ [% IF branches.size != 1 %] >+ <option value="">Any</option> >+ [% END %] >+ [% FOREACH b IN branches %] >+ [% IF b.selected %] >+ <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option> >+ [% ELSE %] >+ <option value="[% b.branchcode %]">[% b.branchname %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </p> > >- [% IF ( branchloop ) %] >- <p> <label for="branchcode">Library: </label> >- <select name="branchcode" id="branchcode"> >- [% IF branchloop.size != 1 %] >- <option value="">Any</option> >- [% END %] >- [% FOREACH branchloo IN branchloop %] >- [% IF ( branchloo.selected ) %] >- <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %] >- <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %] >- [% END %]</select> >- [% END %] >- [% IF ( categories ) %] >- <p> >- <label for="categorycode">Category: </label><select name="categorycode" id="categorycode"> >- <option value="">Any</option>[% FOREACH categorie IN categories %] >- [% IF ( categorie.selected ) %] >- <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description %]</option>[% ELSE %] >- <option value="[% categorie.categorycode %]">[% categorie.description %]</option>[% END %] >- [% END %]</select> >- </p> >- [% END %] >+ <p> >+ <label for="categorycode">Category: </label> >+ [% SET categories = Categories.all( selected => categorycode ) %] >+ <select name="categorycode" id="categorycode"> >+ <option value="">Any</option> >+ [% FOREACH categorie IN categories %] >+ [% IF ( categorie.selected ) %] >+ <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description %]</option> >+ [% ELSE %] >+ <option value="[% categorie.categorycode %]">[% categorie.description %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </p> > </div> > </form> > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >index 7ecf271..cd2608b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >@@ -1,5 +1,7 @@ > [% USE Koha %] > [% USE ColumnsSettings %] >+[% USE Branches %] >+[% USE Categories %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Patrons [% IF ( searching ) %]› Search results[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -452,24 +454,26 @@ function filterByFirstLetterSurname(letter) { > </li> > <li> > <label for="categorycode_filter">Category:</label> >+ [% SET categories = Categories.all( selected => categorycode ) %] > <select id="categorycode_filter"> > <option value="">Any</option> > [% FOREACH cat IN categories %] > [% IF cat.selected %] >- <option selected="selected" value="[% cat.categorycode %]">[% cat.description | html_entity %]</option> >+ <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option> > [% ELSE %] >- <option value="[% cat.categorycode %]">[% cat.description | html_entity %]</option> >+ <option value="[% cat.categorycode %]">[% cat.description %]</option> > [% END %] > [% END %] > </select> > </li> > <li> > <label for="branchcode_filter">Library:</label> >+ [% SET branches = Branches.all( selected => branchcode ) %] > <select id="branchcode_filter"> >- [% IF branchloop.size != 1 %] >+ [% IF branches.size != 1 %] > <option value="">Any</option> > [% END %] >- [% FOREACH b IN branchloop %] >+ [% FOREACH b IN branches %] > [% IF b.selected %] > <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option> > [% ELSE %] >diff --git a/members/member.pl b/members/member.pl >index 191ff44..03fcc8f 100755 >--- a/members/member.pl >+++ b/members/member.pl >@@ -75,37 +75,6 @@ if ( $searchfieldstype eq "dateofbirth" ) { > $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1}); > } > >-my $branches = C4::Branch::GetBranches; >-my @branches_loop; >-if ( C4::Branch::onlymine ) { >- my $userenv = C4::Context->userenv; >- my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} ); >- push @branches_loop, { >- value => $branch->{branchcode}, >- branchcode => $branch->{branchcode}, >- branchname => $branch->{branchname}, >- selected => 1 >- } >-} else { >- foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) { >- my $selected = 0; >- $selected = 1 if($patron->{branchcode} and $patron->{branchcode} eq $_); >- push @branches_loop, { >- value => $_, >- branchcode => $_, >- branchname => $branches->{$_}->{branchname}, >- selected => $selected >- }; >- } >-} >- >-my @categories = C4::Category->all; >-if ( $patron->{categorycode} ) { >- foreach my $category ( grep { $_->{categorycode} eq $patron->{categorycode} } @categories ) { >- $category->{selected} = 1; >- } >-} >- > $template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ); > > my $view = $input->request_method() eq "GET" ? "show_form" : "show_results"; >@@ -113,8 +82,6 @@ my $view = $input->request_method() eq "GET" ? "show_form" : "show_results"; > $template->param( > patron_lists => [ GetPatronLists() ], > searchmember => $searchmember, >- branchloop => \@branches_loop, >- categories => \@categories, > branchcode => $patron->{branchcode}, > categorycode => $patron->{categorycode}, > searchtype => $input->param('searchtype') || 'start_with', >-- >1.7.10.4
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 7380
:
29697
|
33157
|
35222
|
35259
|
35342
|
37805
|
37806
|
38053
|
38055
|
38056
|
38067
|
38068
|
38090
|
38107
|
38108