# Issues management
if ( $cgi->param('show_loans') && $cgi->param('show_loans') eq "1" ) {
+ my $per_page = $cgi->param('loans_per_page');
+ my $page = $cgi->param('loans_page');
+
my $pending_checkouts = $patron->pending_checkouts;
+
+ if ($page || $per_page) {
+ $page ||= 1;
+ $per_page ||= 10;
+ $borrower->{total_loans} = $pending_checkouts->count();
+ $pending_checkouts = $pending_checkouts->search(undef, {
+ rows => $per_page,
+ page => $page,
+ });
+ }
+
my @checkouts;
while ( my $c = $pending_checkouts->next ) {
# FIXME We should only retrieve what is needed in the template
$borrower->{'loans'}->{'loan'} = \@checkouts;
}
- if ( $cgi->param('show_attributes') eq "1" ) {
+ my $show_attributes = $cgi->param('show_attributes');
+ if ( $show_attributes && $show_attributes eq "1" ) {
my $attrs = GetBorrowerAttributes( $borrowernumber, 1 );
$borrower->{'attributes'} = $attrs;
}
my @renewal = CanBookBeRenewed( $borrowernumber, $itemnumber );
if ( $renewal[0] ) { AddRenewal( $borrowernumber, $itemnumber ); }
- return unless $item; # FIXME should be handled
-
my $issue = $item->checkout;
- return $issue; # FIXME should be handled
+ return unless $issue; # FIXME should be handled
# Hashref building
my $out;
$out->{'renewals'} = $issue->renewals;
- $out->{date_due} = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%S');
+ $out->{date_due} = dt_from_string($issue->date_due)->strftime('%Y-%m-%d %H:%M');
$out->{'success'} = $renewal[0];
$out->{'error'} = $renewal[1];