Bug 28591: Don't pass debug to get_template_and_user
[koha.git] / members / holdshistory.pl
1 #!/usr/bin/perl
2 #
3 # This file is part of Koha.
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 CGI qw ( -utf8 );
21
22 use C4::Auth;
23 use C4::Output;
24
25 use Koha::Patrons;
26
27 my $input = CGI->new;
28
29 my $borrowernumber;
30 my $cardnumber;
31 my @all_holds;
32
33 my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "members/holdshistory.tt",
34                 query => $input,
35                 type => "intranet",
36                 flagsrequired => {borrowers => 'edit_borrowers'},
37                 });
38
39 my $patron;
40
41 if ($input->param('cardnumber')) {
42     $cardnumber = $input->param('cardnumber');
43     $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
44 }
45 if ($input->param('borrowernumber')) {
46     $borrowernumber = $input->param('borrowernumber');
47     $patron = Koha::Patrons->find( $borrowernumber );
48 }
49
50 unless ( $patron ) {
51     print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
52     exit;
53 }
54
55 my $holds;
56 my $old_holds;
57
58 if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){
59     # use of 'eq' in the above comparison is intentional -- the
60     # system preference value could be blank
61     $template->param( is_anonymous => 1 );
62 } else {
63     $holds = $patron->holds;
64     $old_holds = $patron->old_holds;
65
66     while (my $hold = $holds->next) {
67         push @all_holds, $hold;
68     }
69
70     while (my $hold = $old_holds->next) {
71         push @all_holds, $hold;
72     }
73 }
74
75 $template->param(
76     holdshistoryview => 1,
77     patron           => $patron,
78     holds            => \@all_holds,
79 );
80
81 output_html_with_http_headers $input, $cookie, $template->output;