Lines 18-26
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use C4::Context; |
20 |
use C4::Context; |
21 |
use C4::Log qw(cronlogaction); |
21 |
use C4::Log qw(cronlogaction); |
22 |
use Getopt::Long qw( GetOptions ); |
22 |
use Getopt::Long qw( GetOptions ); |
23 |
use Pod::Usage qw( pod2usage ); |
23 |
use Pod::Usage qw( pod2usage ); |
24 |
use Koha::Logger; |
24 |
use Koha::Logger; |
25 |
use Koha::Patrons; |
25 |
use Koha::Patrons; |
26 |
use Koha::Patron::Categories; |
26 |
use Koha::Patron::Categories; |
Lines 170-177
my $branch_lim;
Link Here
|
170 |
my %fields; |
170 |
my %fields; |
171 |
my @where; |
171 |
my @where; |
172 |
|
172 |
|
173 |
my $command_line_options = join(" ",@ARGV); |
173 |
my $command_line_options = join( " ", @ARGV ); |
174 |
cronlogaction({ info => $command_line_options }); |
174 |
cronlogaction( { info => $command_line_options } ); |
175 |
|
175 |
|
176 |
GetOptions( |
176 |
GetOptions( |
177 |
'help|?' => \$help, |
177 |
'help|?' => \$help, |
Lines 229-242
my $cat_to = Koha::Patron::Categories->find($tocat);
Link Here
|
229 |
die "Categories not found" unless $cat_from && $cat_to; |
229 |
die "Categories not found" unless $cat_from && $cat_to; |
230 |
|
230 |
|
231 |
$params{"me.categorycode"} = $fromcat; |
231 |
$params{"me.categorycode"} = $fromcat; |
232 |
$params{"me.branchcode"} = $branch_lim if $branch_lim; |
232 |
$params{"me.branchcode"} = $branch_lim if $branch_lim; |
233 |
|
233 |
|
234 |
if ($verbose) { |
234 |
if ($verbose) { |
235 |
print "Conditions:\n"; |
235 |
print "Conditions:\n"; |
236 |
print " Registered before $reg_bef\n" if $reg_bef; |
236 |
print " Registered before $reg_bef\n" if $reg_bef; |
237 |
print " Registered after $reg_aft\n" if $reg_aft; |
237 |
print " Registered after $reg_aft\n" if $reg_aft; |
238 |
print " Total fines more than $fine_min\n" if $fine_min; |
238 |
print " Total fines more than $fine_min\n" if $fine_min; |
239 |
print " Total fines less than $fine_max\n" if $fine_max; |
239 |
print " Total fines less than $fine_max\n" if $fine_max; |
240 |
print " Age below minimum for " . $cat_from->description . "\n" if $ageunder; |
240 |
print " Age below minimum for " . $cat_from->description . "\n" if $ageunder; |
241 |
print " Age above maximum for " . $cat_from->description . "\n" if $ageover; |
241 |
print " Age above maximum for " . $cat_from->description . "\n" if $ageover; |
242 |
if ( defined $branch_lim ) { |
242 |
if ( defined $branch_lim ) { |
Lines 250-256
while ( my ( $key, $value ) = each %fields ) {
Link Here
|
250 |
$params{ "me." . $key } = $value; |
250 |
$params{ "me." . $key } = $value; |
251 |
} |
251 |
} |
252 |
|
252 |
|
253 |
my $where_literal = join ' AND ', @where; |
253 |
my $where_literal = join ' AND ', @where; |
254 |
my $target_patrons = Koha::Patrons->search( \%params ); |
254 |
my $target_patrons = Koha::Patrons->search( \%params ); |
255 |
$target_patrons = $target_patrons->search( \$where_literal ) if @where; |
255 |
$target_patrons = $target_patrons->search( \$where_literal ) if @where; |
256 |
$target_patrons = $target_patrons->search_patrons_to_update_category( |
256 |
$target_patrons = $target_patrons->search_patrons_to_update_category( |
Lines 271-281
if ($verbose) {
Link Here
|
271 |
while ( my $target_patron = $target_patrons->next() ) { |
271 |
while ( my $target_patron = $target_patrons->next() ) { |
272 |
$target_patron->discard_changes(); |
272 |
$target_patron->discard_changes(); |
273 |
$verbose |
273 |
$verbose |
274 |
and print $testdisplay |
274 |
and print $testdisplay |
275 |
. "Updated " |
275 |
. "Updated " |
276 |
. $target_patron->firstname() . " " |
276 |
. $target_patron->firstname() . " " |
277 |
. $target_patron->surname() |
277 |
. $target_patron->surname() |
278 |
. " from $fromcat to $tocat\n"; |
278 |
. " from $fromcat to $tocat\n"; |
279 |
} |
279 |
} |
280 |
$target_patrons->reset; |
280 |
$target_patrons->reset; |
281 |
} |
281 |
} |
282 |
- |
|
|