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 (-18 / +30 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 85-109 Link Here
85
      </select>
87
      </select>
86
88
87
    <input value="Search" class="submit" type="submit" />
89
    <input value="Search" class="submit" type="submit" />
88
    [% IF ( branchloop ) %]
90
    <p id="filters">
89
    <p id="filters"> <label for="branchcode">Library: </label>
91
        <label for="branchcode">Library: </label>
90
    <select name="branchcode" id="branchcode">
92
        [% SET branches = Branches.all( selected => branchcode ) %]
91
        [% IF branchloop.size != 1 %]
93
        <select name="branchcode" id="branchcode">
92
          <option value="">Any</option>
94
            [% IF branches.size != 1 %]
93
        [% END %]
95
              <option value="">Any</option>
94
        [% FOREACH branchloo IN branchloop %]
96
            [% END %]
95
        [% IF ( branchloo.selected ) %]
97
            [% FOREACH b IN branches %]
96
        <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]
98
                [% IF b.selected %]
97
        <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
99
                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
98
      [% END %]</select>
100
                [% ELSE %]
99
                 <label for="categorycode">Category: </label><select name="categorycode" id="categorycode">
101
                    <option value="[% b.branchcode %]">[% b.branchname %]</option>
100
        <option value="">Any</option>[% FOREACH categorie IN categories %]
102
                [% END %]
101
        [% IF ( categorie.selected ) %]
103
            [% END %]
102
        <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description %]</option>[% ELSE %]
104
        </select>
103
        <option value="[% categorie.categorycode %]">[% categorie.description %]</option>[% END %]
105
104
      [% END %]</select>
106
        <label for="categorycode">Category: </label>
107
        [% SET categories = Categories.all( selected => categorycode ) %]
108
        <select name="categorycode" id="categorycode">
109
            <option value="">Any</option>
110
            [% FOREACH categorie IN categories %]
111
                [% IF ( categorie.selected ) %]
112
                    <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description %]</option>
113
                [% ELSE %]
114
                    <option value="[% categorie.categorycode %]">[% categorie.description %]</option>
115
                [% END %]
116
            [% END %]
117
        </select>
105
    </p>
118
    </p>
106
    [% END %]
107
</form>
119
</form>
108
	</div>
120
	</div>
109
121
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-4 / +8 lines)
Lines 1-3 Link Here
1
[% USE Branches %]
2
[% USE Categories %]
1
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
4
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 443-466 function filterByFirstLetterSurname(letter) { Link Here
443
            </li>
445
            </li>
444
            <li>
446
            <li>
445
              <label for="categorycode_filter">Category:</label>
447
              <label for="categorycode_filter">Category:</label>
448
              [% SET categories = Categories.all( selected => categorycode ) %]
446
              <select id="categorycode_filter">
449
              <select id="categorycode_filter">
447
                <option value="">Any</option>
450
                <option value="">Any</option>
448
                [% FOREACH cat IN categories %]
451
                [% FOREACH cat IN categories %]
449
                  [% IF cat.selected %]
452
                  [% IF cat.selected %]
450
                    <option selected="selected" value="[% cat.categorycode %]">[% cat.description | html_entity %]</option>
453
                    <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
451
                  [% ELSE %]
454
                  [% ELSE %]
452
                    <option value="[% cat.categorycode %]">[% cat.description | html_entity %]</option>
455
                    <option value="[% cat.categorycode %]">[% cat.description %]</option>
453
                  [% END %]
456
                  [% END %]
454
                [% END %]
457
                [% END %]
455
              </select>
458
              </select>
456
            </li>
459
            </li>
457
            <li>
460
            <li>
458
              <label for="branchcode_filter">Library:</label>
461
              <label for="branchcode_filter">Library:</label>
462
              [% SET branches = Branches.all( selected => branchcode ) %]
459
              <select id="branchcode_filter">
463
              <select id="branchcode_filter">
460
                [% IF branchloop.size != 1 %]
464
                [% IF branches.size != 1 %]
461
                  <option value="">Any</option>
465
                  <option value="">Any</option>
462
                [% END %]
466
                [% END %]
463
                [% FOREACH b IN branchloop %]
467
                [% FOREACH b IN branches %]
464
                  [% IF b.selected %]
468
                  [% IF b.selected %]
465
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
469
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
466
                  [% ELSE %]
470
                  [% ELSE %]
(-)a/members/member.pl (-33 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',
(-)a/members/moremember.pl (-1 / +29 lines)
Lines 298-304 $template->param( picture => 1 ) if $picture; Link Here
298
298
299
my $branch=C4::Context->userenv->{'branch'};
299
my $branch=C4::Context->userenv->{'branch'};
300
300
301
302
my $branches = C4::Branch::GetBranches;
303
my @branches_loop;
304
if ( C4::Branch::onlymine ) {
305
    my $userenv = C4::Context->userenv;
306
    my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
307
    push @branches_loop, {
308
        value => $branch->{branchcode},
309
        branchcode => $branch->{branchcode},
310
        branchname => $branch->{branchname},
311
        selected => 1
312
    }
313
} else {
314
    foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) {
315
        my $selected = 0;
316
        $selected = 1 if($data->{branchcode} and $data->{branchcode} eq $_);
317
        push @branches_loop, {
318
            value => $_,
319
            branchcode => $_,
320
            branchname => $branches->{$_}->{branchname},
321
            selected => $selected
322
        };
323
    }
324
}
325
301
$template->param(%$data);
326
$template->param(%$data);
327
$template->param(
328
    branchloop          => \@branches_loop,
329
    categories => [ C4::Category->all ],
330
);
302
331
303
if (C4::Context->preference('ExtendedPatronAttributes')) {
332
if (C4::Context->preference('ExtendedPatronAttributes')) {
304
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
333
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
305
- 

Return to bug 7380