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/;
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 foreach my $issue (@{$issues}){
70 $line{issuestimestamp} = format_date($issue->{'issuestimestamp'});
71 $line{biblionumber} = $issue->{'biblionumber'};
72 $line{title} = $issue->{'title'};
73 $line{author} = $issue->{'author'};
74 $line{classification} = $issue->{'classification'} || $issue->{'itemcallnumber'};
75 $line{date_due} = format_date($issue->{'date_due'});
76 $line{returndate} = format_date($issue->{'returndate'});
77 $line{issuedate} = format_date($issue->{'issuedate'});
78 $line{issuingbranch} = GetBranchName($issue->{'branchcode'});
79 $line{renewals} = $issue->{'renewals'};
80 $line{barcode} = $issue->{'barcode'};
81 $line{volumeddesc} = $issue->{'volumeddesc'};
82 push(@loop_reading,\%line);
85 if ( $data->{'category_type'} eq 'C') {
86 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
87 my $cnt = scalar(@$catcodes);
88 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
89 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
92 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
97 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
98 $template->param( picture => 1 ) if $picture;
100 if (C4::Context->preference('ExtendedPatronAttributes')) {
101 my $attributes = GetBorrowerAttributes($borrowernumber);
103 ExtendedPatronAttributes => 1,
104 extendedattributes => $attributes
109 readingrecordview => 1,
110 biblionumber => $data->{'biblionumber'},
111 title => $data->{'title'},
112 initials => $data->{'initials'},
113 surname => $data->{'surname'},
114 borrowernumber => $borrowernumber,
116 firstname => $data->{'firstname'},
117 cardnumber => $data->{'cardnumber'},
118 categorycode => $data->{'categorycode'},
119 category_type => $data->{'category_type'},
120 # category_description => $data->{'description'},
121 categoryname => $data->{'description'},
122 address => $data->{'address'},
123 address2 => $data->{'address2'},
124 city => $data->{'city'},
125 state => $data->{'state'},
126 zipcode => $data->{'zipcode'},
127 country => $data->{'country'},
128 phone => $data->{'phone'},
129 email => $data->{'email'},
130 branchcode => $data->{'branchcode'},
131 is_child => ($data->{'category_type'} eq 'C'),
132 branchname => GetBranchName($data->{'branchcode'}),
133 showfulllink => (scalar @loop_reading > 50),
134 loop_reading => \@loop_reading,
136 output_html_with_http_headers $input, $cookie, $template->output;