View | Details | Raw Unified | Return to bug 7380
Collapse All | Expand All

(-)a/Koha/Template/Plugin/Branches.pm (+30 lines)
Lines 1-6 Link Here
1
package Koha::Template::Plugin::Branches;
1
package Koha::Template::Plugin::Branches;
2
2
3
# Copyright ByWater Solutions 2012
3
# Copyright ByWater Solutions 2012
4
# Copyright BibLibre 2014
4
5
5
# This file is part of Koha.
6
# This file is part of Koha.
6
#
7
#
Lines 53-56 sub GetURL { Link Here
53
    return $b->{branchurl};
54
    return $b->{branchurl};
54
}
55
}
55
56
57
sub all {
58
    my ( $self, $params ) = @_;
59
    my $selected = $params->{selected};
60
    my $dbh = C4::Context->dbh;
61
    my @params;
62
    my $query = q|
63
        SELECT branchcode, branchname
64
        FROM branches
65
    |;
66
    if (    C4::Branch::onlymine
67
        and C4::Context->userenv
68
        and C4::Context->userenv->{branch} )
69
    {
70
        $query .= q| WHERE branchcode = ? |;
71
        push @params, C4::Context->userenv->{branch};
72
    }
73
    $query .= q| ORDER BY branchname|;
74
    my $branches = $dbh->selectall_arrayref( $query, { Slice => {} }, @params );
75
76
    if ( $selected ) {
77
        for my $branch ( @$branches ) {
78
            if ( $branch->{branchcode} eq $selected ) {
79
                $branch->{selected} = 1;
80
            }
81
        }
82
    }
83
    return $branches;
84
}
85
56
1;
86
1;
(-)a/Koha/Template/Plugin/Categories.pm (+63 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Categories;
2
3
# Copyright 2013-2014 BibLibre
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Template::Plugin;
21
use base qw( Template::Plugin );
22
23
use C4::Category;
24
25
sub all {
26
    my ( $self, $params ) = @_;
27
    my $selected = $params->{selected};
28
29
    my @categories = C4::Category->all;
30
    if ( $selected ) {
31
        for my $category ( @categories ) {
32
            if ( $category->{categorycode} eq $selected ) {
33
                $category->{selected} = 1;
34
            }
35
        }
36
    }
37
    return @categories;
38
}
39
40
1;
41
42
=head1 NAME
43
44
Koha::Template::Plugin::Categories - TT Plugin for categories
45
46
=head1 SYNOPSIS
47
48
[% USE Categories %]
49
50
[% Categories.all() %]
51
52
=head1 ROUTINES
53
54
=head2 all
55
56
In a template, you can get the all categories with
57
the following TT code: [% Categories.all() %]
58
59
=head1 AUTHOR
60
61
Jonathan Druart <jonathan.druart@biblibre.com>
62
63
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-22 / +32 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Branches %]
3
[% USE Categories %]
2
<div class="gradient">
4
<div class="gradient">
3
<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Patrons Resident Search Box -->
5
<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Patrons Resident Search Box -->
4
<div id="header_search">
6
<div id="header_search">
Lines 71-99 Link Here
71
            </select>
73
            </select>
72
        </p>
74
        </p>
73
75
76
        <p>
77
            <label for="branchcode">Library: </label>
78
            [% SET branches = Branches.all( selected => branchcode ) %]
79
            <select name="branchcode" id="branchcode">
80
                [% IF branches.size != 1 %]
81
                  <option value="">Any</option>
82
                [% END %]
83
                [% FOREACH b IN branches %]
84
                    [% IF b.selected %]
85
                        <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
86
                    [% ELSE %]
87
                        <option value="[% b.branchcode %]">[% b.branchname %]</option>
88
                    [% END %]
89
                [% END %]
90
            </select>
91
        </p>
74
92
75
        [% IF ( branchloop ) %]
93
        <p>
76
        <p> <label for="branchcode">Library: </label>
94
            <label for="categorycode">Category: </label>
77
        <select name="branchcode" id="branchcode">
95
            [% SET categories = Categories.all( selected => categorycode ) %]
78
            [% IF branchloop.size != 1 %]
96
            <select name="categorycode" id="categorycode">
79
              <option value="">Any</option>
97
                <option value="">Any</option>
80
            [% END %]
98
                [% FOREACH categorie IN categories %]
81
            [% FOREACH branchloo IN branchloop %]
99
                    [% IF ( categorie.selected ) %]
82
            [% IF ( branchloo.selected ) %]
100
                        <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description %]</option>
83
            <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]
101
                    [% ELSE %]
84
            <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
102
                        <option value="[% categorie.categorycode %]">[% categorie.description %]</option>
85
          [% END %]</select>
103
                    [% END %]
86
        [% END %]
104
                [% END %]
87
        [% IF ( categories ) %]
105
            </select>
88
            <p>
106
        </p>
