5 # script to do a borrower enquiry/bring up borrower details etc
6 # Displays all the details about a borrower
7 # written 20/12/99 by chris@katipo.co.nz
8 # last modified 21/1/2000 by chris@katipo.co.nz
9 # modified 31/1/2001 by chris@katipo.co.nz
10 # to not allow items on request to be renewed
12 # needs html removed and to use the C4::Output more, but its tricky
16 # Copyright 2000-2002 Katipo Communications
18 # This file is part of Koha.
20 # Koha is free software; you can redistribute it and/or modify it under the
21 # terms of the GNU General Public License as published by the Free Software
22 # Foundation; either version 2 of the License, or (at your option) any later
25 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
26 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
27 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
29 # You should have received a copy of the GNU General Public License along with
30 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
31 # Suite 330, Boston, MA 02111-1307 USA
40 use C4::Circulation::Renewals2;
41 use C4::Circulation::Circ2;
45 my $dbh = C4::Context->dbh;
49 my $template = gettemplate("members/moremember.tmpl");
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 # FIXME - This is expecting
150 # &C4::Circulation::Renewals2::calc_charges, but it's getting
151 # &C4::Circulation::Circ2::calc_charges, which only returns one
152 # element, so itemtype isn't being set.
153 # But &C4::Circulation::Renewals2::calc_charges doesn't appear to
154 # return the correct item type either (or a properly-formatted
155 # charge, for that matter).
156 my ($charge,$itemtype)=calc_charges(undef,$dbh,$issue->[$i]{'itemnumber'},$bornum);
157 $row{'itemtype'}=$itemtype;
158 $row{'charge'}=$charge;
160 #check item is not reserved
161 my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'});
163 print "<TD><a href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
164 # } elsif ($issue->[$i]->{'renewals'} > 0) {
165 # print "<TD>Previously Renewed - no renewals</td></tr>";
169 push (@issuedata, \%row);
172 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
175 # does it make sense to turn this into a foreach my $i (0..$rescount)
179 for (my $i=0;$i<$rescount;$i++){
180 $reserves->[$i]{'reservedate2'} = slashifyDate($reserves->[$i]{'reservedate'});
182 my %row = %$reserves->[$i];
183 if ($reserves->[$i]{'constrainttype'} eq 'o'){
184 $restitle=getreservetitle($reserves->[$i]{'biblionumber'},$reserves->[$i]{'borrowernumber'},$reserves->[$i]{'reservedate'},$reserves->[$i]{'timestamp'});
185 %row = (%row , %$restitle);
187 push (@reservedata, \%row);
190 $template->param($data);
191 $template->param(startmenumember => join('', startmenu('member')),
192 endmenumember => join('', endmenu('member')),
194 accountloop => \@accountdata,
195 issueloop => \@issuedata,
196 reserveloop => \@reservedata);
198 print "Content-Type: text/html\n\n", $template->output;