Lines 45-50
my $endrange = 366;
Link Here
|
45 |
my $mark_returned; |
45 |
my $mark_returned; |
46 |
my $borrower_category = []; |
46 |
my $borrower_category = []; |
47 |
my $skip_borrower_category = []; |
47 |
my $skip_borrower_category = []; |
|
|
48 |
my @branches; |
49 |
my @skip_branches; |
48 |
my $itemtype = []; |
50 |
my $itemtype = []; |
49 |
my $skip_itemtype = []; |
51 |
my $skip_itemtype = []; |
50 |
my $help=0; |
52 |
my $help=0; |
Lines 68-73
GetOptions(
Link Here
|
68 |
'category=s' => $borrower_category, |
70 |
'category=s' => $borrower_category, |
69 |
'skip-category=s' => $skip_borrower_category, |
71 |
'skip-category=s' => $skip_borrower_category, |
70 |
'list-categories' => \$list_categories, |
72 |
'list-categories' => \$list_categories, |
|
|
73 |
'library=s' => \@branches, |
74 |
'skip-library=s' => \@skip_branches, |
71 |
'itemtype=s' => $itemtype, |
75 |
'itemtype=s' => $itemtype, |
72 |
'skip-itemtype=s' => $skip_itemtype, |
76 |
'skip-itemtype=s' => $skip_itemtype, |
73 |
'list-itemtypes' => \$list_itemtypes, |
77 |
'list-itemtypes' => \$list_itemtypes, |
Lines 94-99
if ( scalar @$borrower_category && scalar @$skip_borrower_category) {
Link Here
|
94 |
); |
98 |
); |
95 |
} |
99 |
} |
96 |
|
100 |
|
|
|
101 |
if ( scalar @branches && scalar @skip_branches ) { |
102 |
pod2usage( |
103 |
-verbose => 1, |
104 |
-message => "The options --library and --skip-library are mutually exclusive.\n" . "Use one or the other.", |
105 |
-exitval => 1 |
106 |
); |
107 |
} |
108 |
|
97 |
if ( scalar @$itemtype && scalar @$skip_itemtype) { |
109 |
if ( scalar @$itemtype && scalar @$skip_itemtype) { |
98 |
pod2usage( -verbose => 1, |
110 |
pod2usage( -verbose => 1, |
99 |
-message => "The options --itemtype and --skip-itemtype are mutually exclusive.\n" |
111 |
-message => "The options --itemtype and --skip-itemtype are mutually exclusive.\n" |
Lines 121-126
if ( $list_itemtypes ) {
Link Here
|
121 |
longoverdue.pl --lost | -l DAYS=LOST_CODE [ --charge | -c CHARGE_CODE ] [ --verbose | -v ] [ --quiet ] |
133 |
longoverdue.pl --lost | -l DAYS=LOST_CODE [ --charge | -c CHARGE_CODE ] [ --verbose | -v ] [ --quiet ] |
122 |
[ --maxdays MAX_DAYS ] [ --mark-returned ] [ --category BORROWER_CATEGORY ] ... |
134 |
[ --maxdays MAX_DAYS ] [ --mark-returned ] [ --category BORROWER_CATEGORY ] ... |
123 |
[ --skip-category BORROWER_CATEGORY ] ... |
135 |
[ --skip-category BORROWER_CATEGORY ] ... |
|
|
136 |
[ --library LIBRARY_CODE ] [ --skip-library LIBRARY_CODE ] ... |
124 |
[ --skip-lost-value LOST_VALUE [ --skip-lost-value LOST_VALUE ] ] |
137 |
[ --skip-lost-value LOST_VALUE [ --skip-lost-value LOST_VALUE ] ] |
125 |
[ --commit ] |
138 |
[ --commit ] |
126 |
|
139 |
|
Lines 187-192
If not provided, the value of the system preference 'DefaultLongOverdueSkipPatro
Link Here
|
187 |
List borrower categories available for use by B<--category> or |
200 |
List borrower categories available for use by B<--category> or |
188 |
B<--skip-category>, and exit. |
201 |
B<--skip-category>, and exit. |
189 |
|
202 |
|
|
|
203 |
=item B<--library> |
204 |
|
205 |
Act on the listed library codes. Exclude all others. This may be specified multiple times to include multiple libraries. Which libraries are selected follows the CircControl system preference. |
206 |
May not be used with B<--skip-library> |
207 |
|
208 |
=item B<--skip-library> |
209 |
|
210 |
Act on all library codes except the ones listed. This may be specified multiple times to exclude multiple libraries. Which libraries are excluded follows the CircControl system preference. |
211 |
May not be used with B<--library> |
212 |
|
190 |
=item B<--itemtype> |
213 |
=item B<--itemtype> |
191 |
|
214 |
|
192 |
Act on the listed itemtype code. |
215 |
Act on the listed itemtype code. |
Lines 332-337
sub longoverdue_sth {
Link Here
|
332 |
} |
355 |
} |
333 |
|
356 |
|
334 |
my $dbh = C4::Context->dbh; |
357 |
my $dbh = C4::Context->dbh; |
|
|
358 |
my $circ_control_pref = C4::Context->preference('CircControl'); |
335 |
|
359 |
|
336 |
my @available_categories = Koha::Patron::Categories->search()->get_column('categorycode'); |
360 |
my @available_categories = Koha::Patron::Categories->search()->get_column('categorycode'); |
337 |
$borrower_category = [ map { uc $_ } @$borrower_category ]; |
361 |
$borrower_category = [ map { uc $_ } @$borrower_category ]; |
Lines 361-366
if ( @$skip_borrower_category ) {
Link Here
|
361 |
|
385 |
|
362 |
my $filter_borrower_categories = ( scalar @$borrower_category || scalar @$skip_borrower_category ); |
386 |
my $filter_borrower_categories = ( scalar @$borrower_category || scalar @$skip_borrower_category ); |
363 |
|
387 |
|
|
|
388 |
my @available_branches = Koha::Libraries->search()->get_column('branchcode'); |
389 |
my %branches_to_process; |
390 |
# If --library was used, validate any branchcode passed in and mark them as branches to use |
391 |
for my $lib (@branches) { |
392 |
unless ( grep { $_ eq $lib } @available_branches ) { |
393 |
pod2usage( |
394 |
'-exitval' => 1, |
395 |
'-message' => "The library $lib does not exist in the database", |
396 |
); |
397 |
} |
398 |
$branches_to_process{$lib} = 1; |
399 |
} |
400 |
# If --skip-library was used, validate any branchcode passed in and mark them as branches to *not* use |
401 |
if (@skip_branches) { |
402 |
for my $lib (@skip_branches) { |
403 |
unless ( grep { $_ eq $lib } @available_branches ) { |
404 |
pod2usage( |
405 |
'-exitval' => 1, |
406 |
'-message' => "The library $lib does not exist in the database", |
407 |
); |
408 |
} |
409 |
} |
410 |
%branches_to_process = map { $_ => 1 } @available_branches; |
411 |
# The mapped 0 values here will overwrite the corrosponding mapped 1 values |
412 |
# where the 0 values exist |
413 |
%branches_to_process = ( %branches_to_process, map { $_ => 0 } @skip_branches ); |
414 |
} |
415 |
|
416 |
my $filter_branches = ( scalar @branches || scalar @skip_branches ); |
417 |
|
364 |
my @available_itemtypes = Koha::ItemTypes->search()->get_column('itemtype'); |
418 |
my @available_itemtypes = Koha::ItemTypes->search()->get_column('itemtype'); |
365 |
$itemtype = [ map { uc $_ } @$itemtype ]; |
419 |
$itemtype = [ map { uc $_ } @$itemtype ]; |
366 |
$skip_itemtype = [ map { uc $_} @$skip_itemtype ]; |
420 |
$skip_itemtype = [ map { uc $_} @$skip_itemtype ]; |
Lines 410-419
foreach my $startrange (sort keys %$lost) {
Link Here
|
410 |
$sth_items->execute($startrange, $endrange, $lostvalue); |
464 |
$sth_items->execute($startrange, $endrange, $lostvalue); |
411 |
$count=0; |
465 |
$count=0; |
412 |
ITEM: while (my $row=$sth_items->fetchrow_hashref) { |
466 |
ITEM: while (my $row=$sth_items->fetchrow_hashref) { |
|
|
467 |
my $patron; |
413 |
if( $filter_borrower_categories ) { |
468 |
if( $filter_borrower_categories ) { |
414 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
469 |
$patron ||= Koha::Patrons->find( $row->{borrowernumber} ); |
|
|
470 |
my $category = uc $patron->categorycode(); |
415 |
next ITEM unless ( $category_to_process{ $category } ); |
471 |
next ITEM unless ( $category_to_process{ $category } ); |
416 |
} |
472 |
} |
|
|
473 |
if ($filter_branches) { |
474 |
my $lib; |
475 |
for ($circ_control_pref) { |
476 |
if ( $_ eq 'PatronLibrary' ) { |
477 |
$patron ||= Koha::Patrons->find( $row->{borrowernumber} ); |
478 |
$lib = $patron->branchcode(); |
479 |
} elsif ( $_ eq 'PickupLibrary' ) { |
480 |
$lib = C4::Context->userenv->{'branch'}; |
481 |
} else { # ( $_ eq 'ItemHomeLibrary' ) |
482 |
$lib = Koha::Items->find( $row->{itemnumber} )->homebranch(); |
483 |
} |
484 |
} |
485 |
next ITEM unless ( $branches_to_process{$lib} ); |
486 |
} |
417 |
if ($filter_itemtypes) { |
487 |
if ($filter_itemtypes) { |
418 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
488 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
419 |
next ITEM unless ( $itemtype_to_process{$it} ); |
489 |
next ITEM unless ( $itemtype_to_process{$it} ); |
Lines 425-431
foreach my $startrange (sort keys %$lost) {
Link Here
|
425 |
if ( $charge && $charge eq $lostvalue ) { |
495 |
if ( $charge && $charge eq $lostvalue ) { |
426 |
LostItem( $row->{'itemnumber'}, 'cronjob', $mark_returned ); |
496 |
LostItem( $row->{'itemnumber'}, 'cronjob', $mark_returned ); |
427 |
} elsif ( $mark_returned ) { |
497 |
} elsif ( $mark_returned ) { |
428 |
my $patron = Koha::Patrons->find( $row->{borrowernumber} ); |
498 |
$patron ||= Koha::Patrons->find( $row->{borrowernumber} ); |
429 |
MarkIssueReturned($row->{borrowernumber},$row->{itemnumber},undef,$patron->privacy) |
499 |
MarkIssueReturned($row->{borrowernumber},$row->{itemnumber},undef,$patron->privacy) |
430 |
} |
500 |
} |
431 |
} |
501 |
} |
432 |
- |
|
|