@@ -, +, @@ --- misc/cronjobs/fix_patron_dates.pl | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 misc/cronjobs/fix_patron_dates.pl --- a/misc/cronjobs/fix_patron_dates.pl +++ a/misc/cronjobs/fix_patron_dates.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +# 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 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. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use C4::Context; +use C4::Log qw(cronlogaction); +use Getopt::Long qw( GetOptions ); +use Pod::Usage qw( pod2usage ); +use Koha::Logger; +use Koha::Patrons; +use Koha::DateUtils qw( dt_from_string ); +use Koha::Script -cron; +use Data::Dumper; + +my $verbose = 0; +my $doit = 0; + +GetOptions( + 'v|verbose' => \$verbose, + 'c|confirm' => \$doit, +); + +my $count; + +# search patrons that have date fields that are 0000-00-00 +foreach my $date_type (qw(dateofbirth dateenrolled dateexpiry date_renewed)) { + my $borrowers = Koha::Patrons->search( { $date_type=>'0000-00-00' } ); + + if ($doit) { # if confirm flag was run with cronjob + while (my $borrower = $borrowers->next()) { + $count++; + $borrower->$date_type(undef)->store(); + } + } +} + +if ($verbose) { + print "$count wrong dates found"; --