bug 3464: Takes columns country and B_country of table borrowers into account in...
[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 with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA  02111-1307 USA
22
23 use strict;
24 use C4::Auth;
25 use C4::Output;
26 use CGI;
27 use C4::Members;
28 use C4::Branch;
29
30 use C4::Dates qw/format_date/;
31 my $input=new CGI;
32
33
34 my $borrowernumber=$input->param('borrowernumber');
35 #get borrower details
36 my $data=GetMember($borrowernumber,'borrowernumber');
37 my $order=$input->param('order');
38 my $order2=$order;
39 if ($order2 eq ''){
40   $order2="date_due desc";
41 }
42 my $limit=$input->param('limit');
43
44 if ($limit){
45     if ($limit eq 'full'){
46                 $limit=0;
47     }
48
49 else {
50   $limit=50;
51 }
52 my ($count,$issues)=GetAllIssues($borrowernumber,$order2,$limit);
53
54 my ($template, $loggedinuser, $cookie)
55 = get_template_and_user({template_name => "members/readingrec.tmpl",
56                                 query => $input,
57                                 type => "intranet",
58                                 authnotrequired => 0,
59                                 flagsrequired => {borrowers => 1},
60                                 debug => 1,
61                                 });
62
63 my @loop_reading;
64
65 for (my $i=0;$i<$count;$i++){
66         my %line;
67         $line{biblionumber}=$issues->[$i]->{'biblionumber'};
68         $line{title}=$issues->[$i]->{'title'};
69         $line{author}=$issues->[$i]->{'author'};
70         $line{classification} = $issues->[$i]->{'classification'} || $issues->[$i]->{'itemcallnumber'};
71         $line{date_due}=format_date($issues->[$i]->{'date_due'});
72         $line{returndate}=format_date($issues->[$i]->{'returndate'});
73         $line{renewals}=$issues->[$i]->{'renewals'};
74         $line{barcode}=$issues->[$i]->{'barcode'};
75         $line{volumeddesc}=$issues->[$i]->{'volumeddesc'};
76         push(@loop_reading,\%line);
77 }
78
79 if ( $data->{'category_type'} eq 'C') {
80     my  ( $catcodes, $labels ) =  GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
81     my $cnt = scalar(@$catcodes);
82     $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
83     $template->param( 'catcode' =>    $catcodes->[0])  if $cnt == 1;
84 }
85
86 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
87 if (! $limit){ 
88         $limit = 'full'; 
89 }
90
91 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
92 $template->param( picture => 1 ) if $picture;
93
94 $template->param(
95                                                 readingrecordview => 1,
96                                                 biblionumber => $data->{'biblionumber'},
97                                                 title => $data->{'title'},
98                                                 initials => $data->{'initials'},
99                                                 surname => $data->{'surname'},
100                                                 borrowernumber => $borrowernumber,
101                                                 limit => $limit,
102                                                 firstname => $data->{'firstname'},
103                                                 cardnumber => $data->{'cardnumber'},
104                                             categorycode => $data->{'categorycode'},
105                                             category_type => $data->{'category_type'},
106                                            # category_description => $data->{'description'},
107                                             categoryname        => $data->{'description'},
108                                             address => $data->{'address'},
109                                                 address2 => $data->{'address2'},
110                                             city => $data->{'city'},
111                                                 zipcode => $data->{'zipcode'},
112                                                 country => $data->{'country'},
113                                                 phone => $data->{'phone'},
114                                                 email => $data->{'email'},
115                                                 branchcode => $data->{'branchcode'},
116                                                 is_child        => ($data->{'category_type'} eq 'C'),
117                                                 branchname => GetBranchName($data->{'branchcode'}),
118                                                 showfulllink => ($count > 50),                                  
119                                                 loop_reading => \@loop_reading);
120 output_html_with_http_headers $input, $cookie, $template->output;
121
122
123