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.
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.tmpl",
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';
66 my $issues = GetAllIssues
($borrowernumber,$order,$limit);
68 my $branches = GetBranches
();
69 foreach my $issue ( @
{$issues} ) {
70 $issue->{issuingbranch
} = $branches->{ $issue->{branchcode
} }->{branchname
};
74 if ( $op eq 'export_barcodes' ) {
75 my $today = C4
::Dates
->new();
76 $today = $today->output('iso');
78 map { $_->{barcode
} } grep { $_->{returndate
} =~ m/^$today/o } @
{$issues};
79 my $borrowercardnumber =
80 GetMember
( borrowernumber
=> $borrowernumber )->{'cardnumber'};
82 binmode( STDOUT
, ":encoding(UTF-8)" );
84 -type
=> 'application/octet-stream',
86 -attachment
=> "$today-$borrowercardnumber-checkinexport.txt"
88 my $content = join $delimiter, uniq
(@barcodes);
93 if ( $data->{'category_type'} eq 'C') {
94 my ( $catcodes, $labels ) = GetborCatFromCatType
( 'A', 'WHERE category_type = ?' );
95 my $cnt = scalar(@
$catcodes);
96 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
97 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
100 $template->param( adultborrower
=> 1 ) if ( $data->{'category_type'} eq 'A' );
106 my ($picture, $dberror) = GetPatronImage
($data->{'cardnumber'});
107 $template->param( picture
=> 1 ) if $picture;
109 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
110 my $attributes = GetBorrowerAttributes
($borrowernumber);
112 ExtendedPatronAttributes
=> 1,
113 extendedattributes
=> $attributes
118 readingrecordview
=> 1,
119 title
=> $data->{title
},
120 initials
=> $data->{initials
},
121 surname
=> $data->{surname
},
122 othernames
=> $data->{othernames
},
123 borrowernumber
=> $borrowernumber,
124 firstname
=> $data->{firstname
},
125 cardnumber
=> $data->{cardnumber
},
126 categorycode
=> $data->{categorycode
},
127 category_type
=> $data->{category_type
},
128 categoryname
=> $data->{description
},
129 address
=> $data->{address
},
130 address2
=> $data->{address2
},
131 city
=> $data->{city
},
132 state => $data->{state},
133 zipcode
=> $data->{zipcode
},
134 country
=> $data->{country
},
135 phone
=> $data->{phone
},
136 email
=> $data->{email
},
137 branchcode
=> $data->{branchcode
},
138 is_child
=> ( $data->{category_type
} eq 'C' ),
139 branchname
=> $branches->{ $data->{branchcode
} }->{branchname
},
140 loop_reading
=> $issues,
141 activeBorrowerRelationship
=>
142 ( C4
::Context
->preference('borrowerRelationship') ne '' ),
143 RoutingSerials
=> C4
::Context
->preference('RoutingSerials'),
145 output_html_with_http_headers
$input, $cookie, $template->output;