Fix FSF address in directory members/
[koha.git] / members / readingrec.pl
1 #!/usr/bin/perl
2
3 # written 27/01/2000
4 # script to display borrowers reading record
5
6 # Copyright 2000-2002 Katipo Communications
7 #
8 # This file is part of Koha.
9 #
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.
14 #
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.
18 #
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.
22
23 use strict;
24 use warnings;
25
26 use CGI;
27
28 use C4::Auth;
29 use C4::Output;
30 use C4::Members;
31 use C4::Branch;
32 use C4::Dates qw/format_date/;
33
34 my $input = CGI->new;
35
36 #get borrower details
37 my $data = undef;
38 my $borrowernumber = undef;
39 my $cardnumber = undef;
40
41 if ($input->param('cardnumber')) {
42     $cardnumber = $input->param('cardnumber');
43     $data = GetMember(cardnumber => $cardnumber);
44     $borrowernumber = $data->{'borrowernumber'}; # we must define this as it is used to retrieve other data about the patron
45 }
46 if ($input->param('borrowernumber')) {
47     $borrowernumber = $input->param('borrowernumber');
48     $data = GetMember(borrowernumber => $borrowernumber);
49 }
50
51 my $order=$input->param('order') || '';
52 my $order2=$order;
53 if ($order2 eq ''){
54   $order2="date_due desc";
55 }
56 my $limit=$input->param('limit');
57
58 if ($limit){
59     if ($limit eq 'full'){
60                 $limit=0;
61     }
62 }
63 else {
64   $limit=50;
65 }
66 my ($count,$issues)=GetAllIssues($borrowernumber,$order2,$limit);
67
68 my ($template, $loggedinuser, $cookie)
69 = get_template_and_user({template_name => "members/readingrec.tmpl",
70                                 query => $input,
71                                 type => "intranet",
72                                 authnotrequired => 0,
73                                 flagsrequired => {borrowers => 1},
74                                 debug => 1,
75                                 });
76
77 my @loop_reading;
78
79 for (my $i=0;$i<$count;$i++){
80         my %line;
81         $line{biblionumber}=$issues->[$i]->{'biblionumber'};
82         $line{title}=$issues->[$i]->{'title'};
83         $line{author}=$issues->[$i]->{'author'};
84         $line{classification} = $issues->[$i]->{'classification'} || $issues->[$i]->{'itemcallnumber'};
85         $line{date_due}=format_date($issues->[$i]->{'date_due'});
86         $line{returndate}=format_date($issues->[$i]->{'returndate'});
87         $line{renewals}=$issues->[$i]->{'renewals'};
88         $line{barcode}=$issues->[$i]->{'barcode'};
89         $line{volumeddesc}=$issues->[$i]->{'volumeddesc'};
90         push(@loop_reading,\%line);
91 }
92
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;
98 }
99
100 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
101 if (! $limit){
102         $limit = 'full';
103 }
104
105 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
106 $template->param( picture => 1 ) if $picture;
107
108 $template->param(
109                                                 readingrecordview => 1,
110                                                 biblionumber => $data->{'biblionumber'},
111                                                 title => $data->{'title'},
112                                                 initials => $data->{'initials'},
113                                                 surname => $data->{'surname'},
114                                                 borrowernumber => $borrowernumber,
115                                                 limit => $limit,
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                                                 zipcode => $data->{'zipcode'},
126                                                 country => $data->{'country'},
127                                                 phone => $data->{'phone'},
128                                                 email => $data->{'email'},
129                                                 branchcode => $data->{'branchcode'},
130                                                 is_child        => ($data->{'category_type'} eq 'C'),
131                                                 branchname => GetBranchName($data->{'branchcode'}),
132                                                 showfulllink => ($count > 50),
133                                                 loop_reading => \@loop_reading);
134 output_html_with_http_headers $input, $cookie, $template->output;
135
136
137