Bug 16276: Make delete_patrons.pl deal with --last_seen
This patch modify the delete_patrons.pl cronjob to deal with the last_seen option. To test it, you just have to use the --last_seen option and pass a valid date (iso format) Example: perl misc/cronjobs/delete_patrons.pl --last_seen="1984-02-04" --confirm will delete all the patrons who do not have been active since this date. Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr> https://bugs.koha-community.org/show_bug.cgi?id=12276 Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
f234d1586b
commit
93ff61c10d
1 changed files with 16 additions and 5 deletions
|
@ -9,13 +9,14 @@ use C4::Members;
|
|||
use Koha::DateUtils;
|
||||
use C4::Log;
|
||||
|
||||
my ( $help, $verbose, $not_borrowed_since, $expired_before, $category_code,
|
||||
$branchcode, $confirm );
|
||||
my ( $help, $verbose, $not_borrowed_since, $expired_before, $last_seen,
|
||||
$category_code, $branchcode, $confirm );
|
||||
GetOptions(
|
||||
'h|help' => \$help,
|
||||
'v|verbose' => \$verbose,
|
||||
'not_borrowed_since:s' => \$not_borrowed_since,
|
||||
'expired_before:s' => \$expired_before,
|
||||
'last_seen:s' => \$last_seen,
|
||||
'category_code:s' => \$category_code,
|
||||
'library:s' => \$branchcode,
|
||||
'c|confirm' => \$confirm,
|
||||
|
@ -31,9 +32,12 @@ $not_borrowed_since = dt_from_string( $not_borrowed_since, 'iso' )
|
|||
$expired_before = dt_from_string( $expired_before, 'iso' )
|
||||
if $expired_before;
|
||||
|
||||
unless ( $not_borrowed_since or $expired_before or $category_code or $branchcode ) {
|
||||
if ( $last_seen and not C4::Context->preference('TrackLastPatronActivity') ) {
|
||||
pod2usage(q{The --last_seen option cannot be used with TrackLastPatronActivity turned off});
|
||||
}
|
||||
|
||||
unless ( $not_borrowed_since or $expired_before or $last_seen or $category_code or $branchcode ) {
|
||||
pod2usage(q{At least one filter is mandatory});
|
||||
exit;
|
||||
}
|
||||
|
||||
cronlogaction();
|
||||
|
@ -42,6 +46,7 @@ my $members = GetBorrowersToExpunge(
|
|||
{
|
||||
not_borrowed_since => $not_borrowed_since,
|
||||
expired_before => $expired_before,
|
||||
last_seen => $last_seen,
|
||||
category_code => $category_code,
|
||||
branchcode => $branchcode,
|
||||
}
|
||||
|
@ -108,7 +113,7 @@ delete_patrons - This script deletes patrons
|
|||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
delete_patrons.pl [-h|--help] [-v|--verbose] [-c|--confirm] [--not_borrowed_since=DATE] [--expired_before=DATE] [--category_code=CAT] [--library=LIBRARY]
|
||||
delete_patrons.pl [-h|--help] [-v|--verbose] [-c|--confirm] [--not_borrowed_since=DATE] [--expired_before=DATE] [--last-seen=DATE] [--category_code=CAT] [--library=LIBRARY]
|
||||
|
||||
Dates should be in ISO format, e.g., 2013-07-19, and can be generated
|
||||
with `date -d '-3 month' "+%Y-%m-%d"`.
|
||||
|
@ -133,6 +138,12 @@ Delete patrons who have not borrowed since this date.
|
|||
|
||||
Delete patrons with an account expired before this date.
|
||||
|
||||
=item B<--last_seen>
|
||||
|
||||
Delete patrons who have not been connected since this date.
|
||||
|
||||
The system preference TrackLastPatronActivity must be enabled to use this option.
|
||||
|
||||
=item B<--category_code>
|
||||
|
||||
Delete patrons who have this category code.
|
||||
|
|
Loading…
Reference in a new issue