8 use C4::Circulation::Circ2;
11 use C4::Interface::CGI::Output;
16 my ($template, $borrowernumber, $cookie)
17 = get_template_and_user({template_name => "opac-user.tmpl",
21 flagsrequired => {borrow => 1},
25 # get borrower information ....
26 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
28 $borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'});
29 $borr->{'expiry'} = format_date($borr->{'expiry'});
30 $borr->{'dateofbirth'} = format_date($borr->{'dateofbirth'});
31 $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'});
33 if ($borr->{'amountoutstanding'} > 5) {
34 $borr->{'amountoverfive'} = 1;
36 if (5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
37 $borr->{'amountoverzero'} = 1;
39 if ($borr->{'amountoutstanding'} < 0) {
40 $borr->{'amountlessthanzero'} = 1;
41 $borr->{'amountoutstanding'} = -1*($borr->{'amountoutstanding'});
44 $borr->{'amountoutstanding'} = sprintf "%.02f", $borr->{'amountoutstanding'};
49 $template->param(BORROWER_INFO => \@bordat);
50 $template->param(borrowernumber => $borrowernumber);
52 #get issued items ....
53 my $issues = getissues($borr);
56 my $overdues_count = 0;
59 foreach my $key (keys %$issues) {
60 my $issue = $issues->{$key};
61 $issue->{'date_due'} = format_date($issue->{'date_due'});
64 my ($restype, $res) = CheckReserves($issue->{'itemnumber'});
66 $issue->{'reserved'} = 1;
69 my ($numaccts,$accts,$total) = getboracctrecord(undef,$borr);
71 foreach my $ac (@$accts) {
72 if ($ac->{'itemnumber'} == $issue->{'itemnumber'}) {
73 $charges += $ac->{'amountoutstanding'} if $ac->{'accounttype'} eq 'F';
74 $charges += $ac->{'amountoutstanding'} if $ac->{'accounttype'} eq 'L';
77 $issue->{'charges'} = $charges;
79 # get publictype for icon
81 my $publictype = $issue->{'publictype'};
82 $issue->{$publictype} = 1;
84 # check if item is renewable
86 my $status = renewstatus(\%env,$borrowernumber, $issue->{'itemnumber'});
88 $issue->{'status'} = $status;
90 if ($issue->{'overdue'}) {
91 push @overdues, $issue;
93 $issue->{'overdue'} = 1;
95 $issue->{'issued'} = 1;
97 push @issuedat, $issue;
101 $template->param(ISSUES => \@issuedat);
102 $template->param(issues_count => $count);
104 $template->param(OVERDUES => \@overdues);
105 $template->param(overdues_count => $overdues_count);
107 my $branches = getbranches();
109 # now the reserved items....
110 my ($rcount, $reserves) = FindReserves(undef, $borrowernumber);
111 foreach my $res (@$reserves) {
112 $res->{'reservedate'} = format_date($res->{'reservedate'});
113 my $publictype = $res->{'publictype'};
114 $res->{$publictype} = 1;
115 $res->{'waiting'} = 1 if $res->{'found'} eq 'W';
116 $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
119 $template->param(RESERVES => $reserves);
120 $template->param(reserves_count => $rcount);
124 foreach my $res (@$reserves) {
125 if ($res->{'itemnumber'}) {
126 my $item = getiteminformation('',$res->{'itemnumber'},'');
127 $res->{'holdingbranch'} = $branches->{$item->{'holdingbranch'}}->{'branchname'};
128 $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
129 if($res->{'holdingbranch'} eq $res->{'branch'}){
130 $res->{'atdestination'} = 1;
137 $template->param(WAITING => \@waiting);
138 $template->param(waiting_count => $wcount,
139 LibraryName => C4::Context->preference("LibraryName"),
140 suggestion => C4::Context->preference("suggestion"),
141 virtualshelves => C4::Context->preference("virtualshelves"),
142 textmessaging => $borr->{textmessaging},
145 output_html_with_http_headers $query, $cookie, $template->output;