6 use C4::Output; # gettemplate
7 use C4::Auth; # checkauth, getborrowernumber.
9 use C4::Circulation::Circ2;
15 $flagsrequired->{borrow}=1;
17 my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 0, $flagsrequired);
19 my $template = gettemplate("opac-user.tmpl", "opac");
21 # get borrower information ....
22 my $borrowernumber = getborrowernumber($loggedinuser);
23 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
25 $borr->{'dateenrolled'} = slashifyDate($borr->{'dateenrolled'});
26 $borr->{'expiry'} = slashifyDate($borr->{'expiry'});
27 $borr->{'dateofbirth'} = slashifyDate($borr->{'dateofbirth'});
28 $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'});
30 if ($borr->{'amountoutstanding'} > 5) {
31 $borr->{'amountoverfive'} = 1;
33 if (5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
34 $borr->{'amountoverzero'} = 1;
36 if ($borr->{'amountoutstanding'} < 0) {
37 $borr->{'amountlessthanzero'} = 1;
38 $borr->{'amountoutstanding'} = -1*($borr->{'amountoutstanding'});
41 $borr->{'amountoutstanding'} = sprintf "\$%.02f", $borr->{'amountoutstanding'};
46 $template->param(BORROWER_INFO => \@bordat);
48 #get issued items ....
49 my $issues = getissues($borr);
53 foreach my $key (keys %$issues) {
54 my $issue = $issues->{$key};
55 $issue->{'date_due'} = slashifyDate($issue->{'date_due'});
56 if ($issue->{'overdue'}) {
57 $issue->{'status'} = "<font color='red'>OVERDUE</font>";
59 $issue->{'status'} = "Issued";
62 my ($restype, $res) = CheckReserves($issue->{'itemnumber'});
64 $issue->{'status'} .= " Reserved";
66 my ($charges, $itemtype) = calc_charges(undef, undef, $issue->{'itemnumber'}, $borrowernumber);
67 $issue->{'charges'} = $charges;
68 push @issuedat, $issue;
72 $template->param(ISSUES => \@issuedat);
73 $template->param(issues_count => $count);
75 # now the reserved items....
76 my ($rcount, $reserves) = FindReserves(undef, $borrowernumber);
77 foreach my $res (@$reserves) {
78 $res->{'reservedate'} = slashifyDate($res->{'reservedate'});
81 $template->param(RESERVES => $reserves);
82 $template->param(reserves_count => $rcount);
84 my $branches = getbranches();
87 foreach my $res (@$reserves) {
88 if ($res->{'itemnumber'}) {
89 $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
95 $template->param(WAITING => \@waiting);
96 $template->param(waiting_count => $wcount);
98 $template->param(loggedinuser => $loggedinuser);
99 print "Content-Type: text/html\n\n", $template->output;