3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
25 use C4
::Circulation
qw( GetIssuingCharges );
34 my $borrowernumber = $input->param('borrowernumber');
36 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
38 template_name
=> "members/moremember-print.tt",
41 flagsrequired
=> { circulate
=> "circulate_remaining_permissions" },
46 my $logged_in_user = Koha
::Patrons
->find( $loggedinuser );
47 my $patron = Koha
::Patrons
->find( $borrowernumber );
48 output_and_exit_if_error
( $input, $cookie, $template, { module
=> 'members', logged_in_user
=> $logged_in_user, current_patron
=> $patron } );
50 my $total = $patron->account->balance;
51 my $accts = Koha
::Account
::Lines
->search(
52 { borrowernumber
=> $patron->borrowernumber, amountoutstanding
=> { '!=' => 0 } },
53 { order_by
=> { -desc
=> 'accountlines_id' } }
58 my $holds_rs = Koha
::Holds
->search(
59 { borrowernumber
=> $borrowernumber },
68 issues
=> build_issue_data
( $borrowernumber ),
69 totalprice
=> $totalprice,
71 reserves
=> build_reserve_data
( $holds_rs ),
74 output_html_with_http_headers
$input, $cookie, $template->output;
76 sub build_issue_data
{
77 my ( $borrowernumber ) = @_;
78 my $patron = Koha
::Patrons
->find( $borrowernumber );
79 return unless $patron;
81 my $pending_checkouts = $patron->pending_checkouts->search( {},
82 { order_by
=> [ { -desc
=> 'date_due' }, { -asc
=> 'issue_id' } ] } );
86 while ( my $c = $pending_checkouts->next ) {
87 my $checkout = $c->unblessed_all_relateds;
89 $totalprice += $checkout->{replacementprice
}
90 if $checkout->{replacementprice
};
92 #find the charge for an item
93 my ( $charge, $itemtype ) =
94 GetIssuingCharges
( $checkout->{itemnumber
}, $borrowernumber );
96 $checkout->{charge
} = $charge;
98 $checkout->{overdue
} = $c->is_overdue;
100 push @checkouts, $checkout;
107 sub build_reserve_data
{
108 my $reserves = shift;
112 my $today = dt_from_string
();
113 $today->truncate( to
=> 'day' );
115 while ( my $reserve = $reserves->next() ) {
118 title
=> $reserve->biblio()->title(),
119 author
=> $reserve->biblio()->author(),
120 reservedate
=> $reserve->reservedate(),
121 expirationdate
=> $reserve->expirationdate(),
122 waiting_at
=> $reserve->branch()->branchname(),
125 push( @
{$return}, $row );
128 @
{$return} = sort { $a->{reservedate
} <=> $b->{reservedate
} } @
{$return};