use Modern::Perl;
-use CGI;
+use CGI qw ( -utf8 );
use C4::Context;
use C4::Auth qw/:DEFAULT get_session/;
use C4::Output;
use C4::Circulation;
+use C4::Koha;
use Koha::DateUtils;
use Koha::Database;
+use Koha::BiblioFrameworks;
+use Koha::Checkouts;
my $cgi = new CGI;
-my ( $template, $librarian, $cookie ) = get_template_and_user(
+my ( $template, $librarian, $cookie, $flags ) = get_template_and_user(
{
- template_name => "circ/renew.tmpl",
+ template_name => "circ/renew.tt",
query => $cgi,
type => "intranet",
authnotrequired => 0,
my ( $item, $issue, $borrower );
my $error = q{};
+my ( $soonest_renew_date, $latest_auto_renew_date );
if ($barcode) {
$item = $schema->resultset("Item")->single( { barcode => $barcode } );
if ($item) {
- $issue = $item->issues()->single();
+ $issue = $item->issue();
if ($issue) {
CanBookBeRenewed( $borrower->borrowernumber(),
$item->itemnumber(), $override_limit );
- if ( $error eq 'on_reserve' ) {
+ if ( $error && ($error eq 'on_reserve') ) {
if ($override_holds) {
$can_renew = 1;
$error = undef;
}
}
+ if ( $error && ($error eq 'too_soon' or $error eq 'auto_too_soon') ) {
+ $soonest_renew_date = C4::Circulation::GetSoonestRenewDate(
+ $borrower->borrowernumber(),
+ $item->itemnumber(),
+ );
+ }
+ if ( $error && ( $error eq 'auto_too_late' ) ) {
+ $latest_auto_renew_date = C4::Circulation::GetLatestAutoRenewDate(
+ $borrower->borrowernumber(),
+ $item->itemnumber(),
+ );
+ }
if ($can_renew) {
- my $date_due = AddRenewal( undef, $item->itemnumber() );
+ my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
+ my $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode );
$template->param( date_due => $date_due );
}
}
item => $item,
issue => $issue,
borrower => $borrower,
- error => $error
+ error => $error,
+ soonestrenewdate => $soonest_renew_date,
+ latestautorenewdate => $latest_auto_renew_date,
);
}
+# Checking if there is a Fast Cataloging Framework
+$template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );
+
+my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count;
+$template->param( pending_checkout_notes => $pending_checkout_notes );
+
output_html_with_http_headers( $cgi, $cookie, $template->output );