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

(-)a/installer/data/mysql/atomicupdate/bug_18064-add_LongOverdueNoticeCalendar_syspref.pl (+12 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "BUG_18064",
5
    description => "Add new system preference LongOverdueNoticeCalendar",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('LongOverdueNoticeCalendar', '0', NULL, 'Take the calendar into consideration when generating long overdue notices', 'Yes/No') });
11
    },
12
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 352-357 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
352
('LocalHoldsPriorityItemControl',  'holdingbranch',  'holdingbranch|homebranch',  'decides if the feature operates using the item''s home or holding library.',  'Choice'),
352
('LocalHoldsPriorityItemControl',  'holdingbranch',  'holdingbranch|homebranch',  'decides if the feature operates using the item''s home or holding library.',  'Choice'),
353
('LocalHoldsPriorityPatronControl',  'PickupLibrary',  'HomeLibrary|PickupLibrary',  'decides if the feature operates using the library set as the patron''s home library, or the library set as the pickup library for the given hold.',  'Choice'),
353
('LocalHoldsPriorityPatronControl',  'PickupLibrary',  'HomeLibrary|PickupLibrary',  'decides if the feature operates using the library set as the patron''s home library, or the library set as the pickup library for the given hold.',  'Choice'),
354
('LockExpiredDelay','','','Delay for locking expired patrons (empty means no locking)','Integer'),
354
('LockExpiredDelay','','','Delay for locking expired patrons (empty means no locking)','Integer'),
355
('LongOverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating long overdue notices','YesNo'),
355
('makePreviousSerialAvailable','0','','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','YesNo'),
356
('makePreviousSerialAvailable','0','','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','YesNo'),
356
('Mana','2',NULL,'request to Mana Webservice. Mana centralize common information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','Choice'),
357
('Mana','2',NULL,'request to Mana Webservice. Mana centralize common information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','Choice'),
357
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
358
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 403-408 Circulation: Link Here
403
            - "Send all notices as a BCC to this email address:"
403
            - "Send all notices as a BCC to this email address:"
404
            - pref: NoticeBcc
404
            - pref: NoticeBcc
405
              class: email
405
              class: email
406
        -
407
            - pref: LongOverdueNoticeCalendar
408
              choices:
409
                  1: Use calendar
410
                  0: Ignore calendar
411
            - "when working out the period for long overdue notices."
406
        -
412
        -
407
            - pref: OverdueNoticeCalendar
413
            - pref: OverdueNoticeCalendar
408
              choices:
414
              choices:
