|
Lines 55-61
Options:
Link Here
|
| 55 |
-fu=X --fineunder=X update if fines under X amount |
55 |
-fu=X --fineunder=X update if fines under X amount |
| 56 |
-rb=date --regbefore update if registration date is before given date |
56 |
-rb=date --regbefore update if registration date is before given date |
| 57 |
-ra=date --regafter update if registration date is after a given date |
57 |
-ra=date --regafter update if registration date is after a given date |
| 58 |
-d --dbfield name=value where <name> is a column in the borrowers table, patrons will be updated if the field is equal to given <value> |
58 |
-d --field name=value where <name> is a column in the borrowers table, patrons will be updated if the field is equal to given <value> |
|
|
59 |
--where <conditions> where clause to add to the query |
| 59 |
-v -verbose verbose mode |
60 |
-v -verbose verbose mode |
| 60 |
-c --confirm commit changes to db, no action will be taken unless this switch is included |
61 |
-c --confirm commit changes to db, no action will be taken unless this switch is included |
| 61 |
-b --branch <branchname> only deal with patrons from this library/branch |
62 |
-b --branch <branchname> only deal with patrons from this library/branch |
|
Lines 121-132
Enter a date in ISO format YYYY-MM-DD and only patrons registered after this dat
Link Here
|
| 121 |
|
122 |
|
| 122 |
=item B<--field column=value | -d column=value> |
123 |
=item B<--field column=value | -d column=value> |
| 123 |
|
124 |
|
| 124 |
Use this flag to specify a column in the borrowers table and update only patrons whose value in that column matches the value supplied (repeatable) |
125 |
Use this flag to specify a column in the borrowers table and update only patrons whose value in that column equals the value supplied (repeatable) |
|
|
126 |
A value of null will check for a field that is not set. |
| 125 |
|
127 |
|
| 126 |
e.g. |
128 |
e.g. |
| 127 |
--field dateexpiry=2016-01-01 |
129 |
--field dateexpiry=2016-01-01 |
| 128 |
will update all patrons who expired on that date, useful for schools etc. |
130 |
will update all patrons who expired on that date, useful for schools etc. |
| 129 |
|
131 |
|
|
|
132 |
=item B<--where $conditions> |
| 133 |
|
| 134 |
Use this option to specify a condition built with columns from the borrowers table |
| 135 |
|
| 136 |
e.g. |
| 137 |
--where 'email IS NULL' |
| 138 |
will update all patrons with no value for email |
| 139 |
|
| 140 |
--where 'categorycode LIKE "%CHILD"' |
| 141 |
will update all patrons with a category ending in CHILD. |
| 142 |
|
| 143 |
--where 'categorycode LIKE RESIDENT%' |
| 144 |
will update all patrons whose category does not begin with RESIDENT. |
| 145 |
|
| 130 |
=back |
146 |
=back |
| 131 |
|
147 |
|
| 132 |
=head1 DESCRIPTION |
148 |
=head1 DESCRIPTION |
|
Lines 163-168
my $reg_bef;
Link Here
|
| 163 |
my $reg_aft; |
179 |
my $reg_aft; |
| 164 |
my $branch_lim; |
180 |
my $branch_lim; |
| 165 |
my %fields; |
181 |
my %fields; |
|
|
182 |
my @where; |
| 166 |
|
183 |
|
| 167 |
GetOptions( |
184 |
GetOptions( |
| 168 |
'help|?' => \$help, |
185 |
'help|?' => \$help, |
|
Lines 178-184
GetOptions(
Link Here
|
| 178 |
'rb|regbefore=s' => \$reg_bef, |
195 |
'rb|regbefore=s' => \$reg_bef, |
| 179 |
'ra|regafter=s' => \$reg_aft, |
196 |
'ra|regafter=s' => \$reg_aft, |
| 180 |
'b|branch=s' => \$branch_lim, |
197 |
'b|branch=s' => \$branch_lim, |
| 181 |
'd|field=s' => \%fields |
198 |
'd|field=s' => \%fields, |
|
|
199 |
'where=s' => \@where, |
| 182 |
); |
200 |
); |
| 183 |
|
201 |
|
| 184 |
pod2usage(1) if $help; |
202 |
pod2usage(1) if $help; |
|
Lines 235-244
if ($verbose) {
Link Here
|
| 235 |
} |
253 |
} |
| 236 |
|
254 |
|
| 237 |
while ( my ( $key, $value ) = each %fields ) { |
255 |
while ( my ( $key, $value ) = each %fields ) { |
| 238 |
$verbose and print " Borrower column $key is equal to $value\n"; |
256 |
$verbose and print " Borrower column $key is $value\n"; |
|
|
257 |
$value = undef if lc($value) eq 'null'; |
| 239 |
$params{ "me." . $key } = $value; |
258 |
$params{ "me." . $key } = $value; |
| 240 |
} |
259 |
} |
| 241 |
my $target_patrons = Koha::Patrons->search(\%params)->search_patrons_to_update_category( |
260 |
|
|
|
261 |
my $where_literal = join ' AND ', @where; |
| 262 |
my $target_patrons = Koha::Patrons->search( \%params ); |
| 263 |
$target_patrons = $target_patrons->search( \$where_literal ) if @where; |
| 264 |
$target_patrons = $target_patrons->search_patrons_to_update_category( |
| 242 |
{ |
265 |
{ |
| 243 |
from => $fromcat, |
266 |
from => $fromcat, |
| 244 |
search_params => \%params, |
267 |
search_params => \%params, |
| 245 |
- |
|
|