3 # script to do a borrower enquiry/bring up borrower details etc
4 # Displays all the details about a borrower
5 # written 20/12/99 by chris@katipo.co.nz
6 # last modified 21/1/2000 by chris@katipo.co.nz
7 # modified 31/1/2001 by chris@katipo.co.nz
8 # to not allow items on request to be renewed
10 # needs html removed and to use the C4::Output more, but its tricky
14 # Copyright 2000-2002 Katipo Communications
16 # This file is part of Koha.
18 # Koha is free software; you can redistribute it and/or modify it under the
19 # terms of the GNU General Public License as published by the Free Software
20 # Foundation; either version 2 of the License, or (at your option) any later
23 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
24 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
25 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License along with
28 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
29 # Suite 330, Boston, MA 02111-1307 USA
38 use C4::Circulation::Renewals2;
39 use C4::Circulation::Circ2;
43 my $dbh = C4::Context->dbh;
47 my $theme = $input->param('theme'); # only used if allowthemeoverride is set
48 my %tmpldata = pathtotemplate ( template => 'moremember.tmpl', theme => $theme );
49 my $template = HTML::Template->new(filename => $tmpldata{'path'}, die_on_bad_params => 0);
51 my $bornum=$input->param('bornum');
53 #start the page and read in includes
55 my $data=borrdata('',$bornum);
57 $data->{'dateenrolled'} = slashifyDate($data->{'dateenrolled'});
58 $data->{'expiry'} = slashifyDate($data->{'expiry'});
59 $data->{'dateofbirth'} = slashifyDate($data->{'dateofbirth'});
61 $data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'});
63 if ($data->{'categorycode'} eq 'C'){
64 my $data2=borrdata('',$data->{'guarantor'});
65 $data->{'streetaddress'}=$data2->{'streetaddress'};
66 $data->{'city'}=$data2->{'city'};
67 $data->{'physstreet'}=$data2->{'phystreet'};
68 $data->{'streetcity'}=$data2->{'streetcity'};
69 $data->{'phone'}=$data2->{'phone'};
70 $data->{'phoneday'}=$data2->{'phoneday'};
74 if ($data->{'ethnicity'} || $data->{'ethnotes'}) {
75 $template->param(printethnicityline => 1);
78 if ($data->{'categorycode'} ne 'C'){
79 $template->param(isguarantee => 1);
81 # It looks like the $i is only being returned to handle walking through
82 # the array, which is probably better done as a foreach loop.
84 my ($count,$guarantees)=findguarantees($data->{'borrowernumber'});
86 for (my $i=0;$i<$count;$i++){
87 push (@guaranteedata, {borrowernumber => $guarantees->[$i]->{'borrowernumber'},
88 cardnumber => $guarantees->[$i]->{'cardnumber'}});
90 $template->param(guaranteeloop => \@guaranteedata);
93 my ($guarantor)=findguarantor($data->{'borrowernumber'});
94 unless ($guarantor->{'borrowernumber'} == 0){
95 $template->param(guarantorborrowernumber => $guarantor->{'borrowernumber'}, guarantorcardnumber => $guarantor->{'cardnumber'});
100 $bor{'borrowernumber'}=$bornum;
103 # it looks like $numaccts is a temp variable and that the
104 # for (my $i;$i<$numaccts;$i+++)
105 # can be turned into a foreach loop instead
107 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
108 #if ($numaccts > 10){
112 for (my$i=0;$i<$numaccts;$i++){
113 my $amount= $accts->[$i]{'amount'} + 0.00;
114 my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00;
115 my %row = %$accts->[$i];
118 $row{'date'} = slashifyDate($accts->[$i]{'date'});
120 if ($accts->[$i]{'accounttype'} ne 'Res'){
126 # why set this variable if it's not going to be used?
129 if ($accts->[$i]{'accounttype'} ne 'Res'){
130 my $iteminfo=C4::Circulation::Circ2::getiteminformation($env,$accts->[$i]->{'itemnumber'},'');
131 # FIXME, seems to me $iteminfo gets not defined
132 %row = (%row , %$iteminfo) if $iteminfo;
135 push (@accountdata, \%row);
138 my ($count,$issue)=borrissues($bornum);
139 my $today=ParseDate('today');
141 for (my $i=0;$i<$count;$i++){
142 my $datedue=ParseDate($issue->[$i]{'date_due'});
143 $issue->[$i]{'date_due'} = slashifyDate($issue->[$i]{'date_due'});
144 my %row = %$issue->[$i];
145 if ($datedue < $today){
146 $row{'red'}=1; #print "<font color=red>";
148 #find the charge for an item
149 my ($charge,$itemtype)=calc_charges(undef,$dbh,$issue->[$i]{'itemnumber'},$bornum);
150 $row{'itemtype'}=$itemtype;
151 $row{'charge'}=$charge;
153 #check item is not reserved
154 my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'});
156 print "<TD><a href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
157 # } elsif ($issue->[$i]->{'renewals'} > 0) {
158 # print "<TD>Previously Renewed - no renewals</td></tr>";
162 push (@issuedata, \%row);
165 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
168 # does it make sense to turn this into a foreach my $i (0..$rescount)
172 for (my $i=0;$i<$rescount;$i++){
173 $reserves->[$i]{'reservedate2'} = slashifyDate($reserves->[$i]{'reservedate'});
175 my %row = %$reserves->[$i];
176 if ($reserves->[$i]{'constrainttype'} eq 'o'){
177 $restitle=getreservetitle($reserves->[$i]{'biblionumber'},$reserves->[$i]{'borrowernumber'},$reserves->[$i]{'reservedate'},$reserves->[$i]{'timestamp'});
178 %row = (%row , %$restitle);
180 push (@reservedata, \%row);
183 $template->param($data);
184 $template->param(startmenumember => join('', startmenu('member')),
185 endmenumember => join('', endmenu('member')),
187 accountloop => \@accountdata,
188 issueloop => \@issuedata,
189 reserveloop => \@reservedata);
191 print "Content-Type: text/html\n\n", $template->output;