Bug 18915: Renaming svc/patron_notes to svc/checkout_notes
[koha.git] / members / holdshistory.pl
blob06d0d1efde4ba74b6d2359ce1068795c5b924109
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 authnotrequired => 0,
37 flagsrequired => {borrowers => 1},
38 debug => 1,
39 });
41 my $patron;
43 if ($input->param('cardnumber')) {
44 $cardnumber = $input->param('cardnumber');
45 $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
47 if ($input->param('borrowernumber')) {
48 $borrowernumber = $input->param('borrowernumber');
49 $patron = Koha::Patrons->find( $borrowernumber );
52 unless ( $patron ) {
53 print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
54 exit;
57 my $holds;
58 my $old_holds;
60 if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ){
61 # use of 'eq' in the above comparison is intentional -- the
62 # system preference value could be blank
63 $template->param( is_anonymous => 1 );
64 } else {
65 $holds = $patron->holds;
66 $old_holds = $patron->old_holds;
68 while (my $hold = $holds->next) {
69 push @all_holds, $hold;
72 while (my $hold = $old_holds->next) {
73 push @all_holds, $hold;
77 if ( $patron->category->category_type eq 'C') {
78 my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
79 $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
80 $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1;
83 $template->param( adultborrower => 1 ) if ( $patron->category->category_type eq 'A' || $patron->category->category_type eq 'I' );
85 $template->param( picture => 1 ) if $patron->image;
87 $template->param(%{ $patron->unblessed });
89 $template->param(
90 holdshistoryview => 1,
91 borrowernumber => $borrowernumber,
92 patron => $patron,
93 holds => \@all_holds,
96 output_html_with_http_headers $input, $cookie, $template->output;