|
Lines 47-69
my $endrange = 366;
Link Here
|
| 47 |
my $mark_returned; |
47 |
my $mark_returned; |
| 48 |
my $borrower_category = []; |
48 |
my $borrower_category = []; |
| 49 |
my $skip_borrower_category = []; |
49 |
my $skip_borrower_category = []; |
|
|
50 |
my $itemtype = []; |
| 51 |
my $skip_itemtype = []; |
| 50 |
my $help=0; |
52 |
my $help=0; |
| 51 |
my $man=0; |
53 |
my $man=0; |
| 52 |
my $list_categories = 0; |
54 |
my $list_categories = 0; |
|
|
55 |
my $list_itemtypes = 0; |
| 53 |
|
56 |
|
| 54 |
GetOptions( |
57 |
GetOptions( |
| 55 |
'lost=s%' => \$lost, |
58 |
'l|lost=s%' => \$lost, |
| 56 |
'c|charge=s' => \$charge, |
59 |
'c|charge=s' => \$charge, |
| 57 |
'confirm' => \$confirm, |
60 |
'confirm' => \$confirm, |
| 58 |
'v|verbose' => \$verbose, |
61 |
'v|verbose' => \$verbose, |
| 59 |
'quiet' => \$quiet, |
62 |
'quiet' => \$quiet, |
| 60 |
'maxdays=s' => \$endrange, |
63 |
'maxdays=s' => \$endrange, |
| 61 |
'mark-returned' => \$mark_returned, |
64 |
'mark-returned' => \$mark_returned, |
| 62 |
'h|help' => \$help, |
65 |
'h|help' => \$help, |
| 63 |
'man|manual' => \$man, |
66 |
'man|manual' => \$man, |
| 64 |
'category=s' => $borrower_category, |
67 |
'category=s' => $borrower_category, |
| 65 |
'skip-category=s' => $skip_borrower_category, |
68 |
'skip-category=s' => $skip_borrower_category, |
| 66 |
'list-categories' => \$list_categories, |
69 |
'list-categories' => \$list_categories, |
|
|
70 |
'itemtype=s' => $itemtype, |
| 71 |
'skip-itemtype=s' => $skip_itemtype, |
| 72 |
'list-itemtypes' => \$list_itemtypes, |
| 67 |
); |
73 |
); |
| 68 |
|
74 |
|
| 69 |
if ( $man ) { |
75 |
if ( $man ) { |
|
Lines 86-94
if ( scalar @$borrower_category && scalar @$skip_borrower_category) {
Link Here
|
| 86 |
); |
92 |
); |
| 87 |
} |
93 |
} |
| 88 |
|
94 |
|
|
|
95 |
if ( scalar @$itemtype && scalar @$skip_itemtype) { |
| 96 |
pod2usage( -verbose => 1, |
| 97 |
-message => "The options --itemtype and --skip-itemtype are mually exclusive.\n" |
| 98 |
. "Use one or the other.", |
| 99 |
-exitval => 1 |
| 100 |
); |
| 101 |
} |
| 102 |
|
| 89 |
if ( $list_categories ) { |
103 |
if ( $list_categories ) { |
| 90 |
my @categories = sort map { uc $_->[0] } @{ C4::Context->dbh->selectall_arrayref(q|SELECT categorycode FROM categories|) }; |
104 |
my @categories = sort map { uc $_->[0] } @{ C4::Context->dbh->selectall_arrayref(q|SELECT categorycode FROM categories|) }; |
| 91 |
print "\nBorrowrer Categories: " . join( " ", @categories ) . "\n\n"; |
105 |
print "\nBorrower Categories: " . join( " ", @categories ) . "\n\n"; |
|
|
106 |
exit 0; |
| 107 |
} |
| 108 |
|
| 109 |
if ( $list_itemtypes ) { |
| 110 |
my @itemtypes = sort map { uc $_->[0] } @{ C4::Context->dbh->selectall_arrayref(q|SELECT itemtype FROM itemtypes|) }; |
| 111 |
print "\nItemtypes: " . join( " ", @itemtypes ) . "\n\n"; |
| 92 |
exit 0; |
112 |
exit 0; |
| 93 |
} |
113 |
} |
| 94 |
|
114 |
|
|
Lines 161-166
May not be used with B<--category>
Link Here
|
| 161 |
List borrower categories available for use by B<--category> or |
181 |
List borrower categories available for use by B<--category> or |
| 162 |
B<--skip-category>, and exit. |
182 |
B<--skip-category>, and exit. |
| 163 |
|
183 |
|
|
|
184 |
=item B<--itemtype> |
| 185 |
|
| 186 |
Act on the listed itemtype code. |
| 187 |
Exclude all others. This may be specified multiple times to include multiple itemtypes. |
| 188 |
May not be used with B<--skip-itemtype> |
| 189 |
|
| 190 |
=item B<--skip-itemtype> |
| 191 |
|
| 192 |
Act on all available itemtype codes, except those listed. |
| 193 |
This may be specified multiple times, to exclude multiple itemtypes. |
| 194 |
May not be used with B<--itemtype> |
| 195 |
|
| 196 |
=item B<--list-itemtypes> |
| 197 |
|
| 198 |
List itemtypes available for use by B<--itemtype> or |
| 199 |
B<--skip-itemtype>, and exit. |
| 200 |
|
| 164 |
=item B<--help | -h> |
201 |
=item B<--help | -h> |
| 165 |
|
202 |
|
| 166 |
Display short help message an exit. |
203 |
Display short help message an exit. |
|
Lines 253-258
sub longoverdue_sth {
Link Here
|
| 253 |
} |
290 |
} |
| 254 |
|
291 |
|
| 255 |
my $dbh = C4::Context->dbh; |
292 |
my $dbh = C4::Context->dbh; |
|
|
293 |
|
| 256 |
my @available_categories = map { uc $_->[0] } @{ $dbh->selectall_arrayref(q|SELECT categorycode FROM categories|) }; |
294 |
my @available_categories = map { uc $_->[0] } @{ $dbh->selectall_arrayref(q|SELECT categorycode FROM categories|) }; |
| 257 |
$borrower_category = [ map { uc $_ } @$borrower_category ]; |
295 |
$borrower_category = [ map { uc $_ } @$borrower_category ]; |
| 258 |
$skip_borrower_category = [ map { uc $_} @$skip_borrower_category ]; |
296 |
$skip_borrower_category = [ map { uc $_} @$skip_borrower_category ]; |
|
Lines 281-286
if ( @$skip_borrower_category ) {
Link Here
|
| 281 |
|
319 |
|
| 282 |
my $filter_borrower_categories = ( scalar @$borrower_category || scalar @$skip_borrower_category ); |
320 |
my $filter_borrower_categories = ( scalar @$borrower_category || scalar @$skip_borrower_category ); |
| 283 |
|
321 |
|
|
|
322 |
my @available_itemtypes = map { uc $_->[0] } @{ $dbh->selectall_arrayref(q|SELECT itemtype FROM itemtypes|) }; |
| 323 |
$itemtype = [ map { uc $_ } @$itemtype ]; |
| 324 |
$skip_itemtype = [ map { uc $_} @$skip_itemtype ]; |
| 325 |
my %itemtype_to_process; |
| 326 |
for my $it ( @$itemtype ) { |
| 327 |
unless ( grep { /^$it$/ } @available_itemtypes ) { |
| 328 |
pod2usage( |
| 329 |
'-exitval' => 1, |
| 330 |
'-message' => "The itemtype $it does not exist in the database", |
| 331 |
); |
| 332 |
} |
| 333 |
$itemtype_to_process{$it} = 1; |
| 334 |
} |
| 335 |
if ( @$skip_itemtype ) { |
| 336 |
for my $it ( @$skip_itemtype ) { |
| 337 |
unless ( grep { /^$it$/ } @available_itemtypes ) { |
| 338 |
pod2usage( |
| 339 |
'-exitval' => 1, |
| 340 |
'-message' => "The itemtype $it does not exist in the database", |
| 341 |
); |
| 342 |
} |
| 343 |
} |
| 344 |
%itemtype_to_process = map { $_ => 1 } @available_itemtypes; |
| 345 |
%itemtype_to_process = ( %itemtype_to_process, map { $_ => 0 } @$skip_itemtype ); |
| 346 |
} |
| 347 |
|
| 348 |
my $filter_itemtypes = ( scalar @$itemtype || scalar @$skip_itemtype ); |
| 349 |
|
| 284 |
my $count; |
350 |
my $count; |
| 285 |
my @report; |
351 |
my @report; |
| 286 |
my $total = 0; |
352 |
my $total = 0; |
|
Lines 306-311
foreach my $startrange (sort keys %$lost) {
Link Here
|
| 306 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
372 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
| 307 |
next ITEM unless ( $category_to_process{ $category } ); |
373 |
next ITEM unless ( $category_to_process{ $category } ); |
| 308 |
} |
374 |
} |
|
|
375 |
if ($filter_itemtypes) { |
| 376 |
my $it = uc Koha::Items->find( $row->{itemnumber} )->effective_itemtype(); |
| 377 |
next ITEM unless ( $itemtype_to_process{$it} ); |
| 378 |
} |
| 309 |
printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose); |
379 |
printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose); |
| 310 |
if($confirm) { |
380 |
if($confirm) { |
| 311 |
ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'}); |
381 |
ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'}); |
| 312 |
- |
|
|