Bug 5995 : MT2892: Fix security issue in CAS intranet login
[koha.git] / members / readingrec.pl
blobe7586a0debe4b020eb530538f064f046e1d59574
1 #!/usr/bin/perl
3 # written 27/01/2000
4 # script to display borrowers reading record
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 use strict;
24 use warnings;
26 use CGI;
28 use C4::Auth;
29 use C4::Output;
30 use C4::Members;
31 use C4::Branch;
32 use List::MoreUtils qw/any/;
34 use C4::Dates qw/format_date/;
36 my $input = CGI->new;
38 #get borrower details
39 my $data = undef;
40 my $borrowernumber = undef;
41 my $cardnumber = undef;
43 my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "members/readingrec.tmpl",
44 query => $input,
45 type => "intranet",
46 authnotrequired => 0,
47 flagsrequired => {borrowers => 1},
48 debug => 1,
49 });
51 if ($input->param('cardnumber')) {
52 $cardnumber = $input->param('cardnumber');
53 $data = GetMember(cardnumber => $cardnumber);
54 $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
56 if ($input->param('borrowernumber')) {
57 $borrowernumber = $input->param('borrowernumber');
58 $data = GetMember(borrowernumber => $borrowernumber);
61 my $order = 'date_due desc';
62 my $limit = 0;
63 my ( $issues ) = GetAllIssues($borrowernumber,$order,$limit);
65 my @loop_reading;
67 foreach my $issue (@{$issues}){
68 my %line;
69 $line{issuestimestamp} = format_date($issue->{'issuestimestamp'});
70 $line{biblionumber} = $issue->{'biblionumber'};
71 $line{title} = $issue->{'title'};
72 $line{author} = $issue->{'author'};
73 $line{classification} = $issue->{'classification'} || $issue->{'itemcallnumber'};
74 $line{date_due} = format_date($issue->{'date_due'});
75 $line{returndate} = format_date($issue->{'returndate'});
76 $line{issuedate} = format_date($issue->{'issuedate'});
77 $line{issuingbranch} = GetBranchName($issue->{'branchcode'});
78 $line{renewals} = $issue->{'renewals'};
79 $line{barcode} = $issue->{'barcode'};
80 $line{volumeddesc} = $issue->{'volumeddesc'};
81 push(@loop_reading,\%line);
84 if ( $data->{'category_type'} eq 'C') {
85 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
86 my $cnt = scalar(@$catcodes);
87 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
88 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
91 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
92 if (! $limit){
93 $limit = 'full';
96 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
97 $template->param( picture => 1 ) if $picture;
99 $template->param(
100 readingrecordview => 1,
101 biblionumber => $data->{'biblionumber'},
102 title => $data->{'title'},
103 initials => $data->{'initials'},
104 surname => $data->{'surname'},
105 borrowernumber => $borrowernumber,
106 limit => $limit,
107 firstname => $data->{'firstname'},
108 cardnumber => $data->{'cardnumber'},
109 categorycode => $data->{'categorycode'},
110 category_type => $data->{'category_type'},
111 # category_description => $data->{'description'},
112 categoryname => $data->{'description'},
113 address => $data->{'address'},
114 address2 => $data->{'address2'},
115 city => $data->{'city'},
116 state => $data->{'state'},
117 zipcode => $data->{'zipcode'},
118 country => $data->{'country'},
119 phone => $data->{'phone'},
120 email => $data->{'email'},
121 branchcode => $data->{'branchcode'},
122 is_child => ($data->{'category_type'} eq 'C'),
123 branchname => GetBranchName($data->{'branchcode'}),
124 showfulllink => (scalar @loop_reading > 50),
125 loop_reading => \@loop_reading);
126 output_html_with_http_headers $input, $cookie, $template->output;