use C4::Interface::CGI::Output;
use C4::Interface::CGI::Template;
use CGI;
-use C4::Search;
+use C4::Members;
use Date::Manip;
use C4::Date;
use C4::Reserves2;
use C4::Circulation::Circ2;
use C4::Koha;
+use C4::Letters;
use HTML::Template;
my $dbh = C4::Context->dbh;
});
my $bornum=$input->param('bornum');
-
#start the page and read in includes
-
my $data=borrdata('',$bornum);
+my (undef,undef,undef,$category_type)=getborrowercategory($data->{'categorycode'});
$template->param($data->{'categorycode'} => 1); # in template <TMPL_IF name="I"> => instutitional (A for Adult & C for children)
-
$data->{'dateenrolled'} = format_date($data->{'dateenrolled'});
-$data->{'expiry'} = format_date($data->{'expiry'});
+$data->{'dateexpiry'} = format_date($data->{'dateexpiry'});
$data->{'dateofbirth'} = format_date($data->{'dateofbirth'});
$data->{'IS_ADULT'} = ($data->{'categorycode'} ne 'I');
$data->{&expand_sex_into_predicate($data->{'sex'})} = 1;
-if ($data->{'categorycode'} eq 'C'){
- my $data2=borrdata('',$data->{'guarantor'});
- $data->{'streetaddress'}=$data2->{'streetaddress'};
+if ($category_type eq 'C' and $data->{'guarantorid'} ne '0' ){
+ my $data2=borrdata('',$data->{'guarantorid'});
+ $data->{'address'}=$data2->{'address'};
$data->{'city'}=$data2->{'city'};
- $data->{'physstreet'}=$data2->{'physstreet'};
- $data->{'streetcity'}=$data2->{'streetcity'};
+ $data->{'B_address'}=$data2->{'B_address'};
+ $data->{'B_city'}=$data2->{'B_city'};
$data->{'phone'}=$data2->{'phone'};
- $data->{'phoneday'}=$data2->{'phoneday'};
+ $data->{'mobile'}=$data2->{'mobile'};
$data->{'zipcode'} = $data2->{'zipcode'};
}
-
if ($data->{'ethnicity'} || $data->{'ethnotes'}) {
$template->param(printethnicityline => 1);
}
-
-if ($data->{'categorycode'} ne 'C'){
+if ($category_type ne 'C'){
$template->param(isguarantee => 1);
# FIXME
# It looks like the $i is only being returned to handle walking through
name => $guarantees->[$i]->{'firstname'} . " " . $guarantees->[$i]->{'surname'}});
}
$template->param(guaranteeloop => \@guaranteedata);
-
+ ($template->param(adultborrower=>1)) if ($category_type eq 'A');
} else {
- my ($guarantor)=findguarantor($data->{'borrowernumber'});
- unless ($guarantor->{'borrowernumber'} == 0){
- $template->param(guarantorborrowernumber => $guarantor->{'borrowernumber'}, guarantorcardnumber => $guarantor->{'cardnumber'});
+ my ($guarantorid)=findguarantor($data->{guarantorid});
+ if ($guarantorid->{'borrowernumber'}){
+ $template->param(guarantorborrowernumber => $guarantorid->{'borrowernumber'}, guarantorcardnumber => $guarantorid->{'cardnumber'});
}
}
+#Independant branches management
+my $unvalidlibrarian = ((C4::Context->preference("IndependantBranches")) && (C4::Context->userenv->{flags}!=1) && ($data->{'branchcode'} ne C4::Context->userenv->{branch}));
+
my %bor;
$bor{'borrowernumber'}=$bornum;
# Converts the branchcode to the branch name
-$data->{'branchcode'} = &getbranchname($data->{'branchcode'});
+my $samebranch;
+if (C4::Context->preference("IndependantBranches")) {
+ my $userenv = C4::Context->userenv;
+ unless ($userenv->{flags} == 1){
+ $samebranch = ($data->{'branchcode'} eq $userenv->{branch});
+ }
+ $samebranch =1 if ($userenv->{flags} == 1);
+}
+
+$data->{'branchname'} = ((getbranchdetail($data->{'branchcode'}))->{'branchname'});
# Converts the categorycode to the description
-$data->{'categorycode'} = &getborrowercategory($data->{'categorycode'});
+($data->{'categorycode'},undef,undef) = &getborrowercategory($data->{'categorycode'});
my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
+#
+# current issues
+#
my ($count,$issue)=borrissues($bornum);
+
my $today=ParseDate('today');
my @issuedata;
my $totalprice = 0;
+my $toggle = 0;
for (my $i=0;$i<$count;$i++){
my $datedue=ParseDate($issue->[$i]{'date_due'});
$issue->[$i]{'date_due'} = format_date($issue->[$i]{'date_due'});
if ($datedue < $today){
$row{'red'}=1; #print "<font color=red>";
}
+ $row{toggle} = $toggle++%2;
#find the charge for an item
# FIXME - This is expecting
# &C4::Circulation::Renewals2::calc_charges, but it's getting
# return the correct item type either (or a properly-formatted
# charge, for that matter).
my ($charge,$itemtype)=calc_charges($dbh,$issue->[$i]{'itemnumber'},$bornum);
- $row{'itemtype'}=&ItemType($itemtype);
- $row{'charge'}=$charge;
+
+ my $itemtypeinfo = getitemtypeinfo($itemtype);
+ $row{'itemtype_description'} = $itemtypeinfo->{description};
+ $row{'itemtype_image'} = $itemtypeinfo->{imageurl};
+
+ $row{'charge'}= sprintf("%.2f",$charge);
#check item is not reserved
my ($restype,$reserves)=CheckReserves($issue->[$i]{'itemnumber'});
push (@issuedata, \%row);
}
+#
+# find reserves
+#
my ($rescount,$reserves)=FindReserves('',$bornum); #From C4::Reserves2
-
my @reservedata;
+$toggle = 0;
foreach my $reserveline (@$reserves) {
$reserveline->{'reservedate2'} = format_date($reserveline->{'reservedate'});
my $restitle;
my %row = %$reserveline;
+ $row{toggle} = $toggle++%2;
if ($reserveline->{'constrainttype'} eq 'o'){
$restitle=getreservetitle($reserveline->{'biblionumber'},$reserveline->{'borrowernumber'},$reserveline->{'reservedate'},$reserveline->{'rtimestamp'});
%row = (%row , %$restitle) if $restitle;
push (@reservedata, \%row);
}
+# current alert subscriptions
+my $alerts = getalert($bornum);
+foreach (@$alerts) {
+ $_->{$_->{type}}=1;
+ $_->{relatedto} = findrelatedto($_->{type},$_->{externalid});
+}
+my $picture;
+my $htdocs = C4::Context->config('intrahtdocs');
+$picture = "/borrowerimages/".$bornum.".jpg";
+if (-e $htdocs."$picture")
+{
+ $template->param(picture => $picture)
+};
$template->param($data);
$template->param(
bornum => $bornum,
- totalprice =>$totalprice,
- totaldue =>$total,
+ totalprice =>sprintf("%.2f",$totalprice),
+ totaldue => sprintf("%.2f",$total),
issueloop => \@issuedata,
- reserveloop => \@reservedata);
+ unvalidlibrarian => $unvalidlibrarian,
+ reserveloop => \@reservedata,
+ intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+ patronimages => C4::Context->preference("patronimages"),
+ );
output_html_with_http_headers $input, $cookie, $template->output;