[MT3191] various perl errors in script (merge conflict)
[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 List::MoreUtils qw/any/;
33
34 use C4::Dates qw/format_date/;
35
36 my $input = CGI->new;
37
38 #get borrower details
39 my $data = undef;
40 my $borrowernumber = undef;
41 my $cardnumber = undef;
42
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
47 }
48 if ($input->param('borrowernumber')) {
49     $borrowernumber = $input->param('borrowernumber');
50     $data = GetMember(borrowernumber => $borrowernumber);
51 }
52
53 my $order=$input->param('order') || 'date_due desc';
54 my $limit=$input->param('limit');
55
56 if ($limit){
57     if ($limit eq 'full'){
58                 $limit=0;
59     }
60 }
61 else {
62   $limit=50;
63 }
64 my ( $issues ) = GetAllIssues($borrowernumber,$order,$limit);
65 warn "BORR : $borrowernumber = ".Data::Dumper::Dumper($issues);
66
67 my ($template, $loggedinuser, $cookie)
68 = get_template_and_user({template_name => "members/readingrec.tmpl",
69                                 query => $input,
70                                 type => "intranet",
71                                 authnotrequired => 0,
72                                 flagsrequired => {borrowers => 1},
73                                 debug => 1,
74                                 });
75
76 my @loop_reading;
77
78 foreach my $issue (@{$issues}){
79         my %line;
80         $line{issuestimestamp} = format_date($issue->{'issuestimestamp'});
81         $line{biblionumber}    = $issue->{'biblionumber'};
82         $line{title}           = $issue->{'title'};
83         $line{author}          = $issue->{'author'};
84         $line{classification}  = $issue->{'classification'} || $issue->{'itemcallnumber'};
85         $line{date_due}        = format_date($issue->{'date_due'});
86         $line{returndate}      = format_date($issue->{'returndate'});
87         $line{issuedate}       = format_date($issue->{'issuedate'});
88         $line{issuingbranch}   = GetBranchName($issue->{'issuingbranch'});
89         $line{renewals}        = $issue->{'renewals'};
90         $line{barcode}         = $issue->{'barcode'};
91         $line{volumeddesc}     = $issue->{'volumeddesc'};
92         push(@loop_reading,\%line);
93 }
94
95 if ( $data->{'category_type'} eq 'C') {
96     my  ( $catcodes, $labels ) =  GetborCatFromCatType( 'A', 'WHERE category_type = ?' );
97     my $cnt = scalar(@$catcodes);
98     $template->param( 'CATCODE_MULTI' => 1) if $cnt > 1;
99     $template->param( 'catcode' =>    $catcodes->[0])  if $cnt == 1;
100 }
101
102 $template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' );
103 if (! $limit){
104         $limit = 'full';
105 }
106
107 my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'});
108 $template->param( picture => 1 ) if $picture;
109
110 $template->param(
111                                                 readingrecordview => 1,
112                                                 biblionumber => $data->{'biblionumber'},
113                                                 title => $data->{'title'},
114                                                 initials => $data->{'initials'},
115                                                 surname => $data->{'surname'},
116                                                 borrowernumber => $borrowernumber,
117                                                 limit => $limit,
118                                                 firstname => $data->{'firstname'},
119                                                 cardnumber => $data->{'cardnumber'},
120                                             categorycode => $data->{'categorycode'},
121                                             category_type => $data->{'category_type'},
122                                            # category_description => $data->{'description'},
123                                             categoryname        => $data->{'description'},
124                                             address => $data->{'address'},
125                                                 address2 => $data->{'address2'},
126                                             city => $data->{'city'},
127                                                 zipcode => $data->{'zipcode'},
128                                                 country => $data->{'country'},
129                                                 phone => $data->{'phone'},
130                                                 email => $data->{'email'},
131                                                 branchcode => $data->{'branchcode'},
132                                                 is_child        => ($data->{'category_type'} eq 'C'),
133                                                 branchname => GetBranchName($data->{'branchcode'}),
134                                                 showfulllink => (scalar @loop_reading > 50),                                    
135                                                 loop_reading => \@loop_reading);
136 output_html_with_http_headers $input, $cookie, $template->output;
137
138
139