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
37 use C4::Interface::CGI::Output;
38 use C4::Interface::CGI::Template;
44 use C4::Circulation::Renewals2;
45 use C4::Circulation::Circ2;
49 my $dbh = C4::Context->dbh;
53 my ($template, $loggedinuser, $cookie)
54 = get_template_and_user({template_name => "members/moremember.tmpl",
58 flagsrequired => {borrowers => 1},
62 my $bornum=$input->param('bornum');
64 #start the page and read in includes
66 my $data=borrdata('',$bornum);
68 $data->{'dateenrolled'} = format_date($data->{'dateenrolled'});
69 $data->{'expiry'} = format_date($data->{'expiry'});
70 $data->{'dateofbirth'} = format_date($data->{'dateofbirth'});
72 $data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'});
74 $data->{&expand_sex_into_predicate($data->{'sex'})} = 1;
76 if ($data->{'categorycode'} eq 'C'){
77 my $data2=borrdata('',$data->{'guarantor'});
78 $data->{'streetaddress'}=$data2->{'streetaddress'};
79 $data->{'city'}=$data2->{'city'};
80 $data->{'physstreet'}=$data2->{'phystreet'};
81 $data->{'streetcity'}=$data2->{'streetcity'};
82 $data->{'phone'}=$data2->{'phone'};
83 $data->{'phoneday'}=$data2->{'phoneday'};
87 if ($data->{'ethnicity'} || $data->{'ethnotes'}) {
88 $template->param(printethnicityline => 1);
91 if ($data->{'categorycode'} ne 'C'){
92 $template->param(isguarantee => 1);
94 # It looks like the $i is only being returned to handle walking through
95 # the array, which is probably better done as a foreach loop.
97 my ($count,$guarantees)=findguarantees($data->{'borrowernumber'});
99 for (my $i=0;$i<$count;$i++){
100 push (@guaranteedata, {borrowernumber => $guarantees->[$i]->{'borrowernumber'},
101 cardnumber => $guarantees->[$i]->{'cardnumber'}});
103 $template->param(guaranteeloop => \@guaranteedata);
106 my ($guarantor)=findguarantor($data->{'borrowernumber'});
107 unless ($guarantor->{'borrowernumber'} == 0){
108 $template->param(guarantorborrowernumber => $guarantor->{'borrowernumber'}, guarantorcardnumber => $guarantor->{'cardnumber'});
113 $bor{'borrowernumber'}=$bornum;
116 # it looks like $numaccts is a temp variable and that the
117 # for (my $i;$i<$numaccts;$i++)
118 # can be turned into a foreach loop instead
120 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
121 #if ($numaccts > 10){
125 for (my$i=0;$i<$numaccts;$i++){
126 my $amount= $accts->[$i]{'amount'} + 0.00;
127 my $amount2= $accts->[$i]{'amountoutstanding'} + 0.00;
128 my %row = %$accts->[$i];
131 $row{'date'} = format_date($accts->[$i]{'date'});
133 if ($accts->[$i]{'accounttype'} ne 'Res'){
139 # why set this variable if it's not going to be used?
142 if ($accts->[$i]{'accounttype'} ne 'Res'){
143 my $iteminfo=C4::Circulation::Circ2::getiteminformation($env,$accts->[$i]->{'itemnumber'},'');
144 # FIXME, seems to me $iteminfo gets not defined
145 %row = (%row , %$iteminfo) if $iteminfo;
148 push (@accountdata, \%row);
151 my ($count,$issue)=borrissues($bornum);
152 my $today=ParseDate('today');
154 for (my $i=0;$i<$count;$i++){
155 my $datedue=ParseDate($issue->[$i]{'date_due'});
156 $issue->[$i]{'date_due'} = format_date($issue->[$i]{'date_due'});
157 my %row = %{$issue->[$i]};
158 if ($datedue < $today){
159 $row{'red'}=1; #print "<font color=red>";
161 #find the charge for an item
162 # FIXME - This is expecting
163 # &C4::Circulation::Renewals2::calc_charges, but it's getting
164 # &C4::Circulation::Circ2::calc_charges, which only returns one
165 # element, so itemtype isn't being set.
166 # But &C4::Circulation::Renewals2::calc_charges doesn't appear to
167 # return the correct item type either (or a properly-formatted
168 # charge, for that matter).
169 my ($charge,$itemtype)=calc_charges(undef,$dbh,$issue->[$i]{'itemnumber'},$bornum);
170 $row{'itemtype'}=$itemtype;
171 $row{'charge'}=$charge;
173 #check item is not reserved
174 my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'});
176 print "<TD><a href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
177 # } elsif ($issue->[$i]->{'renewals'} > 0) {
178 # print "<TD>Previously Renewed - no renewals</td></tr>";
182 push (@issuedata, \%row);
185 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
188 # does it make sense to turn this into a foreach my $i (0..$rescount)
192 for (my $i=0;$i<$rescount;$i++){
193 $reserves->[$i]{'reservedate2'} = format_date($reserves->[$i]{'reservedate'});
195 my %row = %$reserves->[$i];
196 if ($reserves->[$i]{'constrainttype'} eq 'o'){
197 $restitle=getreservetitle($reserves->[$i]{'biblionumber'},$reserves->[$i]{'borrowernumber'},$reserves->[$i]{'reservedate'},$reserves->[$i]{'timestamp'});
198 %row = (%row , %$restitle);
200 push (@reservedata, \%row);
203 $template->param($data);
206 accountloop => \@accountdata,
207 issueloop => \@issuedata,
208 reserveloop => \@reservedata);
210 output_html_with_http_headers $input, $cookie, $template->output;