3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA 02111-1307 USA
29 use C4::Interface::CGI::Output;
33 use C4::Branch; # GetBranches
36 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
38 template_name => "opac-user.tmpl",
42 flagsrequired => { borrow => 1 },
47 # get borrower information ....
48 my ( $borr, $flags ) = GetMemberDetails( $borrowernumber );
50 $borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} );
51 $borr->{'expiry'} = format_date( $borr->{'expiry'} );
52 $borr->{'dateofbirth'} = format_date( $borr->{'dateofbirth'} );
53 $borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} );
55 if ( $borr->{'debarred'} || $borr->{'gonenoaddress'} || $borr->{'lost'} ) {
56 $borr->{'flagged'} = 1;
59 if ( $borr->{'amountoutstanding'} > 5 ) {
60 $borr->{'amountoverfive'} = 1;
62 if ( 5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
63 $borr->{'amountoverzero'} = 1;
65 if ( $borr->{'amountoutstanding'} < 0 ) {
66 $borr->{'amountlessthanzero'} = 1;
67 $borr->{'amountoutstanding'} = -1 * ( $borr->{'amountoutstanding'} );
70 $borr->{'amountoutstanding'} = sprintf "%.02f", $borr->{'amountoutstanding'};
75 $template->param( BORROWER_INFO => \@bordat );
76 $template->param( borrowernumber => $borrowernumber );
78 #get issued items ....
79 my $issues = GetBorrowerIssues($borr);
82 my $overdues_count = 0;
85 my $imgdir = getitemtypeimagesrc();
86 my $itemtypes = GetItemTypes();
87 foreach my $issue ( @$issues ) {
90 my ( $restype, $res ) = CheckReserves( $issue->{'itemnumber'} );
92 $issue->{'reserved'} = 1;
95 my ( $numaccts, $accts, $total ) = getboracctrecord( undef, $borr );
97 foreach my $ac (@$accts) {
98 if ( $ac->{'itemnumber'} == $issue->{'itemnumber'} ) {
99 $charges += $ac->{'amountoutstanding'}
100 if $ac->{'accounttype'} eq 'F';
101 $charges += $ac->{'amountoutstanding'}
102 if $ac->{'accounttype'} eq 'L';
105 $issue->{'charges'} = $charges;
107 # get publictype for icon
109 my $publictype = $issue->{'publictype'};
110 $issue->{$publictype} = 1;
112 # check if item is renewable
114 my $status = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
116 $issue->{'status'} = $status;
118 if ( $issue->{'overdue'} ) {
119 push @overdues, $issue;
121 $issue->{'overdue'} = 1;
124 $issue->{'issued'} = 1;
127 my $itemtype = $issue->{'itemtype'};
129 $issue->{'imageurl'} = $imgdir."/".$itemtypes->{$itemtype}->{'imageurl'};
130 $issue->{'description'} = $itemtypes->{$itemtype}->{'description'};
132 push @issuedat, $issue;
136 $template->param( ISSUES => \@issuedat );
137 $template->param( issues_count => $count );
139 $template->param( OVERDUES => \@overdues );
140 $template->param( overdues_count => $overdues_count );
142 my $branches = GetBranches();
144 # now the reserved items....
145 my ( $rcount, $reserves ) = FindReserves( undef, $borrowernumber );
146 foreach my $res (@$reserves) {
147 $res->{'reservedate'} = format_date( $res->{'reservedate'} );
148 my $publictype = $res->{'publictype'};
149 $res->{$publictype} = 1;
150 $res->{'waiting'} = 1 if $res->{'found'} eq 'W';
151 $res->{'branch'} = $branches->{ $res->{'branchcode'} }->{'branchname'};
152 my $biblioData = GetBiblioData($res->{'biblionumber'});
153 $res->{'reserves_title'} = $biblioData->{'title'};
156 $template->param( RESERVES => $reserves );
157 $template->param( reserves_count => $rcount );
161 foreach my $res (@$reserves) {
162 if ( $res->{'itemnumber'} ) {
163 my $item = GetItem( $res->{'itemnumber'});
164 $res->{'holdingbranch'} =
165 $branches->{ $item->{'holdingbranch'} }->{'branchname'};
166 $res->{'branch'} = $branches->{ $res->{'branchcode'} }->{'branchname'};
167 if ( $res->{'holdingbranch'} eq $res->{'branch'} ) {
168 $res->{'atdestination'} = 1;
170 my $biblioData = GetBiblioData($res->{'biblionumber'});
171 $res->{'waiting_title'} = $biblioData->{'title'};
177 $template->param( WAITING => \@waiting );
179 # current alert subscriptions
180 my $alerts = getalert($borrowernumber);
181 foreach ( @$alerts ) {
182 $_->{ $_->{type} } = 1;
183 $_->{relatedto} = findrelatedto( $_->{type}, $_->{externalid} );
187 waiting_count => $wcount,
188 textmessaging => $borr->{textmessaging},
191 output_html_with_http_headers $query, $cookie, $template->output;