Bug 24665: (QA follow-up) Fix selection default
[koha.git] / members / holdshistory.pl
blob2b2db160d21961554f0578d9072c7e7d273ff6ad
1 #!/usr/bin/perl
3 # This file is part of Koha.
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.
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.
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>.
18 use Modern::Perl;
20 use CGI qw ( -utf8 );
22 use C4::Auth;
23 use C4::Output;
25 use Koha::Patrons;
27 my $input = CGI->new;
29 my $borrowernumber;
30 my $cardnumber;
31 my @all_holds;
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 debug => 1,
38 });
40 my $patron;
42 if ($input->param('cardnumber')) {
43 $cardnumber = $input->param('cardnumber');
44 $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
46 if ($input->param('borrowernumber')) {
47 $borrowernumber = $input->param('borrowernumber');
48 $patron = Koha::Patrons->find( $borrowernumber );
51 unless ( $patron ) {
52 print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
53 exit;
56 my $holds;
57 my $old_holds;
59 if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){
60 # use of 'eq' in the above comparison is intentional -- the
61 # system preference value could be blank
62 $template->param( is_anonymous => 1 );
63 } else {
64 $holds = $patron->holds;
65 $old_holds = $patron->old_holds;
67 while (my $hold = $holds->next) {
68 push @all_holds, $hold;
71 while (my $hold = $old_holds->next) {
72 push @all_holds, $hold;
76 $template->param(
77 holdshistoryview => 1,
78 patron => $patron,
79 holds => \@all_holds,
82 output_html_with_http_headers $input, $cookie, $template->output;