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