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-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Branches %]
3
[% USE Categories %]
2
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
5
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
Lines 451-474 function filterByFirstLetterSurname(letter) { Link Here
451
            </li>
453
            </li>
452
            <li>
454
            <li>
453
              <label for="categorycode_filter">Category:</label>
455
              <label for="categorycode_filter">Category:</label>
456
              [% SET categories = Categories.all( selected => categorycode ) %]
454
              <select id="categorycode_filter">
457
              <select id="categorycode_filter">
455
                <option value="">Any</option>
458
                <option value="">Any</option>
456
                [% FOREACH cat IN categories %]
459
                [% FOREACH cat IN categories %]
457
                  [% IF cat.selected %]
460
                  [% IF cat.selected %]
458
                    <option selected="selected" value="[% cat.categorycode %]">[% cat.description | html_entity %]</option>
461
                    <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
459
                  [% ELSE %]
462
                  [% ELSE %]
460
                    <option value="[% cat.categorycode %]">[% cat.description | html_entity %]</option>
463
                    <option value="[% cat.categorycode %]">[% cat.description %]</option>
461
                  [% END %]
464
                  [% END %]
462
                [% END %]
465
                [% END %]
463
              </select>
466
              </select>
464
            </li>
467
            </li>
465
            <li>
468
            <li>
466
              <label for="branchcode_filter">Library:</label>
469
              <label for="branchcode_filter">Library:</label>
470
              [% SET branches = Branches.all( selected => branchcode ) %]
467
              <select id="branchcode_filter">
471
              <select id="branchcode_filter">
468
                [% IF branchloop.size != 1 %]
472
                [% IF branches.size != 1 %]
469
                  <option value="">Any</option>
473
                  <option value="">Any</option>
470
                [% END %]
474
                [% END %]
471
                [% FOREACH b IN branchloop %]
475
                [% FOREACH b IN branches %]
472
                  [% IF b.selected %]
476
                  [% IF b.selected %]
473
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
477
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
474
                  [% ELSE %]
478
                  [% 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 312-318 $template->param( picture => 1 ) if $picture; Link Here
312
312
313
my $branch=C4::Context->userenv->{'branch'};
313
my $branch=C4::Context->userenv->{'branch'};
314
314
315
316
my $branches = C4::Branch::GetBranches;
317
my @branches_loop;
318
if ( C4::Branch::onlymine ) {
319
    my $userenv = C4::Context->userenv;
320
    my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
321
    push @branches_loop, {
322
        value => $branch->{branchcode},
323
        branchcode => $branch->{branchcode},
324
        branchname => $branch->{branchname},
325
        selected => 1
326
    }
327
} else {
328
    foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) {
329
        my $selected = 0;
330
        $selected = 1 if($data->{branchcode} and $data->{branchcode} eq $_);
331
        push @branches_loop, {
332
            value => $_,
333
            branchcode => $_,
334
            branchname => $branches->{$_}->{branchname},
335
            selected => $selected
336
        };
337
    }
338
}
339
315
$template->param(%$data);
340
$template->param(%$data);
341
$template->param(
342
    branchloop          => \@branches_loop,
343
    categories => [ C4::Category->all ],
344
);
316
345
317
if (C4::Context->preference('ExtendedPatronAttributes')) {
346
if (C4::Context->preference('ExtendedPatronAttributes')) {
318
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
347
    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
319
- 

Return to bug 7380