Merge branch 'new/bug_6479' into kcmaster
[koha.git] / members / members-home.pl
blob830800e0ab7d7b517493a90f7f04b6f06e94be2b
1 #!/usr/bin/perl
3 # Parts Copyright Biblibre 2010
4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
9 # version.
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with Koha; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 use strict;
20 use warnings;
22 use CGI;
23 use C4::Auth;
24 use C4::Output;
25 use C4::Context;
26 use C4::Members;
27 use C4::Branch;
28 use C4::Category;
30 my $query = new CGI;
31 my $branch = $query->param('branchcode');
32 my $template_name;
34 $branch = q{} unless defined $branch;
36 my ($template, $loggedinuser, $cookie)
37 = get_template_and_user({template_name => "members/member.tmpl",
38 query => $query,
39 type => "intranet",
40 authnotrequired => 0,
41 flagsrequired => {borrowers => 1},
42 debug => 1,
43 });
45 my $branches = GetBranches;
46 my @branchloop;
47 foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
48 push @branchloop, {
49 value => $_,
50 selected => ($branches->{$_}->{branchcode} eq $branch),
51 branchname => $branches->{$_}->{branchname},
55 my @categories;
56 my $no_categories;
57 my $no_add = 0;
58 if(scalar(@branchloop) < 1){
59 $no_add = 1;
60 $template->param(no_branches => 1);
62 else {
63 $template->param(branchloop=>\@branchloop);
66 @categories=C4::Category->all;
67 if(scalar(@categories) < 1){
68 $no_categories = 1;
71 if($no_categories && C4::Context->preference("AddPatronLists")=~/code/){
72 $no_add = 1;
73 $template->param(no_categories => 1);
75 else {
76 $template->param(categories=>\@categories);
79 $template->param(
80 "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
81 no_add => $no_add,
83 my @letters = map { {letter => $_} } ( 'A' .. 'Z');
84 $template->param( letters => \@letters );
86 output_html_with_http_headers $query, $cookie, $template->output;