use C4::Members;
use C4::Koha qw( getitemtypeinfo );
use C4::Circulation qw( GetIssuingCharges );
+use C4::Reserves;
+use C4::Items;
+use Koha::Holds;
my $input = CGI->new;
my $borrowernumber = $input->param('borrowernumber');
my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
foreach my $accountline (@$accts) {
- $accountline->{amount} = sprintf( '%.2f', $accountline->{amount} )
- if ( $accountline->{amount} ) ;
- $accountline->{amountoutstanding} = sprintf( '%.2f', $accountline->{amountoutstanding} )
- if ( $accountline->{amountoutstanding} );
-
if ( $accountline->{accounttype} ne 'F'
&& $accountline->{accounttype} ne 'FU' )
{
}
}
-my $roadtype =
- C4::Koha::GetAuthorisedValueByCode( 'ROADTYPE', $data->{streettype} );
-$roadtype = '' if ( ! $roadtype );
-
our $totalprice = 0;
-my $total_format = '';
-$total_format = sprintf( "%.2f", $total ) if ($total);
+
+my $holds_rs = Koha::Holds->search(
+ { borrowernumber => $borrowernumber },
+);
$template->param(
%$data,
borrowernumber => $borrowernumber,
- address => $data->{'streetnumber'} . " $roadtype " . $data->{'address'},
accounts => $accts,
- totaldue => $total_format,
+ totaldue => $total,
issues => build_issue_data( GetPendingIssues($borrowernumber) ),
totalprice => $totalprice,
+
+ reserves => build_reserve_data( $holds_rs ),
);
output_html_with_http_headers $input, $cookie, $template->output;
@{$return} = sort { $a->{date_due} eq $b->{date_due} } @{$return};
return $return;
+
+}
+
+sub build_reserve_data {
+ my $reserves = shift;
+
+ my $return = [];
+
+ my $today = DateTime->now( time_zone => C4::Context->tz );
+ $today->truncate( to => 'day' );
+
+ while ( my $reserve = $reserves->next() ) {
+
+ my $row = {
+ title => $reserve->biblio()->title(),
+ author => $reserve->biblio()->author(),
+ reservedate => $reserve->reservedate(),
+ expirationdate => $reserve->expirationdate(),
+ waiting_at => $reserve->branch()->branchname(),
+ };
+
+ push( @{$return}, $row );
+ }
+
+ @{$return} = sort { $a->{reservedate} <=> $b->{reservedate} } @{$return};
+
+ return $return;
}