|
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 |
'branch=s' => \@branches, |
| 74 |
'skip-branch=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 --branch and --skip-branch 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 |
[ --branch BRANCH_CODE ] [ --skip-branch BRANCH_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<--branch> |
| 204 |
|
| 205 |
Act on the listed branch codes. Exclude all others. This may be specified multiple times to include multiple branches. Which branches are selected follows the CircControl system preference. |
| 206 |
May not be used with B<--skip-branch> |
| 207 |
|
| 208 |
=item B<--skip-branch> |
| 209 |
|
| 210 |
Act on all branch codes except the ones listed. This may be specified multiple times to exclude multiple branches. Which branches are excluded follows the CircControl system preference. |
| 211 |
May not be used with B<--branch> |
| 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 |
for my $lib (@branches) { |
| 391 |
unless ( grep { $_ eq $lib } @available_branches ) { |
| 392 |
pod2usage( |
| 393 |
'-exitval' => 1, |
| 394 |
'-message' => "The library $lib does not exist in the database", |
| 395 |
); |
| 396 |
} |
| 397 |
$branches_to_process{$lib} = 1; |
| 398 |
} |
| 399 |
if (@skip_branches) { |
| 400 |
for my $lib (@skip_branches) { |
| 401 |
unless ( grep { $_ eq $lib } @available_branches ) { |
| 402 |
pod2usage( |
| 403 |
'-exitval' => 1, |
| 404 |
'-message' => "The library $lib does not exist in the database", |
| 405 |
); |
| 406 |
} |
| 407 |
} |
| 408 |
%branches_to_process = map { $_ => 1 } @available_branches; |
| 409 |
%branches_to_process = ( %branches_to_process, map { $_ => 0 } @skip_branches ); |
| 410 |
} |
| 411 |
|
| 412 |
my $filter_branches = ( scalar @branches || scalar @skip_branches ); |
| 413 |
|
| 364 |
my @available_itemtypes = Koha::ItemTypes->search()->get_column('itemtype'); |
414 |
my @available_itemtypes = Koha::ItemTypes->search()->get_column('itemtype'); |
| 365 |
$itemtype = [ map { uc $_ } @$itemtype ]; |
415 |
$itemtype = [ map { uc $_ } @$itemtype ]; |
| 366 |
$skip_itemtype = [ map { uc $_} @$skip_itemtype ]; |
416 |
$skip_itemtype = [ map { uc $_} @$skip_itemtype ]; |
|
Lines 414-419
foreach my $startrange (sort keys %$lost) {
Link Here
|
| 414 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
464 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
| 415 |
next ITEM unless ( $category_to_process{ $category } ); |
465 |
next ITEM unless ( $category_to_process{ $category } ); |
| 416 |
} |
466 |
} |
|
|
467 |
if ($filter_branches) { |
| 468 |
my $lib; |
| 469 |
for ($circ_control_pref) { |
| 470 |
if ( $_ eq 'PatronLibrary' ) { |
| 471 |
$lib = Koha::Patrons->find( $row->{borrowernumber} )->branchcode(); |
| 472 |
} elsif ( $_ eq 'PickupLibrary' ) { |
| 473 |
$lib = C4::Context->userenv->{'branch'}; |
| 474 |
} else { # ( $_ eq 'ItemHomeLibrary' ) |
| 475 |
$lib = Koha::Items->find( $row->{itemnumber} )->homebranch(); |
| 476 |
} |
| 477 |
} |
| 478 |
next ITEM unless ( $branches_to_process{$lib} ); |
| 479 |
} |
| 417 |
if ($filter_itemtypes) { |
480 |
if ($filter_itemtypes) { |
| 418 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
481 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
| 419 |
next ITEM unless ( $itemtype_to_process{$it} ); |
482 |
next ITEM unless ( $itemtype_to_process{$it} ); |
| 420 |
- |
|
|