bug 5326 fix link to old prefs editor on patron attributes
[koha.git] / members / readingrec.pl
blobbd6ca8230992b8b710520c36335e80d65715168c
1 #!/usr/bin/perl
3 # written 27/01/2000
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
13 # version.
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.
23 use strict;
24 use warnings;
26 use CGI;
28 use C4::Auth;
29 use C4::Output;
30 use C4::Members;
31 use C4::Branch;
32 use List::MoreUtils qw/any/;
34 use C4::Dates qw/format_date/;
36 my $input = CGI->new;
38 #get borrower details
39 my $data = undef;
40 my $borrowernumber = undef;
41 my $cardnumber = undef;
43 if ($input->param('cardnumber')) {
44 $cardnumber = $input->param('cardnumber');
45 $data = GetMember(cardnumber => $cardnumber);
46 $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
48 if ($input->param('borrowernumber')) {
49 $borrowernumber = $input->param('borrowernumber');
50 $data = GetMember(borrowernumber => $borrowernumber);
53 my $order=$input->param('order') || 'date_due desc';
54 my $limit=$input->param('limit');
56 if ($limit){
57 if ($limit eq 'full'){
58 $limit=0;
61 else {
62 $limit=50;
64 my ( $issues ) = GetAllIssues($borrowernumber,$order,$limit);
66 my ($template, $loggedinuser, $cookie)
67 = get_template_and_user({template_name => "members/readingrec.tmpl",
68 query => $input,
69 type => "intranet",
70 authnotrequired => 0,
71 flagsrequired => {borrowers => 1},
72 debug => 1,
73 });
75 my @loop_reading;
77 foreach my $issue (@{$issues}){
78 my %line;
79 $line{issuestimestamp} = format_date($issue->{'issuestimestamp'});
80 $line{biblionumber} = $issue->{'biblionumber'};
81 $line{title} = $issue->{'title'};
82 $line{author} = $issue->{'author'};
83 $line{classification} = $issue->{'classification'} || $issue->{'itemcallnumber'};
84 $line{date_due} = format_date($issue->{'date_due'});
85 $line{returndate} = format_date($issue->{'returndate'});
86 $line{issuedate} = format_date($issue->{'issuedate'});
87 $line{issuingbranch} = GetBranchName($issue->{'branchcode'});
88 $line{renewals} = $issue->{'renewals'};
89 $line{barcode} = $issue->{'barcode'};
90 $line{volumeddesc} = $issue->{'volumeddesc'};
91 push(@loop_reading,\%line);
94 if ( $data->{'category_type'} eq 'C') {
95 my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
96 my $cnt = scalar(@$catcodes);
97 $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
98 $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1;
101 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
102 if (! $limit){
103 $limit = 'full';
106 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
107 $template->param( picture => 1 ) if $picture;
109 $template->param(
110 readingrecordview => 1,
111 biblionumber => $data->{'biblionumber'},
112 title => $data->{'title'},
113 initials => $data->{'initials'},
114 surname => $data->{'surname'},
115 borrowernumber => $borrowernumber,
116 limit => $limit,
117 firstname => $data->{'firstname'},
118 cardnumber => $data->{'cardnumber'},
119 categorycode => $data->{'categorycode'},
120 category_type => $data->{'category_type'},
121 # category_description => $data->{'description'},
122 categoryname => $data->{'description'},
123 address => $data->{'address'},
124 address2 => $data->{'address2'},
125 city => $data->{'city'},
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);
135 output_html_with_http_headers $input, $cookie, $template->output;