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