use strict;
use warnings;
-use Carp;
BEGIN {
# find Koha's Perl modules
# test carefully before changing this
- use FindBin;
+ use FindBin ();
eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script -cron;
use C4::Context;
-use C4::Circulation;
-use C4::Dates;
-use Date::Calc qw(
- Today
- Add_Delta_Days
-);
-use Getopt::Long;
+use Koha::Patrons;
+use Date::Calc qw( Add_Delta_Days Today );
+use Getopt::Long qw( GetOptions );
+use C4::Log qw( cronlogaction );
sub usage {
print STDERR <<USAGE;
-v --verbose gives a little more information
-h --help prints this help message, and exits, ignoring all
other options
+Note: If the system preference 'AnonymousPatron' is not defined, NULL will be used.
USAGE
exit $_[0];
}
usage(1);
}
+cronlogaction();
+
my ($year,$month,$day) = Today();
my ($newyear,$newmonth,$newday) = Add_Delta_Days ($year,$month,$day,(-1)*$days);
my $formatdate = sprintf "%4d-%02d-%02d",$newyear,$newmonth,$newday;
$verbose and print "Checkouts before $formatdate will be anonymised.\n";
-my ($rows, $err_history_not_deleted) = AnonymiseIssueHistory($formatdate);
-carp "Anonymisation of reading history failed." if ($err_history_not_deleted);
-$verbose and print "$rows checkouts anonymised.\n";
+my $rows = Koha::Patrons->search_patrons_to_anonymise( { before => $formatdate } )->anonymise_issue_history( { before => $formatdate } );
+$verbose and print int($rows) . " checkouts anonymised.\n";
exit(0);