8 use C4::Circulation::Circ2;
11 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->{'debarred'} || $borr->{'gonenoaddress'} || $borr->{'lost'}){
35 $borr->{'flagged'} =1;
38 if ($borr->{'amountoutstanding'} > 5) {
39 $borr->{'amountoverfive'} = 1;
41 if (5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
42 $borr->{'amountoverzero'} = 1;
44 if ($borr->{'amountoutstanding'} < 0) {
45 $borr->{'amountlessthanzero'} = 1;
46 $borr->{'amountoutstanding'} = -1*($borr->{'amountoutstanding'});
49 $borr->{'amountoutstanding'} = sprintf "%.02f", $borr->{'amountoutstanding'};
54 $template->param(BORROWER_INFO => \@bordat);
55 $template->param(borrowernumber => $borrowernumber);
57 #get issued items ....
58 my $issues = getissues($borr);
61 my $overdues_count = 0;
64 foreach my $key (keys %$issues) {
65 my $issue = $issues->{$key};
66 $issue->{'date_due'} = format_date($issue->{'date_due'});
69 my ($restype, $res) = CheckReserves($issue->{'itemnumber'});
71 $issue->{'reserved'} = 1;
74 my ($numaccts,$accts,$total) = getboracctrecord(undef,$borr);
76 foreach my $ac (@$accts) {
77 if ($ac->{'itemnumber'} == $issue->{'itemnumber'}) {
78 $charges += $ac->{'amountoutstanding'} if $ac->{'accounttype'} eq 'F';
79 $charges += $ac->{'amountoutstanding'} if $ac->{'accounttype'} eq 'L';
82 $issue->{'charges'} = $charges;
84 # get publictype for icon
86 my $publictype = $issue->{'publictype'};
87 $issue->{$publictype} = 1;
89 # check if item is renewable
91 my $status = renewstatus(\%env,$borrowernumber, $issue->{'itemnumber'});
93 $issue->{'status'} = $status;
95 if ($issue->{'overdue'}) {
96 push @overdues, $issue;
98 $issue->{'overdue'} = 1;
100 $issue->{'issued'} = 1;
102 push @issuedat, $issue;
106 $template->param(ISSUES => \@issuedat);
107 $template->param(issues_count => $count);
109 $template->param(OVERDUES => \@overdues);
110 $template->param(overdues_count => $overdues_count);
112 my $branches = getbranches();
114 # now the reserved items....
115 my ($rcount, $reserves) = FindReserves(undef, $borrowernumber);
116 foreach my $res (@$reserves) {
117 $res->{'reservedate'} = format_date($res->{'reservedate'});
118 my $publictype = $res->{'publictype'};
119 $res->{$publictype} = 1;
120 $res->{'waiting'} = 1 if $res->{'found'} eq 'W';
121 $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
124 $template->param(RESERVES => $reserves);
125 $template->param(reserves_count => $rcount);
129 foreach my $res (@$reserves) {
130 if ($res->{'itemnumber'}) {
131 my $item = getiteminformation('',$res->{'itemnumber'},'');
132 $res->{'holdingbranch'} = $branches->{$item->{'holdingbranch'}}->{'branchname'};
133 $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
134 if($res->{'holdingbranch'} eq $res->{'branch'}){
135 $res->{'atdestination'} = 1;
141 $template->param(WAITING => \@waiting);
143 # current alert subscriptions
144 warn " B : $borrowernumber";
145 my $alerts = getalert($borrowernumber);
148 $_->{relatedto} = findrelatedto($_->{type},$_->{externalid});
151 $template->param(waiting_count => $wcount,
152 textmessaging => $borr->{textmessaging},
153 OpacPasswordChange => C4::Context->preference("OpacPasswordChange"),
156 output_html_with_http_headers $query, $cookie, $template->output;