|
Lines 107-113
Update patron only if they are below the minimum age range specified for the 'fr
Link Here
|
| 107 |
|
107 |
|
| 108 |
Supply a number and only account with fines over this number will be updated. |
108 |
Supply a number and only account with fines over this number will be updated. |
| 109 |
|
109 |
|
| 110 |
=item B<==fineunder=X | -fu=X> |
110 |
=item B<--fineunder=X | -fu=X> |
| 111 |
|
111 |
|
| 112 |
Supply a number and only account with fines under this number will be updated. |
112 |
Supply a number and only account with fines under this number will be updated. |
| 113 |
|
113 |
|
|
Lines 179-202
GetOptions(
Link Here
|
| 179 |
'ra|regafter=s' => \$reg_aft, |
179 |
'ra|regafter=s' => \$reg_aft, |
| 180 |
'b|branch=s' => \$branch_lim, |
180 |
'b|branch=s' => \$branch_lim, |
| 181 |
'd|field=s' => \%fields |
181 |
'd|field=s' => \%fields |
| 182 |
) or pod2usage(2); |
182 |
); |
|
|
183 |
|
| 183 |
pod2usage(1) if $help; |
184 |
pod2usage(1) if $help; |
| 184 |
pod2usage( -verbose => 2 ) if $man; |
|
|
| 185 |
|
185 |
|
| 186 |
warn "v $verbose c $doit f $fromcat t $tocat"; |
186 |
pod2usage( -verbose => 2 ) if $man; |
| 187 |
exit; |
|
|
| 188 |
|
187 |
|
| 189 |
if ( not $fromcat && $tocat ) { #make sure we've specified the info we need. |
188 |
if ( not $fromcat && $tocat ) { #make sure we've specified the info we need. |
| 190 |
print |
189 |
print "Must supply category from and to (-f & -t) please specify -help for usage tips.\n"; |
| 191 |
"Must supply category from and to (-f & -t) please specify -help for usage tips.\n"; |
190 |
pod2usage(1); |
| 192 |
exit; |
191 |
exit; |
| 193 |
} |
192 |
} |
| 194 |
|
193 |
|
| 195 |
( $verbose && !$doit ) and print "No actions will be taken (test mode)\n"; |
194 |
( $verbose && !$doit ) and print "No actions will be taken (test mode)\n"; |
| 196 |
|
195 |
|
| 197 |
$verbose |
196 |
$verbose and print "Will update patrons from $fromcat to $tocat with conditions below (if any)\n"; |
| 198 |
and print |
|
|
| 199 |
"Will update patrons from $fromcat to $tocat with conditions below (if any)\n"; |
| 200 |
|
197 |
|
| 201 |
my %params; |
198 |
my %params; |
| 202 |
|
199 |
|
|
Lines 206-220
if ( $reg_bef || $reg_aft ) {
Link Here
|
| 206 |
if ( defined $reg_bef ) { |
203 |
if ( defined $reg_bef ) { |
| 207 |
eval { $date_bef = dt_from_string( $reg_bef, 'iso' ); }; |
204 |
eval { $date_bef = dt_from_string( $reg_bef, 'iso' ); }; |
| 208 |
} |
205 |
} |
| 209 |
die |
206 |
die "$reg_bef is not a valid date before, aborting! Use a date in format YYYY-MM-DD.$@" |
| 210 |
"$reg_bef is not a valid date before, aborting! Use a date in format YYYY-MM-DD.$@" |
207 |
if $@; |
| 211 |
if $@; |
|
|
| 212 |
if ( defined $reg_aft ) { |
208 |
if ( defined $reg_aft ) { |
| 213 |
eval { $date_aft = dt_from_string( $reg_aft, 'iso' ); }; |
209 |
eval { $date_aft = dt_from_string( $reg_aft, 'iso' ); }; |
| 214 |
} |
210 |
} |
| 215 |
die |
211 |
die "$reg_bef is not a valid date after, aborting! Use a date in format YYYY-MM-DD.$@" |
| 216 |
"$reg_bef is not a valid date after, aborting! Use a date in format YYYY-MM-DD.$@" |
212 |
if $@; |
| 217 |
if $@; |
|
|
| 218 |
$params{dateenrolled}{'<='} = $reg_bef if defined $date_bef; |
213 |
$params{dateenrolled}{'<='} = $reg_bef if defined $date_bef; |
| 219 |
$params{dateenrolled}{'>='} = $reg_aft if defined $date_aft; |
214 |
$params{dateenrolled}{'>='} = $reg_aft if defined $date_aft; |
| 220 |
} |
215 |
} |
|
Lines 243-250
while ( my ( $key, $value ) = each %fields ) {
Link Here
|
| 243 |
$verbose and print " Borrower column $key is equal to $value\n"; |
238 |
$verbose and print " Borrower column $key is equal to $value\n"; |
| 244 |
$params{ "me." . $key } = $value; |
239 |
$params{ "me." . $key } = $value; |
| 245 |
} |
240 |
} |
| 246 |
|
241 |
my $target_patrons = Koha::Patrons->search(\%params)->search_patrons_to_update_category( |
| 247 |
my $target_patrons = Koha::Patrons->search({ search_params => \%params })->search_patrons_to_update( |
|
|
| 248 |
{ |
242 |
{ |
| 249 |
from => $fromcat, |
243 |
from => $fromcat, |
| 250 |
search_params => \%params, |
244 |
search_params => \%params, |
|
Lines 270-276
if ($verbose) {
Link Here
|
| 270 |
$target_patrons->reset; |
264 |
$target_patrons->reset; |
| 271 |
} |
265 |
} |
| 272 |
if ($doit) { |
266 |
if ($doit) { |
| 273 |
$actually_updated = $target_patrons->update_category( { to => $tocat } ); |
267 |
$actually_updated = $target_patrons->update_category_to( { category => $tocat } ); |
| 274 |
} |
268 |
} |
| 275 |
|
269 |
|
| 276 |
$verbose and print "$patrons_found found, $actually_updated updated\n"; |
270 |
$verbose and print "$patrons_found found, $actually_updated updated\n"; |
| 277 |
- |
|
|