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>.
27 use C4::Auth qw( get_template_and_user );
28 use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
29 use C4::Members qw( GetAllIssues );
30 use List::MoreUtils qw( any uniq );
31 use Koha::DateUtils qw( dt_from_string );
35 use Koha::Patron::Categories;
39 my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "members/readingrec.tt",
42 flagsrequired => {borrowers => 'edit_borrowers'},
45 my $op = $input->param('op') || '';
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 } );
60 if ( $op eq 'export_barcodes' ) {
61 # FIXME This should be moved out of this script
62 if ( $patron->privacy < 2) {
63 my @barcodes = $patron->old_checkouts->search( {}, { prefetch => 'item' } )
64 ->filter_by_todays_checkins->get_column('item.barcode');
66 my $borrowercardnumber = $patron->cardnumber;
68 my $today = dt_from_string->ymd;
69 binmode( STDOUT, ":encoding(UTF-8)" );
71 -type => 'application/octet-stream',
73 -attachment => "$today-$borrowercardnumber-checkinexport.txt"
76 my $content = join $delimiter, uniq(@barcodes);
82 my $order = 'date_due desc';
85 # Do not request the old issues of anonymous patron
86 if ( $patron->borrowernumber eq C4::Context->preference('AnonymousPatron') ){
87 # use of 'eq' in the above comparison is intentional -- the
88 # system preference value could be blank
89 $template->param( is_anonymous => 1 );
91 $issues = GetAllIssues($patron->borrowernumber,$order,$limit);
100 readingrecordview => 1,
101 loop_reading => $issues
103 output_html_with_http_headers $input, $cookie, $template->output;