|
Lines 12-34
use Koha::Patrons;
Link Here
|
| 12 |
use C4::Log qw( cronlogaction ); |
12 |
use C4::Log qw( cronlogaction ); |
| 13 |
|
13 |
|
| 14 |
my ( |
14 |
my ( |
| 15 |
$help, $verbose, $not_borrowed_since, $expired_before, $last_seen, |
15 |
$help, $verbose, $not_borrowed_since, $expired_before, $last_seen, |
| 16 |
@category_code, $branchcode, $file, $confirm |
16 |
@category_code, $branchcode, $file, @without_restriction_types, $confirm |
| 17 |
); |
17 |
); |
| 18 |
|
18 |
|
| 19 |
my $command_line_options = join( " ", @ARGV ); |
19 |
my $command_line_options = join( " ", @ARGV ); |
| 20 |
cronlogaction( { info => $command_line_options } ); |
20 |
cronlogaction( { info => $command_line_options } ); |
| 21 |
|
21 |
|
| 22 |
GetOptions( |
22 |
GetOptions( |
| 23 |
'h|help' => \$help, |
23 |
'h|help' => \$help, |
| 24 |
'v|verbose' => \$verbose, |
24 |
'v|verbose' => \$verbose, |
| 25 |
'not_borrowed_since:s' => \$not_borrowed_since, |
25 |
'not_borrowed_since:s' => \$not_borrowed_since, |
| 26 |
'expired_before:s' => \$expired_before, |
26 |
'expired_before:s' => \$expired_before, |
| 27 |
'last_seen:s' => \$last_seen, |
27 |
'last_seen:s' => \$last_seen, |
| 28 |
'category_code:s' => \@category_code, |
28 |
'category_code:s' => \@category_code, |
| 29 |
'library:s' => \$branchcode, |
29 |
'library:s' => \$branchcode, |
| 30 |
'file:s' => \$file, |
30 |
'file:s' => \$file, |
| 31 |
'c|confirm' => \$confirm, |
31 |
'without_restriction_type:s' => \@without_restriction_types, |
|
|
32 |
'c|confirm' => \$confirm, |
| 32 |
) || pod2usage(1); |
33 |
) || pod2usage(1); |
| 33 |
|
34 |
|
| 34 |
if ($help) { |
35 |
if ($help) { |
|
Lines 49-54
unless ( $not_borrowed_since or $expired_before or $last_seen or @category_code
Link Here
|
| 49 |
pod2usage(q{At least one filter is mandatory}); |
50 |
pod2usage(q{At least one filter is mandatory}); |
| 50 |
} |
51 |
} |
| 51 |
|
52 |
|
|
|
53 |
if ( @without_restriction_types > 0 ) { |
| 54 |
my %restriction_types; |
| 55 |
@restriction_types{ map { $_->code() } Koha::Patron::Restriction::Types->search()->as_list } = (); |
| 56 |
|
| 57 |
my @invalid_restriction_types; |
| 58 |
foreach my $restriction_type (@without_restriction_types) { |
| 59 |
if ( !exists $restriction_types{$restriction_type} ) { |
| 60 |
push @invalid_restriction_types, $restriction_type; |
| 61 |
} |
| 62 |
} |
| 63 |
if ( @invalid_restriction_types > 0 ) { |
| 64 |
die 'Invalid restriction type(s): ' . join ', ', @invalid_restriction_types; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 52 |
my @file_members; |
68 |
my @file_members; |
| 53 |
if ($file) { |
69 |
if ($file) { |
| 54 |
open( my $fh, '<:encoding(UTF-8)', $file ) or die "Could not open file $file' $!"; |
70 |
open( my $fh, '<:encoding(UTF-8)', $file ) or die "Could not open file $file' $!"; |
|
Lines 65-75
my $members;
Link Here
|
| 65 |
if ( $not_borrowed_since or $expired_before or $last_seen or @category_code or $branchcode ) { |
81 |
if ( $not_borrowed_since or $expired_before or $last_seen or @category_code or $branchcode ) { |
| 66 |
$members = GetBorrowersToExpunge( |
82 |
$members = GetBorrowersToExpunge( |
| 67 |
{ |
83 |
{ |
| 68 |
not_borrowed_since => $not_borrowed_since, |
84 |
not_borrowed_since => $not_borrowed_since, |
| 69 |
expired_before => $expired_before, |
85 |
expired_before => $expired_before, |
| 70 |
last_seen => $last_seen, |
86 |
last_seen => $last_seen, |
| 71 |
category_code => \@category_code, |
87 |
category_code => \@category_code, |
| 72 |
branchcode => $branchcode, |
88 |
branchcode => $branchcode, |
|
|
89 |
without_restriction_types => \@without_restriction_types |
| 73 |
} |
90 |
} |
| 74 |
); |
91 |
); |
| 75 |
} |
92 |
} |
|
Lines 149-155
delete_patrons - This script deletes patrons
Link Here
|
| 149 |
|
166 |
|
| 150 |
=head1 SYNOPSIS |
167 |
=head1 SYNOPSIS |
| 151 |
|
168 |
|
| 152 |
delete_patrons.pl [-h|--help] [-v|--verbose] [-c|--confirm] [--not_borrowed_since=DATE] [--expired_before=DATE] [--last-seen=DATE] [--category_code=CAT] [--category_code=CAT ...] [--library=LIBRARY] [--file=FILE] |
169 |
delete_patrons.pl [-h|--help] [-v|--verbose] [-c|--confirm] [--not_borrowed_since=DATE] [--expired_before=DATE] [--last-seen=DATE] [--category_code=CAT] [--category_code=CAT ...] [--library=LIBRARY] [--file=FILE] [--without_restriction_type=TYPE] [--without_restriction_type=TYPE ...] |
| 153 |
|
170 |
|
| 154 |
Dates should be in ISO format, e.g., 2013-07-19, and can be generated |
171 |
Dates should be in ISO format, e.g., 2013-07-19, and can be generated |
| 155 |
with `date -d '-3 month' --iso-8601`. |
172 |
with `date -d '-3 month' --iso-8601`. |
|
Lines 202-207
Delete patrons in this library.
Link Here
|
| 202 |
Delete patrons whose borrower numbers are in this file. If other criteria are defined |
219 |
Delete patrons whose borrower numbers are in this file. If other criteria are defined |
| 203 |
it will only delete those in the file that match those criteria. |
220 |
it will only delete those in the file that match those criteria. |
| 204 |
|
221 |
|
|
|
222 |
=item B<--without_restriction_type> |
| 223 |
|
| 224 |
Delete patrons who DO NOT have a debarment with this restriction type. |
| 225 |
|
| 226 |
Can be used multiple times for additional restriction types. |
| 227 |
|
| 205 |
=item B<-c|--confirm> |
228 |
=item B<-c|--confirm> |
| 206 |
|
229 |
|
| 207 |
This flag must be provided in order for the script to actually |
230 |
This flag must be provided in order for the script to actually |
| 208 |
- |
|
|