8 use C4::Circulation::Circ2;
9 use C4::Circulation::Renewals2;
12 use C4::Interface::CGI::Output;
17 my ($template, $borrowernumber, $cookie)
18 = get_template_and_user({template_name => "opac-user.tmpl",
22 flagsrequired => {borrow => 1},
26 # get borrower information ....
27 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
29 $borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'});
30 $borr->{'expiry'} = format_date($borr->{'expiry'});
31 $borr->{'dateofbirth'} = format_date($borr->{'dateofbirth'});
32 $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'});
34 if ($borr->{'amountoutstanding'} > 5) {
35 $borr->{'amountoverfive'} = 1;
37 if (5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
38 $borr->{'amountoverzero'} = 1;
40 if ($borr->{'amountoutstanding'} < 0) {
41 $borr->{'amountlessthanzero'} = 1;
42 $borr->{'amountoutstanding'} = -1*($borr->{'amountoutstanding'});
45 $borr->{'amountoutstanding'} = sprintf "\$%.02f", $borr->{'amountoutstanding'};
50 $template->param(BORROWER_INFO => \@bordat);
51 $template->param(borrowernumber => $borrowernumber);
53 #get issued items ....
54 my $issues = getissues($borr);
57 my $overdues_count = 0;
60 foreach my $key (keys %$issues) {
61 my $issue = $issues->{$key};
62 $issue->{'date_due'} = format_date($issue->{'date_due'});
65 my ($restype, $res) = CheckReserves($issue->{'itemnumber'});
67 $issue->{'reserved'} = 1;
70 my ($numaccts,$accts,$total) = getboracctrecord(undef,$borr);
72 foreach my $ac (@$accts) {
73 if ($ac->{'itemnumber'} == $issue->{'itemnumber'}) {
74 $charges += $ac->{'amountoutstanding'} if $ac->{'accounttype'} eq 'F';
75 $charges += $ac->{'amountoutstanding'} if $ac->{'accounttype'} eq 'L';
78 $issue->{'charges'} = $charges;
80 # get publictype for icon
82 my $publictype = $issue->{'publictype'};
83 $issue->{$publictype} = 1;
85 # check if item is renewable
87 my $status = renewstatus(\%env,$borrowernumber, $issue->{'itemnumber'});
89 $issue->{'renewable'} = $status;
91 if ($issue->{'overdue'}) {
92 push @overdues, $issue;
94 $issue->{'overdue'} = 1;
96 $issue->{'issued'} = 1;
98 push @issuedat, $issue;
102 $template->param(ISSUES => \@issuedat);
103 $template->param(issues_count => $count);
105 $template->param(OVERDUES => \@overdues);
106 $template->param(overdues_count => $overdues_count);
108 my $branches = getbranches();
110 # now the reserved items....
111 my ($rcount, $reserves) = FindReserves(undef, $borrowernumber);
112 foreach my $res (@$reserves) {
113 $res->{'reservedate'} = format_date($res->{'reservedate'});
114 my $publictype = $res->{'publictype'};
115 $res->{$publictype} = 1;
116 $res->{'waiting'} = 1 if $res->{'found'} eq 'W';
117 $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
120 $template->param(RESERVES => $reserves);
121 $template->param(reserves_count => $rcount);
125 foreach my $res (@$reserves) {
126 if ($res->{'itemnumber'}) {
127 $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
133 # $template->param(WAITING => \@waiting);
134 $template->param(waiting_count => $wcount);
136 output_html_with_http_headers $query, $cookie, $template->output;