89
            <label for="categorycode">Category: </label><select name="categorycode" id="categorycode">
90
            <option value="">Any</option>[% FOREACH categorie IN categories %]
91
            [% IF ( categorie.selected ) %]
92
            <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description %]</option>[% ELSE %]
93
            <option value="[% categorie.categorycode %]">[% categorie.description %]</option>[% END %]
94
          [% END %]</select>
95
            </p>
96
        [% END %]
97
    </div>
107
    </div>
98
    </form>
108
    </form>
99
</div>
109
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-4 / +8 lines)
Lines 1-5 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE ColumnsSettings %]
2
[% USE ColumnsSettings %]
3
[% USE Branches %]
4
[% USE Categories %]
3
[% INCLUDE 'doc-head-open.inc' %]
5
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
6
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
5
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'doc-head-close.inc' %]
Lines 452-475 function filterByFirstLetterSurname(letter) { Link Here
452
            </li>
454
            </li>
453
            <li>
455
            <li>
454
              <label for="categorycode_filter">Category:</label>
456
              <label for="categorycode_filter">Category:</label>
457
              [% SET categories = Categories.all( selected => categorycode ) %]
455
              <select id="categorycode_filter">
458
              <select id="categorycode_filter">
456
                <option value="">Any</option>
459
                <option value="">Any</option>
457
                [% FOREACH cat IN categories %]
460
                [% FOREACH cat IN categories %]
458
                  [% IF cat.selected %]
461
                  [% IF cat.selected %]
459
                    <option selected="selected" value="[% cat.categorycode %]">[% cat.description | html_entity %]</option>
462
                    <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
460
                  [% ELSE %]
463
                  [% ELSE %]
461
                    <option value="[% cat.categorycode %]">[% cat.description | html_entity %]</option>
464
                    <option value="[% cat.categorycode %]">[% cat.description %]</option>
462
                  [% END %]
465
                  [% END %]
463
                [% END %]
466
                [% END %]
464
              </select>
467
              </select>
465
            </li>
468
            </li>
466
            <li>
469
            <li>
467
              <label for="branchcode_filter">Library:</label>
470
              <label for="branchcode_filter">Library:</label>
471
              [% SET branches = Branches.all( selected => branchcode ) %]
468
              <select id="branchcode_filter">
472
              <select id="branchcode_filter">
469
                [% IF branchloop.size != 1 %]
473
                [% IF branches.size != 1 %]
470
                  <option value="">Any</option>
474
                  <option value="">Any</option>
471
                [% END %]
475
                [% END %]
472
                [% FOREACH b IN branchloop %]
476
                [% FOREACH b IN branches %]
473
                  [% IF b.selected %]
477
                  [% IF b.selected %]
474
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
478
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
475
                  [% ELSE %]
479
                  [% ELSE %]
(-)a/members/member.pl (-34 lines)
Lines 75-111 if ( $searchfieldstype eq "dateofbirth" ) { Link Here
75
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
75
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
76
}
76
}
77
77
78
my $branches = C4::Branch::GetBranches;
79
my @branches_loop;
80
if ( C4::Branch::onlymine ) {
81
    my $userenv = C4::Context->userenv;
82
    my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
83
    push @branches_loop, {
84
        value => $branch->{branchcode},
85
        branchcode => $branch->{branchcode},
86
        branchname => $branch->{branchname},
87
        selected => 1
88
    }
89
} else {
90
    foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) {
91
        my $selected = 0;
92
        $selected = 1 if($patron->{branchcode} and $patron->{branchcode} eq $_);
93
        push @branches_loop, {
94
            value => $_,
95
            branchcode => $_,
96
            branchname => $branches->{$_}->{branchname},
97
            selected => $selected
98
        };
99
    }
100
}
101
102
my @categories = C4::Category->all;
103
if ( $patron->{categorycode} ) {
104
    foreach my $category ( grep { $_->{categorycode} eq $patron->{categorycode} } @categories ) {
105
        $category->{selected} = 1;
106
    }
107
}
108
109
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
78
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
110
79
111
my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
80
my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
Lines 113-120 my $view = $input->request_method() eq "GET" ? "show_form" : "show_results"; Link Here
113
$template->param(
82
$template->param(
114
    patron_lists => [ GetPatronLists() ],
83
    patron_lists => [ GetPatronLists() ],
115
    searchmember        => $searchmember,
84
    searchmember        => $searchmember,
116
    branchloop          => \@branches_loop,
117
    categories          => \@categories,
118
    branchcode          => $patron->{branchcode},
85
    branchcode          => $patron->{branchcode},
119
    categorycode        => $patron->{categorycode},
86
    categorycode        => $patron->{categorycode},
120
    searchtype          => $input->param('searchtype') || 'start_with',
87
    searchtype          => $input->param('searchtype') || 'start_with',
121
- 

Return to bug 7380