Lines 41-46
use C4::Search::History;
Link Here
|
41 |
use Getopt::Long; |
41 |
use Getopt::Long; |
42 |
use C4::Log; |
42 |
use C4::Log; |
43 |
use C4::Accounts; |
43 |
use C4::Accounts; |
|
|
44 |
use Koha::Database; |
45 |
use Koha::DateUtils; |
46 |
use Koha::Account::Lines; |
44 |
use Koha::UploadedFiles; |
47 |
use Koha::UploadedFiles; |
45 |
use Koha::Old::Biblios; |
48 |
use Koha::Old::Biblios; |
46 |
use Koha::Old::Items; |
49 |
use Koha::Old::Items; |
Lines 53-59
use Koha::PseudonymizedTransactions;
Link Here
|
53 |
|
56 |
|
54 |
sub usage { |
57 |
sub usage { |
55 |
print STDERR <<USAGE; |
58 |
print STDERR <<USAGE; |
56 |
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS] [--transfers DAYS] |
59 |
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose] [--zebraqueue DAYS] [-m|--mail] [--merged] [--import DAYS] [--logs DAYS] [--searchhistory DAYS] [--restrictions DAYS] [--all-restrictions] [--fees DAYS] [--statute-barred-fees DAYS] [--temp-uploads] [--temp-uploads-days DAYS] [--uploads-missing 0|1 ] [--statistics DAYS] [--deleted-catalog DAYS] [--deleted-patrons DAYS] [--old-issues DAYS] [--old-reserves DAYS] [--transfers DAYS] |
57 |
|
60 |
|
58 |
-h --help prints this help message, and exits, ignoring all |
61 |
-h --help prints this help message, and exits, ignoring all |
59 |
other options |
62 |
other options |
Lines 76-81
Usage: $0 [-h|--help] [--confirm] [--sessions] [--sessdays DAYS] [-v|--verbose]
Link Here
|
76 |
amountoutstanding is 0 or NULL. |
79 |
amountoutstanding is 0 or NULL. |
77 |
In the case of --fees, DAYS must be greater than |
80 |
In the case of --fees, DAYS must be greater than |
78 |
or equal to 1. |
81 |
or equal to 1. |
|
|
82 |
--statute-barred-fees DAYS Purge entries accountlines older than DAYS days, where |
83 |
status is RETURNED and amountoutstanding is greater than 0. |
84 |
In the case of --statute-barred-fees, DAYS must be greater than |
85 |
or equal to 1. |
79 |
--logs DAYS purge entries from action_logs older than DAYS days. |
86 |
--logs DAYS purge entries from action_logs older than DAYS days. |
80 |
Defaults to 180 days if no days specified. |
87 |
Defaults to 180 days if no days specified. |
81 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
88 |
--searchhistory DAYS purge entries from search_history older than DAYS days. |
Lines 125-130
my $allDebarments;
Link Here
|
125 |
my $pExpSelfReg; |
132 |
my $pExpSelfReg; |
126 |
my $pUnvSelfReg; |
133 |
my $pUnvSelfReg; |
127 |
my $fees_days; |
134 |
my $fees_days; |
|
|
135 |
my $statue_barred_fees_days; |
128 |
my $special_holidays_days; |
136 |
my $special_holidays_days; |
129 |
my $temp_uploads; |
137 |
my $temp_uploads; |
130 |
my $temp_uploads_days; |
138 |
my $temp_uploads_days; |
Lines 151-156
GetOptions(
Link Here
|
151 |
'z3950' => \$pZ3950, |
159 |
'z3950' => \$pZ3950, |
152 |
'logs:i' => \$pLogs, |
160 |
'logs:i' => \$pLogs, |
153 |
'fees:i' => \$fees_days, |
161 |
'fees:i' => \$fees_days, |
|
|
162 |
'statute-barred-fees:i' => \$statue_barred_fees_days, |
154 |
'searchhistory:i' => \$pSearchhistory, |
163 |
'searchhistory:i' => \$pSearchhistory, |
155 |
'list-invites:i' => \$pListShareInvites, |
164 |
'list-invites:i' => \$pListShareInvites, |
156 |
'restrictions:i' => \$pDebarments, |
165 |
'restrictions:i' => \$pDebarments, |
Lines 194-199
unless ( $sessions
Link Here
|
194 |
|| $pImport |
203 |
|| $pImport |
195 |
|| $pLogs |
204 |
|| $pLogs |
196 |
|| $fees_days |
205 |
|| $fees_days |
|
|
206 |
|| $statue_barred_fees_days |
197 |
|| $pSearchhistory |
207 |
|| $pSearchhistory |
198 |
|| $pZ3950 |
208 |
|| $pZ3950 |
199 |
|| $pListShareInvites |
209 |
|| $pListShareInvites |
Lines 231-236
cronlogaction() unless $confirm;
Link Here
|
231 |
my $dbh = C4::Context->dbh(); |
241 |
my $dbh = C4::Context->dbh(); |
232 |
my $sth; |
242 |
my $sth; |
233 |
my $sth2; |
243 |
my $sth2; |
|
|
244 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
234 |
|
245 |
|
235 |
if ( $sessions && !$sess_days ) { |
246 |
if ( $sessions && !$sess_days ) { |
236 |
if ($verbose) { |
247 |
if ($verbose) { |
Lines 340-345
if ($fees_days) {
Link Here
|
340 |
print "Done purging records from accountlines.\n" if $verbose; |
351 |
print "Done purging records from accountlines.\n" if $verbose; |
341 |
} |
352 |
} |
342 |
|
353 |
|
|
|
354 |
if ($statue_barred_fees_days) { |
355 |
my $date = $dtf->format_datetime( DateTime->now->subtract(days => $statue_barred_fees_days) ); |
356 |
my $accountlines = Koha::Account::Lines->search({ |
357 |
amountoutstanding => { '>' => 0 }, |
358 |
status => 'RETURNED', |
359 |
date => { '<=' => $date } |
360 |
}); |
361 |
if ( $confirm ) { |
362 |
say "Purging " . $accountlines->count . " statute-barred fees from accountlines." if $verbose; |
363 |
$accountlines->delete; |
364 |
} |
365 |
else { |
366 |
say $accountlines->count . " statute-barred fees would have been deleted." if $verbose; |
367 |
} |
368 |
say "Done purging statute-barred fees from accountlines." if $verbose; |
369 |
} |
370 |
|
343 |
if ($pSearchhistory) { |
371 |
if ($pSearchhistory) { |
344 |
print "Purging records older than $pSearchhistory from search_history.\n" if $verbose; |
372 |
print "Purging records older than $pSearchhistory from search_history.\n" if $verbose; |
345 |
C4::Search::History::delete({ interval => $pSearchhistory }) if $confirm; |
373 |
C4::Search::History::delete({ interval => $pSearchhistory }) if $confirm; |
346 |
- |
|
|