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 $template->param($data->{'categorycode'} => 1); # in template <TMPL_IF name="I"> => instutitional (A for Adult & C for children)
70 $data->{'dateenrolled'} = format_date($data->{'dateenrolled'});
71 $data->{'expiry'} = format_date($data->{'expiry'});
72 $data->{'dateofbirth'} = format_date($data->{'dateofbirth'});
73 $data->{'IS_ADULT'} = ($data->{'categorycode'} ne 'I');
75 $data->{'ethnicity'} = fixEthnicity($data->{'ethnicity'});
77 $data->{&expand_sex_into_predicate($data->{'sex'})} = 1;
79 if ($data->{'categorycode'} eq 'C'){
80 my $data2=borrdata('',$data->{'guarantor'});
81 $data->{'streetaddress'}=$data2->{'streetaddress'};
82 $data->{'city'}=$data2->{'city'};
83 $data->{'physstreet'}=$data2->{'physstreet'};
84 $data->{'streetcity'}=$data2->{'streetcity'};
85 $data->{'phone'}=$data2->{'phone'};
86 $data->{'phoneday'}=$data2->{'phoneday'};
87 $data->{'zipcode'} = $data2->{'zipcode'};
91 if ($data->{'ethnicity'} || $data->{'ethnotes'}) {
92 $template->param(printethnicityline => 1);
95 if ($data->{'categorycode'} ne 'C'){
96 $template->param(isguarantee => 1);
98 # It looks like the $i is only being returned to handle walking through
99 # the array, which is probably better done as a foreach loop.
101 my ($count,$guarantees)=findguarantees($data->{'borrowernumber'});
103 for (my $i=0;$i<$count;$i++){
104 push (@guaranteedata, {borrowernumber => $guarantees->[$i]->{'borrowernumber'},
105 cardnumber => $guarantees->[$i]->{'cardnumber'},
106 name => $guarantees->[$i]->{'firstname'} . " " . $guarantees->[$i]->{'surname'}});
108 $template->param(guaranteeloop => \@guaranteedata);
111 my ($guarantor)=findguarantor($data->{'borrowernumber'});
112 unless ($guarantor->{'borrowernumber'} == 0){
113 $template->param(guarantorborrowernumber => $guarantor->{'borrowernumber'}, guarantorcardnumber => $guarantor->{'cardnumber'});
118 $bor{'borrowernumber'}=$bornum;
120 # Converts the branchcode to the branch name
121 $data->{'branchcode'} = &getbranchname($data->{'branchcode'});
123 # Converts the categorycode to the description
124 $data->{'categorycode'} = &getborrowercategory($data->{'categorycode'});
126 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
128 my ($count,$issue)=borrissues($bornum);
129 my $today=ParseDate('today');
131 for (my $i=0;$i<$count;$i++){
132 my $datedue=ParseDate($issue->[$i]{'date_due'});
133 $issue->[$i]{'date_due'} = format_date($issue->[$i]{'date_due'});
134 my %row = %{$issue->[$i]};
135 if ($datedue < $today){
136 $row{'red'}=1; #print "<font color=red>";
138 #find the charge for an item
139 # FIXME - This is expecting
140 # &C4::Circulation::Renewals2::calc_charges, but it's getting
141 # &C4::Circulation::Circ2::calc_charges, which only returns one
142 # element, so itemtype isn't being set.
143 # But &C4::Circulation::Renewals2::calc_charges doesn't appear to
144 # return the correct item type either (or a properly-formatted
145 # charge, for that matter).
146 my ($charge,$itemtype)=calc_charges(undef,$dbh,$issue->[$i]{'itemnumber'},$bornum);
147 $row{'itemtype'}=&ItemType($itemtype);
148 $row{'charge'}=$charge;
150 #check item is not reserved
151 my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'});
153 print "<TD><a href=/cgi-bin/koha/request.pl?bib=$issue->[$i]{'biblionumber'}>On Request - no renewals</a></td></tr>";
154 # } elsif ($issue->[$i]->{'renewals'} > 0) {
155 # print "<TD>Previously Renewed - no renewals</td></tr>";
159 push (@issuedata, \%row);
162 my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
165 foreach my $reserveline (@$reserves) {
166 $reserveline->{'reservedate2'} = format_date($reserveline->{'reservedate'});
168 my %row = %$reserveline;
169 if ($reserveline->{'constrainttype'} eq 'o'){
170 $restitle=getreservetitle($reserveline->{'biblionumber'},$reserveline->{'borrowernumber'},$reserveline->{'reservedate'},$reserveline->{'rtimestamp'});
171 %row = (%row , %$restitle) if $restitle;
173 push (@reservedata, \%row);
176 $template->param($data);
180 issueloop => \@issuedata,
181 reserveloop => \@reservedata);
183 output_html_with_http_headers $input, $cookie, $template->output;