Lines 75-110
output_html_with_http_headers $input, $cookie, $template->output;
Link Here
|
75 |
|
75 |
|
76 |
sub build_issue_data { |
76 |
sub build_issue_data { |
77 |
my ( $borrowernumber ) = @_; |
77 |
my ( $borrowernumber ) = @_; |
78 |
my $issues = GetPendingIssues( $borrowernumber ); |
78 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
|
|
79 |
return unless $patron; |
79 |
|
80 |
|
80 |
my $return = []; |
81 |
my $pending_checkouts = $patron->pending_checkouts->search( {}, |
|
|
82 |
{ order_by => [ { -desc => 'date_due' }, { -asc => 'issue_id' } ] } ); |
81 |
|
83 |
|
82 |
my $today = DateTime->now( time_zone => C4::Context->tz ); |
84 |
my @checkouts; |
83 |
$today->truncate( to => 'day' ); |
|
|
84 |
|
85 |
|
85 |
foreach my $issue ( @{$issues} ) { |
86 |
while ( my $c = $pending_checkouts->next ) { |
|
|
87 |
my $checkout = $c->unblessed_all_relateds; |
86 |
|
88 |
|
87 |
my %row = %{$issue}; |
89 |
$totalprice += $checkout->{replacementprice} |
88 |
$totalprice += $issue->{replacementprice} |
90 |
if $checkout->{replacementprice}; |
89 |
if ( $issue->{replacementprice} ); |
|
|
90 |
|
91 |
|
91 |
#find the charge for an item |
92 |
#find the charge for an item |
92 |
my ( $charge, $itemtype ) = |
93 |
my ( $charge, $itemtype ) = |
93 |
GetIssuingCharges( $issue->{itemnumber}, $borrowernumber ); |
94 |
GetIssuingCharges( $checkout->{itemnumber}, $borrowernumber ); |
94 |
|
95 |
|
95 |
$itemtype = Koha::ItemTypes->find( $itemtype ); |
96 |
$itemtype = Koha::ItemTypes->find( $itemtype ); |
96 |
$row{'itemtype_description'} = $itemtype->description; #FIXME Should not it be translated_description |
97 |
$checkout->{itemtype_description} = $itemtype->description; #FIXME Should not it be translated_description |
97 |
|
98 |
|
98 |
$row{'charge'} = sprintf( "%.2f", $charge ); |
99 |
$checkout->{charge} = sprintf( "%.2f", $charge ); # TODO Should be done in the template using Price |
99 |
|
100 |
|
100 |
$row{date_due} = $row{date_due_sql}; |
101 |
$checkout->{overdue} = $c->is_overdue; |
101 |
|
102 |
|
102 |
push( @{$return}, \%row ); |
103 |
push @checkouts, $checkout; |
103 |
} |
104 |
} |
104 |
|
105 |
|
105 |
@{$return} = sort { $a->{date_due} eq $b->{date_due} } @{$return}; |
106 |
return \@checkouts; |
106 |
|
|
|
107 |
return $return; |
108 |
|
107 |
|
109 |
} |
108 |
} |
110 |
|
109 |
|
111 |
- |
|
|