11 my ( $help, $verbose, $not_borrowered_since, $expired_before, $category_code,
15 'v|verbose' => \$verbose,
16 'not_borrowered_since:s' => \$not_borrowered_since,
17 'expired_before:s' => \$expired_before,
18 'category_code:s' => \$category_code,
19 'dry-run' => \$dryrun,
26 $not_borrowered_since = dt_from_string( $not_borrowered_since, 'iso' )
27 if $not_borrowered_since;
29 $expired_before = dt_from_string( $expired_before, 'iso' )
32 unless ( $not_borrowered_since or $expired_before or $category_code ) {
33 pod2usage(q{At least one filter is mandatory});
37 my $members = GetBorrowersToExpunge(
39 not_borrowered_since => $not_borrowered_since,
40 expired_before => $expired_before,
41 category_code => $category_code,
45 say "I found " . scalar(@$members) . " patrons to delete";
46 for my $member (@$members) {
47 print "Trying to delete patron " . $member->{borrowernumber} . "... ";
49 C4::Members::MoveMemberToDeleted( $member->{borrowernumber} )
53 say "Failed, I cannot move this patron ($@)";
56 eval { C4::Members::DelMember( $member->{borrowernumber} ) unless $dryrun; };
58 say "Failed, I cannot delete this patron ($@)";
66 delete_patrons - This script deletes patrons
70 delete_patrons.pl [-h -v] --not_borrowered_since=`date -d '-3 month' "+%Y-%m-%d"` --expired_before=`date -d '-3 month' "+%Y-%m-%d"` --category_code=CAT
72 Options are cumulatives.
80 Print a brief help message
82 =item B<--not_borrowered_since>
84 Delete patrons who have not borrowered since this date.
86 =item B<--expired_date>
88 Delete patrons with an account expired before this date.
90 =item B<--category_code>
92 Delete patrons who have this category code.
96 Dry run mode. To use with the verbose mode.
106 Jonathan Druart <jonathan.druart@biblibre.com>
110 Copyright 2013 BibLibre
114 This file is part of Koha.
116 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
117 Foundation; either version 2 of the License, or (at your option) any later version.
119 You should have received a copy of the GNU General Public License along
120 with Koha; if not, write to the Free Software Foundation, Inc.,
121 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.