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>.
31 use C4
::Branch
qw(GetBranches);
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.tt",
49 flagsrequired
=> {borrowers
=> 1},
53 my $op = $input->param('op') || '';
54 if ($input->param('cardnumber')) {
55 $cardnumber = $input->param('cardnumber');
56 $data = GetMember
(cardnumber
=> $cardnumber);
57 $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
59 if ($input->param('borrowernumber')) {
60 $borrowernumber = $input->param('borrowernumber');
61 $data = GetMember
(borrowernumber
=> $borrowernumber);
64 my $order = 'date_due desc';
67 # Do not request the old issues of anonymous patron
68 if ( $borrowernumber eq C4
::Context
->preference('AnonymousPatron') ){
69 # use of 'eq' in the above comparison is intentional -- the
70 # system preference value could be blank
71 $template->param( is_anonymous
=> 1 );
73 $issues = GetAllIssues
($borrowernumber,$order,$limit);
76 my $branches = GetBranches
();
79 if ( $op eq 'export_barcodes' ) {
80 my $today = C4
::Dates
->new();
81 $today = $today->output('iso');
83 map { $_->{barcode
} } grep { $_->{returndate
} =~ m/^$today/o } @
{$issues};
84 my $borrowercardnumber =
85 GetMember
( borrowernumber
=> $borrowernumber )->{'cardnumber'};
87 binmode( STDOUT
, ":encoding(UTF-8)" );
89 -type
=> 'application/octet-stream',
91 -attachment
=> "$today-$borrowercardnumber-checkinexport.txt"
93 my $content = join $delimiter, uniq
(@barcodes);
98 if ( $data->{'category_type'} eq 'C') {
99 my ( $catcodes, $labels ) = GetborCatFromCatType
( 'A', 'WHERE category_type = ?' );
100 my $cnt = scalar(@
$catcodes);
101 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
102 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
105 $template->param( adultborrower
=> 1 ) if ( $data->{'category_type'} eq 'A' );
111 my ($picture, $dberror) = GetPatronImage
($data->{'borrowernumber'});
112 $template->param( picture
=> 1 ) if $picture;
114 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
115 my $attributes = GetBorrowerAttributes
($borrowernumber);
117 ExtendedPatronAttributes
=> 1,
118 extendedattributes
=> $attributes
123 my $roadtype = C4
::Koha
::GetAuthorisedValueByCode
( 'ROADTYPE', $data->{streettype
} );
124 $template->param(%$data);
127 readingrecordview
=> 1,
128 borrowernumber
=> $borrowernumber,
129 categoryname
=> $data->{description
},
130 roadtype
=> $roadtype,
131 is_child
=> ( $data->{category_type
} eq 'C' ),
132 branchname
=> $branches->{ $data->{branchcode
} }->{branchname
},
133 loop_reading
=> $issues,
134 activeBorrowerRelationship
=>
135 ( C4
::Context
->preference('borrowerRelationship') ne '' ),
136 RoutingSerials
=> C4
::Context
->preference('RoutingSerials'),
138 output_html_with_http_headers
$input, $cookie, $template->output;