use Koha::Patron::Messages;
use Koha::Patron::Discharge;
use Koha::Patrons;
+use Koha::Ratings;
+use Koha::Token;
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
template_name => "opac-user.tt",
query => $query,
type => "opac",
- authnotrequired => 0,
debug => 1,
}
);
# get borrower information ....
my $patron = Koha::Patrons->find( $borrowernumber );
+
+if( $query->param('update_arc') && C4::Context->preference("AllowPatronToControlAutorenewal") ){
+ die "Wrong CSRF token"
+ unless Koha::Token->new->check_csrf({
+ session_id => scalar $query->cookie('CGISESSID'),
+ token => scalar $query->param('csrf_token'),
+ });
+
+ my $autorenew_checkouts = $query->param('borrower_autorenew_checkouts');
+ $patron->autorenew_checkouts( $autorenew_checkouts )->store() if defined $autorenew_checkouts;
+}
+
my $borr = $patron->unblessed;
# unblessed is a hash vs. object/undef. Hence the use of curly braces here.
my $borcat = $borr ? $borr->{categorycode} : q{};
surname => $borr->{surname},
RENEW_ERROR => $renew_error,
borrower => $borr,
+ csrf_token => Koha::Token->new->generate_csrf({
+ session_id => scalar $query->cookie('CGISESSID'),
+ }),
);
#get issued items ....
my @issuedat;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my $pending_checkouts = $patron->pending_checkouts->search({}, { order_by => [ { -desc => 'date_due' }, { -asc => 'issue_id' } ] });
+my $are_renewable_items = 0;
if ( $pending_checkouts->count ) { # Useless test
while ( my $c = $pending_checkouts->next ) {
my $issue = $c->unblessed_all_relateds;
( $issue->{'renewalfee'}, $issue->{'renewalitemtype'} ) = GetIssuingCharges( $issue->{'itemnumber'}, $borrowernumber );
$issue->{itemtype_object} = Koha::ItemTypes->find( Koha::Items->find( $issue->{itemnumber} )->effective_itemtype );
if($status && C4::Context->preference("OpacRenewalAllowed")){
+ $are_renewable_items = 1;
$issue->{'status'} = $status;
}
$issue->{'description'} = $itemtypes->{$itemtype}->{'description'};
}
+ if ( C4::Context->preference('OpacStarRatings') eq 'all' ) {
+ my $ratings = Koha::Ratings->search({ biblionumber => $issue->{biblionumber} });
+ $issue->{ratings} = $ratings;
+ $issue->{my_rating} = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
+ }
+
$issue->{biblio_object} = Koha::Biblios->find($issue->{biblionumber});
push @issuedat, $issue;
$count++;
}
}
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
-$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count);
+$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count) || !$are_renewable_items;
$template->param( ISSUES => \@issuedat );
$template->param( issues_count => $count );