(-)a/misc/cronjobs/longoverdue.pl (-5 / +60 lines)
Lines 30-35 use warnings; Link Here
30
30
31
use Getopt::Long qw( GetOptions );
31
use Getopt::Long qw( GetOptions );
32
use Pod::Usage qw( pod2usage );
32
use Pod::Usage qw( pod2usage );
33
use DateTime;
34
use DateTime::Duration;
33
35
34
use C4::Circulation qw( LostItem MarkIssueReturned );
36
use C4::Circulation qw( LostItem MarkIssueReturned );
35
use C4::Context;
37
use C4::Context;
Lines 38-43 use Koha::ItemTypes; Link Here
38
use Koha::Patron::Categories;
40
use Koha::Patron::Categories;
39
use Koha::Patrons;
41
use Koha::Patrons;
40
use Koha::Script -cron;
42
use Koha::Script -cron;
43
use Koha::Calendar;
44
use Koha::DateUtils qw( dt_from_string );
45
41
46
42
my  $lost;  #  key=lost value,  value=num days.
47
my  $lost;  #  key=lost value,  value=num days.
43
my ($charge, $verbose, $confirm, $quiet);
48
my ($charge, $verbose, $confirm, $quiet);
Lines 314-319 sub longoverdue_sth { Link Here
314
    return C4::Context->dbh->prepare($query);
319
    return C4::Context->dbh->prepare($query);
315
}
320
}
316
321
322
my @holidays_by_branch;
323
324
sub get_number_of_holidays {
325
    my ( $start_date, $end_date ) = @_;
326
327
    $start_date = dt_from_string($start_date);
328
    $end_date   = dt_from_string($end_date);
329
330
    my @branches = Koha::Libraries->search( {}, { order_by => ['branchcode'] } );
331
    my $calendar;
332
333
    foreach my $branch ( @branches ) {
334
        my $date_to_run = $start_date->clone();
335
        my $branchcode  = $branch->branchcode;
336
        my $i           = 0;
337
338
        $calendar = Koha::Calendar->new( branchcode => $branchcode );
339
340
        while ( $date_to_run ne $end_date ) {
341
            # printf "\n Treatment of the day : %s \n", $date_to_run;
342
            if ( $calendar->is_holiday( $date_to_run ) ) {
343
                $i++;
344
            }
345
            $date_to_run->add( days => 1 );
346
        }
347
        push @holidays_by_branch, { 'branchcode' => $branchcode, 'nb_holidays' => $i };
348
    }
349
    return @holidays_by_branch;
350
}
351
317
my $dbh = C4::Context->dbh;
352
my $dbh = C4::Context->dbh;
318
353
319
my @available_categories = Koha::Patron::Categories->search()->get_column('categorycode');
354
my @available_categories = Koha::Patron::Categories->search()->get_column('categorycode');
Lines 386-396 foreach my $startrange (sort keys %$lost) { Link Here
386
    if( my $lostvalue = $lost->{$startrange} ) {
421
    if( my $lostvalue = $lost->{$startrange} ) {
387
        my ($date1) = bounds($startrange);
422
        my ($date1) = bounds($startrange);
388
        my ($date2) = bounds(  $endrange);
423
        my ($date2) = bounds(  $endrange);
424
425
        if ( C4::Context->preference( 'LongOverdueNoticeCalendar' ) ) {
426
            get_number_of_holidays( $date2, $date1 );
427
428
            foreach my $branch ( @holidays_by_branch ) {
429
430
                my $date2_with_holidays = dt_from_string($date2)
431
                  ->subtract( days => $branch->{'nb_holidays'} )->ymd;
432
                my $endrange_with_holidays =
433
                  $endrange + $branch->{'nb_holidays'};
434
435
                    $verbose and
436
                printf "\nBranchcode %s\nDue %3s - %3s days ago (%s to %s) - with %s holiday(s), lost => %s\n", $branch->{'branchcode'},
437
                $startrange, $endrange_with_holidays, $date2_with_holidays, $date1, $branch->{'nb_holidays'}, $lostvalue;
438
                $sth_items->execute($startrange, $endrange_with_holidays, $lostvalue);
439
            }
440
        } else {
441
389
        # print "\nRange ", ++$i, "\nDue $startrange - $endrange days ago ($date2 to $date1), lost => $lostvalue\n" if($verbose);
442
        # print "\nRange ", ++$i, "\nDue $startrange - $endrange days ago ($date2 to $date1), lost => $lostvalue\n" if($verbose);
390
        $verbose and
443
        $verbose and
391
            printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i,
444
            printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i,
392
            $startrange, $endrange, $date2, $date1, $lostvalue;
445
            $startrange, $endrange, $date2, $date1, $lostvalue;
393
        $sth_items->execute($startrange, $endrange, $lostvalue);
446
        $sth_items->execute($startrange, $endrange, $lostvalue);
447
        }
394
        $count=0;
448
        $count=0;
395
        ITEM: while (my $row=$sth_items->fetchrow_hashref) {
449
        ITEM: while (my $row=$sth_items->fetchrow_hashref) {
396
            if( $filter_borrower_categories ) {
450
            if( $filter_borrower_categories ) {
Lines 440-449 sub summarize { Link Here
440
    }
494
    }
441
}
495
}
442
496
443
if (!$quiet){
497
if (!( C4::Context->preference( 'LongOverdueNoticeCalendar' ) )) {
444
    print "\n### LONGOVERDUE SUMMARY ###";
498
    if (!$quiet){
445
    summarize (\@report, 1);
499
        print "\n### LONGOVERDUE SUMMARY ###";
446
    print "\nTOTAL: $total items\n";
500
        summarize (\@report, 1);
501
        print "\nTOTAL: $total items\n";
502
    }
447
}
503
}
448
504
449
cronlogaction({ action => 'End', info => "COMPLETED" });
505
cronlogaction({ action => 'End', info => "COMPLETED" });
450
- 

Return to bug 18064