Bug 24488: Simplify searches
[srvgit] / circ / renew.pl
index c3f1d2a..acce777 100755 (executable)
@@ -29,25 +29,26 @@ use Koha::DateUtils;
 use Koha::Database;
 use Koha::BiblioFrameworks;
 
-my $cgi = new CGI;
+my $cgi = CGI->new;
 
 my ( $template, $librarian, $cookie, $flags ) = get_template_and_user(
     {
         template_name   => "circ/renew.tt",
         query           => $cgi,
         type            => "intranet",
-        authnotrequired => 0,
         flagsrequired   => { circulate => "circulate_remaining_permissions" },
     }
 );
 
 my $schema = Koha::Database->new()->schema();
 
-my $barcode        = $cgi->param('barcode');
+my $barcode        = $cgi->param('barcode') // '';
+my $unseen         = $cgi->param('unseen') || 0;
 $barcode =~ s/^\s*|\s*$//g; # remove leading/trailing whitespae
 $barcode = barcodedecode($barcode) if( $barcode && C4::Context->preference('itemBarcodeInputFilter'));
 my $override_limit = $cgi->param('override_limit');
 my $override_holds = $cgi->param('override_holds');
+my $hard_due_date  = $cgi->param('hard_due_date');
 
 my ( $item, $issue, $borrower );
 my $error = q{};
@@ -99,7 +100,18 @@ if ($barcode) {
                     if ( $cgi->param('renewonholdduedate') ) {
                         $date_due = dt_from_string( scalar $cgi->param('renewonholdduedate'));
                     }
-                    $date_due = AddRenewal( undef, $item->itemnumber(), $branchcode, $date_due );
+                    if ( C4::Context->preference('SpecifyDueDate') && $hard_due_date ) {
+                        $date_due = dt_from_string( $hard_due_date );
+                    }
+                    $date_due = AddRenewal(
+                        undef,
+                        $item->itemnumber(),
+                        $branchcode,
+                        $date_due,
+                        undef,
+                        undef,
+                        !$unseen
+                    );
                     $template->param( date_due => $date_due );
                 }
             }
@@ -125,6 +137,7 @@ if ($barcode) {
     );
 }
 
+$template->param( hard_due_date => ($hard_due_date ? output_pref({ str => $hard_due_date, dateformat => 'iso' }) : undef) );
 # Checking if there is a Fast Cataloging Framework
 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' );