Bug 11603: Fix encoding issues (bug 11944 is now pushed)
[koha.git] / misc / cronjobs / serialsUpdate.pl
index 813ef21..fedf064 100755 (executable)
@@ -4,18 +4,18 @@
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use strict;
 use warnings;
@@ -32,6 +32,7 @@ use C4::Context;
 use C4::Dates qw/format_date format_date_in_iso/;
 use C4::Debug;
 use C4::Serials;
+use C4::Log;
 
 use Date::Calc qw/Date_to_Days check_date/;
 use Getopt::Long;
@@ -77,6 +78,8 @@ GetOptions(
 pod2usage(1) if $help;
 pod2usage( -verbose => 2 ) if $man;
 
+cronlogaction();
+
 $verbose and !$confirm and print "### Database will not be modified ###\n";
 
 if ( $note && $nonote ) {
@@ -99,8 +102,10 @@ my $sth = $dbh->prepare(
      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
     }