Bug 12206: fix HTML in other holdings list in staff search results page
[koha_fer] / misc / cronjobs / serialsUpdate.pl
index d82a0bb..6ac5558 100755 (executable)
@@ -39,7 +39,7 @@ use Pod::Usage;
 
 =head1 NAME
 
-serialsUpdate.pl - change status of serials that are late
+serialsUpdate.pl - change status of serial issues that are late
 
 =head1 SYNOPSIS
 
@@ -49,10 +49,10 @@ serialsUpdate.pl [ -h | -m ][ -v ] -c ][ --note "you are late" ][ --no-note ]
    --h --help -?   Brief help message
    --man           Full documentation
    --verbose -v    Verbose mode
-   -c              Confirm : without this option, the script will report the concerned serials
-                   without modifying database
-   --note          Note set to concerned serials, by default "Automatically set to late"
-   --no-note       Do not set a note one concerned serials
+   -c              Confirm: without this option, the script will report on affected serial
+                   issues without modifying database
+   --note          Note set on affected serial issues, by default "Automatically set to late"
+   --no-note       Do not set a note on affected serial issues
 
 =cut
 
@@ -94,13 +94,15 @@ my $sth = $dbh->prepare(
        serial.serialid,
        serial.serialseq,
        serial.planneddate,
-       serial.publisheddate
+       serial.publisheddate,
        subscription.subscriptionid
      FROM serial 
      LEFT JOIN subscription 
        ON (subscription.subscriptionid=serial.subscriptionid) 
+     LEFT JOIN subscription_frequencies
+       ON (subscription.periodicity = subscription_frequencies.id)
      WHERE serial.status = 1 
-       AND periodicity <> 32
+       AND subscription_frequencies.unit IS NOT NULL
        AND DATE_ADD(planneddate, INTERVAL CAST(graceperiod AS SIGNED) DAY) < NOW()
        AND subscription.closed = 0
     }
@@ -110,10 +112,10 @@ $sth->execute();
 while ( my $issue = $sth->fetchrow_hashref ) {
 
     my $subscription = &GetSubscription( $issue->{subscriptionid} );
-    my $planneddate  = $issue->{planneddate};
+    my $publisheddate  = $issue->{publisheddate};
 
-    if ( $subscription && $planneddate && $planneddate ne "0000-00-00" ) {
-        my $nextpublisheddate = GetNextDate( $planneddate, $subscription );
+    if ( $subscription && $publisheddate && $publisheddate ne "0000-00-00" ) {
+        my $nextpublisheddate = GetNextDate( $subscription, $publisheddate );
         my $today = format_date_in_iso( C4::Dates->new()->output() );
 
         if ( $nextpublisheddate && $today ) {
@@ -129,7 +131,7 @@ while ( my $issue = $sth->fetchrow_hashref ) {
                     $issue->{planneddate}, $issue->{publisheddate},
                     3, $note );
                 $verbose
-                  and print "Serial id=" . $issue->{serialid} . " update\n";
+                  and print "Serial issue with id=" . $issue->{serialid} . " updated\n";
             }
         }
         else {