Bug 11292 - barcode scanner clicking 'save'
[koha_fer] / misc / cronjobs / longoverdue.pl
index 2179d10..0f64712 100755 (executable)
@@ -35,18 +35,22 @@ BEGIN {
 }
 use C4::Context;
 use C4::Items;
+use C4::Circulation qw/LostItem/;
 use Getopt::Long;
 
 my  $lost;  #  key=lost value,  value=num days.
 my ($charge, $verbose, $confirm, $quiet);
-my $endrange = 366;  # FIXME hardcoded - don't deal with anything overdue by more than this num days.
+my $endrange = 366;
+my $mark_returned = 0;
 
 GetOptions( 
-    'lost=s%'    => \$lost,
-    'c|charge=s' => \$charge,
-    'confirm'    => \$confirm,
-    'verbose'    => \$verbose,
-    'quiet'      => \$quiet,
+    'lost=s%'       => \$lost,
+    'c|charge=s'    => \$charge,
+    'confirm'       => \$confirm,
+    'verbose'       => \$verbose,
+    'quiet'         => \$quiet,
+    'maxdays=s'     => \$endrange,
+    'mark-returned' => \$mark_returned,
 );
 
 my $usage = << 'ENDUSAGE';
@@ -68,6 +72,13 @@ This script takes the following parameters :
     --confirm           confirm.  without this option, the script will report the number of affected items and
                         return without modifying any records.
 
+    --quiet             suppress summary output.
+
+    --maxdays           Specifies the end of the range of overdue days to deal with (defaults to 366).  This
+                        value is universal to all lost num days overdue passed.
+
+    --mark-returned     When an item is marked lost, remove it from the borrowers issued items.
+
   examples :
   $PERL5LIB/misc/cronjobs/longoverdue.pl --lost 30=1
     Would set LOST=1 after 30 days (up to one year), but not charge the account.
@@ -154,7 +165,7 @@ foreach my $startrange (sort keys %$lost) {
             printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);
             if($confirm) {
                 ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'});
-                LostItem($row->{'itemnumber'}) if( $charge && $charge eq $lostvalue);
+                LostItem($row->{'itemnumber'}, $mark_returned) if( $charge && $charge eq $lostvalue);
             }
             $count++;
         }