Lines 34-49
BEGIN {
Link Here
|
34 |
eval { require "$FindBin::Bin/../kohalib.pl" }; |
34 |
eval { require "$FindBin::Bin/../kohalib.pl" }; |
35 |
} |
35 |
} |
36 |
|
36 |
|
37 |
use Koha::Script -cron; |
37 |
use Getopt::Long; |
|
|
38 |
use Pod::Usage; |
39 |
use List::Util qw/ any /; |
40 |
|
41 |
use C4::Circulation qw/LostItem MarkIssueReturned/; |
38 |
use C4::Context; |
42 |
use C4::Context; |
39 |
use C4::Items; |
43 |
use C4::Items; |
40 |
use C4::Circulation qw/LostItem MarkIssueReturned/; |
|
|
41 |
use Getopt::Long; |
42 |
use C4::Log; |
44 |
use C4::Log; |
43 |
use Pod::Usage; |
|
|
44 |
use Koha::Patrons; |
45 |
use Koha::Patron::Categories; |
46 |
use Koha::ItemTypes; |
45 |
use Koha::ItemTypes; |
|
|
46 |
use Koha::Patron::Categories; |
47 |
use Koha::Patrons; |
48 |
use Koha::Script -cron; |
47 |
|
49 |
|
48 |
my $lost; # key=lost value, value=num days. |
50 |
my $lost; # key=lost value, value=num days. |
49 |
my ($charge, $verbose, $confirm, $quiet); |
51 |
my ($charge, $verbose, $confirm, $quiet); |
Lines 57-79
my $help=0;
Link Here
|
57 |
my $man=0; |
59 |
my $man=0; |
58 |
my $list_categories = 0; |
60 |
my $list_categories = 0; |
59 |
my $list_itemtypes = 0; |
61 |
my $list_itemtypes = 0; |
|
|
62 |
my @skip_lost_values; |
60 |
|
63 |
|
61 |
GetOptions( |
64 |
GetOptions( |
62 |
'l|lost=s%' => \$lost, |
65 |
'l|lost=s%' => \$lost, |
63 |
'c|charge=s' => \$charge, |
66 |
'c|charge=s' => \$charge, |
64 |
'confirm' => \$confirm, |
67 |
'confirm' => \$confirm, |
65 |
'v|verbose' => \$verbose, |
68 |
'v|verbose' => \$verbose, |
66 |
'quiet' => \$quiet, |
69 |
'quiet' => \$quiet, |
67 |
'maxdays=s' => \$endrange, |
70 |
'maxdays=s' => \$endrange, |
68 |
'mark-returned' => \$mark_returned, |
71 |
'mark-returned' => \$mark_returned, |
69 |
'h|help' => \$help, |
72 |
'h|help' => \$help, |
70 |
'man|manual' => \$man, |
73 |
'man|manual' => \$man, |
71 |
'category=s' => $borrower_category, |
74 |
'category=s' => $borrower_category, |
72 |
'skip-category=s' => $skip_borrower_category, |
75 |
'skip-category=s' => $skip_borrower_category, |
73 |
'list-categories' => \$list_categories, |
76 |
'list-categories' => \$list_categories, |
74 |
'itemtype=s' => $itemtype, |
77 |
'itemtype=s' => $itemtype, |
75 |
'skip-itemtype=s' => $skip_itemtype, |
78 |
'skip-itemtype=s' => $skip_itemtype, |
76 |
'list-itemtypes' => \$list_itemtypes, |
79 |
'list-itemtypes' => \$list_itemtypes, |
|
|
80 |
'skip-lost-value=s' => \@skip_lost_values, |
77 |
); |
81 |
); |
78 |
|
82 |
|
79 |
if ( $man ) { |
83 |
if ( $man ) { |
Lines 98-104
if ( scalar @$borrower_category && scalar @$skip_borrower_category) {
Link Here
|
98 |
|
102 |
|
99 |
if ( scalar @$itemtype && scalar @$skip_itemtype) { |
103 |
if ( scalar @$itemtype && scalar @$skip_itemtype) { |
100 |
pod2usage( -verbose => 1, |
104 |
pod2usage( -verbose => 1, |
101 |
-message => "The options --itemtype and --skip-itemtype are mually exclusive.\n" |
105 |
-message => "The options --itemtype and --skip-itemtype are mutually exclusive.\n" |
102 |
. "Use one or the other.", |
106 |
. "Use one or the other.", |
103 |
-exitval => 1 |
107 |
-exitval => 1 |
104 |
); |
108 |
); |
Lines 123-128
if ( $list_itemtypes ) {
Link Here
|
123 |
longoverdue.pl --lost | -l DAYS=LOST_CODE [ --charge | -c CHARGE_CODE ] [ --verbose | -v ] [ --quiet ] |
127 |
longoverdue.pl --lost | -l DAYS=LOST_CODE [ --charge | -c CHARGE_CODE ] [ --verbose | -v ] [ --quiet ] |
124 |
[ --maxdays MAX_DAYS ] [ --mark-returned ] [ --category BORROWER_CATEGORY ] ... |
128 |
[ --maxdays MAX_DAYS ] [ --mark-returned ] [ --category BORROWER_CATEGORY ] ... |
125 |
[ --skip-category BORROWER_CATEGORY ] ... |
129 |
[ --skip-category BORROWER_CATEGORY ] ... |
|
|
130 |
[ --skip-lost-value LOST_VALUE [ --skip-lost-value LOST_VALUE ] ] |
126 |
[ --commit ] |
131 |
[ --commit ] |
127 |
|
132 |
|
128 |
|
133 |
|
Lines 198-203
Act on all available itemtype codes, except those listed.
Link Here
|
198 |
This may be specified multiple times, to exclude multiple itemtypes. |
203 |
This may be specified multiple times, to exclude multiple itemtypes. |
199 |
May not be used with B<--itemtype> |
204 |
May not be used with B<--itemtype> |
200 |
|
205 |
|
|
|
206 |
=item B<--skip-lost-value> |
207 |
|
208 |
Act on all available lost values, except those listed. |
209 |
This may be specified multiple times, to exclude multiple lost values. |
210 |
|
201 |
=item B<--list-itemtypes> |
211 |
=item B<--list-itemtypes> |
202 |
|
212 |
|
203 |
List itemtypes available for use by B<--itemtype> or |
213 |
List itemtypes available for use by B<--itemtype> or |
Lines 246-251
near-term release, so this script is not intended to have a long lifetime.
Link Here
|
246 |
# FIXME: do checks on --lost ranges to make sure the authorized values exist. |
256 |
# FIXME: do checks on --lost ranges to make sure the authorized values exist. |
247 |
# FIXME: do checks on --lost ranges to make sure don't go past endrange. |
257 |
# FIXME: do checks on --lost ranges to make sure don't go past endrange. |
248 |
# |
258 |
# |
|
|
259 |
|
260 |
unless ( scalar @skip_lost_values ) { |
261 |
my $preference = C4::Context->preference( 'DefaultLongOverdueSkipLostStatuses' ); |
262 |
@skip_lost_values = split( ',', $preference ); |
263 |
} |
264 |
|
249 |
if ( ! defined($lost) ) { |
265 |
if ( ! defined($lost) ) { |
250 |
my $longoverdue_value = C4::Context->preference('DefaultLongOverdueLostValue'); |
266 |
my $longoverdue_value = C4::Context->preference('DefaultLongOverdueLostValue'); |
251 |
my $longoverdue_days = C4::Context->preference('DefaultLongOverdueDays'); |
267 |
my $longoverdue_days = C4::Context->preference('DefaultLongOverdueDays'); |
Lines 283-289
sub bounds {
Link Here
|
283 |
# FIXME - This sql should be inside the API. |
299 |
# FIXME - This sql should be inside the API. |
284 |
sub longoverdue_sth { |
300 |
sub longoverdue_sth { |
285 |
my $query = " |
301 |
my $query = " |
286 |
SELECT items.itemnumber, borrowernumber, date_due |
302 |
SELECT items.itemnumber, borrowernumber, date_due, itemlost |
287 |
FROM issues, items |
303 |
FROM issues, items |
288 |
WHERE items.itemnumber = issues.itemnumber |
304 |
WHERE items.itemnumber = issues.itemnumber |
289 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) > date_due |
305 |
AND DATE_SUB(CURDATE(), INTERVAL ? DAY) > date_due |
Lines 373-378
foreach my $startrange (sort keys %$lost) {
Link Here
|
373 |
$sth_items->execute($startrange, $endrange, $lostvalue); |
389 |
$sth_items->execute($startrange, $endrange, $lostvalue); |
374 |
$count=0; |
390 |
$count=0; |
375 |
ITEM: while (my $row=$sth_items->fetchrow_hashref) { |
391 |
ITEM: while (my $row=$sth_items->fetchrow_hashref) { |
|
|
392 |
if ( @skip_lost_values ) { |
393 |
next ITEM if any { $_ eq $row->{itemlost} } @skip_lost_values; |
394 |
} |
395 |
|
376 |
if( $filter_borrower_categories ) { |
396 |
if( $filter_borrower_categories ) { |
377 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
397 |
my $category = uc Koha::Patrons->find( $row->{borrowernumber} )->categorycode(); |
378 |
next ITEM unless ( $category_to_process{ $category } ); |
398 |
next ITEM unless ( $category_to_process{ $category } ); |
379 |
- |
|
|