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/;
35 use C4
::Dates qw
/format_date/;
36 use C4
::Members
::Attributes
qw(GetBorrowerAttributes);
42 my $borrowernumber = undef;
43 my $cardnumber = undef;
45 my ($template, $loggedinuser, $cookie)= get_template_and_user
({template_name
=> "members/readingrec.tmpl",
49 flagsrequired
=> {borrowers
=> 1},
53 if ($input->param('cardnumber')) {
54 $cardnumber = $input->param('cardnumber');
55 $data = GetMember
(cardnumber
=> $cardnumber);
56 $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
58 if ($input->param('borrowernumber')) {
59 $borrowernumber = $input->param('borrowernumber');
60 $data = GetMember
(borrowernumber
=> $borrowernumber);
63 my $order = 'date_due desc';
65 my ( $issues ) = GetAllIssues
($borrowernumber,$order,$limit);
69 my $today = C4
::Dates
->new();
70 $today = $today->output("iso");
72 foreach my $issue (@
{$issues}){
74 $line{issuestimestamp
} = format_date
($issue->{'issuestimestamp'});
75 $line{biblionumber
} = $issue->{'biblionumber'};
76 $line{title
} = $issue->{'title'};
77 $line{author
} = $issue->{'author'};
78 $line{classification
} = $issue->{'classification'} || $issue->{'itemcallnumber'};
79 $line{date_due
} = format_sqldatetime
($issue->{date_due
});
80 $line{returndate
} = format_sqldatetime
($issue->{returndate
});
81 $line{issuedate
} = format_sqldatetime
($issue->{issuedate
});
82 $line{issuingbranch
} = GetBranchName
($issue->{'branchcode'});
83 $line{renewals
} = $issue->{'renewals'};
84 $line{barcode
} = $issue->{'barcode'};
85 $line{volumeddesc
} = $issue->{'volumeddesc'};
86 push(@loop_reading,\
%line);
87 my $return_dt = Koha
::DateUtils
::dt_from_string
($issue->{'returndate'}, 'iso');
88 if ( ( $input->param('op') eq 'export_barcodes' ) and ( $today eq $return_dt->ymd() ) ) {
89 push( @barcodes, $issue->{'barcode'} );
93 if ($input->param('op') eq 'export_barcodes') {
94 my $borrowercardnumber = GetMember
( borrowernumber
=> $borrowernumber )->{'cardnumber'} ;
96 binmode( STDOUT
, ":encoding(UTF-8)");
98 -type
=> 'application/octet-stream',
100 -attachment
=> "$today-$borrowercardnumber-checkinexport.txt"
102 my $content = join($delimiter, uniq
(@barcodes));
107 if ( $data->{'category_type'} eq 'C') {
108 my ( $catcodes, $labels ) = GetborCatFromCatType
( 'A', 'WHERE category_type = ?' );
109 my $cnt = scalar(@
$catcodes);
110 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
111 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
114 $template->param( adultborrower
=> 1 ) if ( $data->{'category_type'} eq 'A' );
119 my ($picture, $dberror) = GetPatronImage
($data->{'cardnumber'});
120 $template->param( picture
=> 1 ) if $picture;
122 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
123 my $attributes = GetBorrowerAttributes
($borrowernumber);
125 ExtendedPatronAttributes
=> 1,
126 extendedattributes
=> $attributes
131 readingrecordview
=> 1,
132 biblionumber
=> $data->{'biblionumber'},
133 title
=> $data->{'title'},
134 initials
=> $data->{'initials'},
135 surname
=> $data->{'surname'},
136 othernames
=> $data->{'othernames'},
137 borrowernumber
=> $borrowernumber,
139 firstname
=> $data->{'firstname'},
140 cardnumber
=> $data->{'cardnumber'},
141 categorycode
=> $data->{'categorycode'},
142 category_type
=> $data->{'category_type'},
143 # category_description => $data->{'description'},
144 categoryname
=> $data->{'description'},
145 address
=> $data->{'address'},
146 address2
=> $data->{'address2'},
147 city
=> $data->{'city'},
148 state => $data->{'state'},
149 zipcode
=> $data->{'zipcode'},
150 country
=> $data->{'country'},
151 phone
=> $data->{'phone'},
152 email
=> $data->{'email'},
153 branchcode
=> $data->{'branchcode'},
154 is_child
=> ($data->{'category_type'} eq 'C'),
155 branchname
=> GetBranchName
($data->{'branchcode'}),
156 showfulllink
=> (scalar @loop_reading > 50),
157 loop_reading
=> \
@loop_reading,
158 activeBorrowerRelationship
=> (C4
::Context
->preference('borrowerRelationship') ne ''),
160 output_html_with_http_headers
$input, $cookie, $template->output;