Bug 25548: Remove Apache rewrite directives that trigger redirects
[koha.git] / members / readingrec.pl
blobd484e69bf8670b2cb3a243098f6fd67a36201884
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
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Modern::Perl;
25 use CGI qw ( -utf8 );
27 use C4::Auth;
28 use C4::Output;
29 use C4::Members;
30 use List::MoreUtils qw/any uniq/;
31 use Koha::DateUtils;
33 use Koha::Patrons;
34 use Koha::Patron::Categories;
36 my $input = CGI->new;
38 my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "members/readingrec.tt",
39 query => $input,
40 type => "intranet",
41 flagsrequired => {borrowers => 'edit_borrowers'},
42 debug => 1,
43 });
45 my $op = $input->param('op') || '';
46 my $patron;
47 if ($input->param('cardnumber')) {
48 my $cardnumber = $input->param('cardnumber');
49 $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
51 if ($input->param('borrowernumber')) {
52 my $borrowernumber = $input->param('borrowernumber');
53 $patron = Koha::Patrons->find( $borrowernumber );
56 my $logged_in_user = Koha::Patrons->find( $loggedinuser );
57 output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
59 my $order = 'date_due desc';
60 my $limit = 0;
61 my $issues = ();
62 # Do not request the old issues of anonymous patron
63 if ( $patron->borrowernumber eq C4::Context->preference('AnonymousPatron') ){
64 # use of 'eq' in the above comparison is intentional -- the
65 # system preference value could be blank
66 $template->param( is_anonymous => 1 );
67 } else {
68 $issues = GetAllIssues($patron->borrowernumber,$order,$limit);
71 # barcode export
72 if ( $op eq 'export_barcodes' ) {
73 # FIXME This should be moved out of this script
74 if ( $patron->privacy < 2) {
75 my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
76 my @barcodes =
77 map { $_->{barcode} } grep { $_->{returndate} =~ m/^$today/o } @{$issues};
78 my $borrowercardnumber = $patron->cardnumber;
79 my $delimiter = "\n";
80 binmode( STDOUT, ":encoding(UTF-8)" );
81 print $input->header(
82 -type => 'application/octet-stream',
83 -charset => 'utf-8',
84 -attachment => "$today-$borrowercardnumber-checkinexport.txt"
87 my $content = join $delimiter, uniq(@barcodes);
88 print $content;
89 exit;
93 if (! $limit){
94 $limit = 'full';
97 $template->param(
98 patron => $patron,
99 readingrecordview => 1,
100 loop_reading => $issues,
102 output_html_with_http_headers $input, $cookie, $template->output;