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;
99 my $attributes = GetBorrowerAttributes($borrowernumber);
102 readingrecordview => 1,
103 biblionumber => $data->{'biblionumber'},
104 title => $data->{'title'},
105 initials => $data->{'initials'},
106 surname => $data->{'surname'},
107 borrowernumber => $borrowernumber,
109 firstname => $data->{'firstname'},
110 cardnumber => $data->{'cardnumber'},
111 categorycode => $data->{'categorycode'},
112 category_type => $data->{'category_type'},
113 # category_description => $data->{'description'},
114 categoryname => $data->{'description'},
115 address => $data->{'address'},
116 address2 => $data->{'address2'},
117 city => $data->{'city'},
118 state => $data->{'state'},
119 zipcode => $data->{'zipcode'},
120 country => $data->{'country'},
121 phone => $data->{'phone'},
122 email => $data->{'email'},
123 branchcode => $data->{'branchcode'},
124 is_child => ($data->{'category_type'} eq 'C'),
125 branchname => GetBranchName($data->{'branchcode'}),
126 showfulllink => (scalar @loop_reading > 50),
127 loop_reading => \@loop_reading,
128 extendedattributes => $attributes,
130 output_html_with_http_headers $input, $cookie, $template->output;