View | Details | Raw Unified | Return to bug 29525
Collapse All | Expand All

(-)a/misc/cronjobs/batch_anonymise.pl (-5 / +15 lines)
Lines 17-31 Link Here
17
# You should have received a copy of the GNU General Public License
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use strict;
20
use Modern::Perl;
21
use warnings;
22
21
23
use Koha::Script -cron;
22
use Koha::Script -cron;
23
24
use C4::Context;
24
use C4::Context;
25
use C4::Log qw( cronlogaction );
26
27
use Koha::Database;
28
use Koha::Old::Holds;
25
use Koha::Patrons;
29
use Koha::Patrons;
30
26
use Date::Calc qw( Add_Delta_Days Today );
31
use Date::Calc qw( Add_Delta_Days Today );
27
use Getopt::Long qw( GetOptions );
32
use Getopt::Long qw( GetOptions );
28
use C4::Log qw( cronlogaction );
29
33
30
sub usage {
34
sub usage {
31
    print STDERR <<USAGE;
35
    print STDERR <<USAGE;
Lines 61-69 cronlogaction(); Link Here
61
my ($year,$month,$day) = Today();
65
my ($year,$month,$day) = Today();
62
my ($newyear,$newmonth,$newday) = Add_Delta_Days ($year,$month,$day,(-1)*$days);
66
my ($newyear,$newmonth,$newday) = Add_Delta_Days ($year,$month,$day,(-1)*$days);
63
my $formatdate = sprintf "%4d-%02d-%02d",$newyear,$newmonth,$newday;
67
my $formatdate = sprintf "%4d-%02d-%02d",$newyear,$newmonth,$newday;
64
$verbose and print "Checkouts before $formatdate will be anonymised.\n";
68
$verbose and print "Checkouts and holds before $formatdate will be anonymised.\n";
65
69
66
my $rows = Koha::Patrons->search_patrons_to_anonymise( { before => $formatdate } )->anonymise_issue_history( { before => $formatdate } );
70
my $rows = Koha::Patrons->search_patrons_to_anonymise( { before => $formatdate } )->anonymise_issue_history( { before => $formatdate } );
67
$verbose and print int($rows) . " checkouts anonymised.\n";
71
$verbose and print int($rows) . " checkouts anonymised.\n";
68
72
73
$rows = Koha::Old::Holds
74
          ->filter_by_anonymizable
75
          ->filter_by_last_update( { days => $days } )
76
          ->anonymize;
77
78
$verbose and print int($rows) . " holds anonymised.\n";
79
69
exit(0);
80
exit(0);
70
- 

Return to bug 29525