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
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.
32 use List::MoreUtils qw/any uniq/;
34 use C4::Dates qw/format_date/;
35 use C4::Members::Attributes qw(GetBorrowerAttributes);
41 my $borrowernumber = undef;
42 my $cardnumber = undef;
44 my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "members/readingrec.tmpl",
48 flagsrequired => {borrowers => 1},
52 if ($input->param('cardnumber')) {
53 $cardnumber = $input->param('cardnumber');
54 $data = GetMember(cardnumber => $cardnumber);
55 $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
57 if ($input->param('borrowernumber')) {
58 $borrowernumber = $input->param('borrowernumber');
59 $data = GetMember(borrowernumber => $borrowernumber);
62 my $order = 'date_due desc';
64 my ( $issues ) = GetAllIssues($borrowernumber,$order,$limit);
68 my $today = C4::Dates->new();
69 $today = $today->output("iso");
71 foreach my $issue (@{$issues}){
73 $line{issuestimestamp} = format_date($issue->{'issuestimestamp'});
74 $line{biblionumber} = $issue->{'biblionumber'};
75 $line{title} = $issue->{'title'};
76 $line{author} = $issue->{'author'};
77 $line{classification} = $issue->{'classification'} || $issue->{'itemcallnumber'};
78 $line{date_due} = format_date($issue->{'date_due'});
79 $line{returndate} = format_date($issue->{'returndate'});
80 $line{issuedate} = format_date($issue->{'issuedate'});
81 $line{issuingbranch} = GetBranchName($issue->{'branchcode'});
82 $line{renewals} = $issue->{'renewals'};
83 $line{barcode} = $issue->{'barcode'};
84 $line{volumeddesc} = $issue->{'volumeddesc'};
85 push(@loop_reading,\%line);
86 if (($input->param('op') eq 'export_barcodes') and ($today eq $issue->{'returndate'})) {
87 push( @barcodes, $issue->{'barcode'} );
91 if ($input->param('op') eq 'export_barcodes') {
92 my $borrowercardnumber = GetMember( borrowernumber => $borrowernumber )->{'cardnumber'} ;
94 binmode( STDOUT, ":encoding(UTF-8)");
96 -type => 'application/octet-stream',
98 -attachment => "$today-$borrowercardnumber-checkinexport.txt"
100 my $content = join($delimiter, uniq(@barcodes));
105 if ( $data->{'category_type'} eq 'C') {
106 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
107 my $cnt = scalar(@$catcodes);
108 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
109 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
112 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
117 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
118 $template->param( picture => 1 ) if $picture;
120 if (C4::Context->preference('ExtendedPatronAttributes')) {
121 my $attributes = GetBorrowerAttributes($borrowernumber);
123 ExtendedPatronAttributes => 1,
124 extendedattributes => $attributes
129 readingrecordview => 1,
130 biblionumber => $data->{'biblionumber'},
131 title => $data->{'title'},
132 initials => $data->{'initials'},
133 surname => $data->{'surname'},
134 othernames => $data->{'othernames'},
135 borrowernumber => $borrowernumber,
137 firstname => $data->{'firstname'},
138 cardnumber => $data->{'cardnumber'},
139 categorycode => $data->{'categorycode'},
140 category_type => $data->{'category_type'},
141 # category_description => $data->{'description'},
142 categoryname => $data->{'description'},
143 address => $data->{'address'},
144 address2 => $data->{'address2'},
145 city => $data->{'city'},
146 state => $data->{'state'},
147 zipcode => $data->{'zipcode'},
148 country => $data->{'country'},
149 phone => $data->{'phone'},
150 email => $data->{'email'},
151 branchcode => $data->{'branchcode'},
152 is_child => ($data->{'category_type'} eq 'C'),
153 branchname => GetBranchName($data->{'branchcode'}),
154 showfulllink => (scalar @loop_reading > 50),
155 loop_reading => \@loop_reading,
156 activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
158 output_html_with_http_headers $input, $cookie, $template->output;