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