View | Details | Raw Unified | Return to bug 25958
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_25958.sql (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{
4
        INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
5
        ('DefaultLongOverdueSkipLostStatuses', '', NULL, 'Skip these lost statuses by default in longoverdue.pl', 'Free'),
6
    });
7
8
    NewVersion( $DBversion, 25958, "Allow LongOverdue cron to exclude specified lost values");
9
}
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 149-154 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
149
('DefaultClassificationSource','ddc',NULL,'Default classification scheme used by the collection. E.g., Dewey, LCC, etc.','ClassSources'),
149
('DefaultClassificationSource','ddc',NULL,'Default classification scheme used by the collection. E.g., Dewey, LCC, etc.','ClassSources'),
150
('DefaultCountryField008','','','Fill in the default country code for field 008 Range 15-17 of MARC21 - Place of publication, production, or execution. See <a href=\"http://www.loc.gov/marc/countries/countries_code.html\">MARC Code List for Countries</a>','Free'),
150
('DefaultCountryField008','','','Fill in the default country code for field 008 Range 15-17 of MARC21 - Place of publication, production, or execution. See <a href=\"http://www.loc.gov/marc/countries/countries_code.html\">MARC Code List for Countries</a>','Free'),
151
('DefaultLanguageField008','','','Fill in the default language for field 008 Range 35-37 of MARC21 records (e.g. eng, nor, ger, see <a href=\"http://www.loc.gov/marc/languages/language_code.html\">MARC Code List for Languages</a>)','Free'),
151
('DefaultLanguageField008','','','Fill in the default language for field 008 Range 35-37 of MARC21 records (e.g. eng, nor, ger, see <a href=\"http://www.loc.gov/marc/languages/language_code.html\">MARC Code List for Languages</a>)','Free'),
152
('DefaultLongOverdueSkipLostStatuses', '', NULL, 'Skip these lost statuses by default in longoverdue.pl', 'Free'),
152
('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
153
('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
153
('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
154
('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
154
('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
155
('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+5 lines)
Lines 421-426 Circulation: Link Here
421
            - <br>(Used when the longoverdue.pl script is called without the --charge parameter)
421
            - <br>(Used when the longoverdue.pl script is called without the --charge parameter)
422
            - "<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/longoverdue.pl</code> cronjob. Ask your system administrator to schedule it."
422
            - "<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/longoverdue.pl</code> cronjob. Ask your system administrator to schedule it."
423
        -
423
        -
424
            - When using the automatic item loss process, skip items with lost values matching any of
425
            - pref: DefaultLongOverdueSkipLostStatuses
426
            - <br>Leave this field empty if you don't want to skip any lost statuses
427
            - <br>Set to a list of comma separated values, e.g. <em>5,6,7</em>
428
        -
424
            - "When issuing an item that has been marked as lost, "
429
            - "When issuing an item that has been marked as lost, "
425
            - pref: IssueLostItem
430
            - pref: IssueLostItem
426
              choices:
431
              choices:
(-)a/misc/cronjobs/longoverdue.pl (-24 / +43 lines)
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
- 

Return to bug 25958