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 514-519 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
514
('OverDrivePasswordRequired','0',NULL,'Does the library require passwords for OverDrive SIP authentication','YesNo'),
514
('OverDrivePasswordRequired','0',NULL,'Does the library require passwords for OverDrive SIP authentication','YesNo'),
515
('OverDriveUsername','cardnumber','cardnumber|userid','Which patron information should be passed as OverDrive username','Choice'),
515
('OverDriveUsername','cardnumber','cardnumber|userid','Which patron information should be passed as OverDrive username','Choice'),
516
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
516
('OverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating overdue notices','YesNo'),
517
('LongOverdueNoticeCalendar',0,NULL,'Take the calendar into consideration when generating long overdue notices','YesNo'),
517
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
518
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
518
('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'),
519
('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'),
519
('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo'),
520
('PassItemMarcToXSLT','0',NULL,'If enabled, item fields in the MARC record will be made avaiable to XSLT sheets. Otherwise they will be removed.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 400-405 Circulation: Link Here
400
            - "Send all notices as a BCC to this email address:"
400
            - "Send all notices as a BCC to this email address:"
401
            - pref: NoticeBcc
401
            - pref: NoticeBcc
402
              class: email
402
              class: email
403
        -
404
            - pref: LongOverdueNoticeCalendar
405
              choices:
406
                  1: Use calendar
407
                  0: Ignore calendar
408
            - "when working out the period for long overdue notices."
403
        -
409
        -
404
            - pref: OverdueNoticeCalendar
410
            - pref: OverdueNoticeCalendar
405
              choices:
411
              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 312-317 sub longoverdue_sth { Link Here
312
    return C4::Context->dbh->prepare($query);
317
    return C4::Context->dbh->prepare($query);
313
}
318
}
314
319
320
my @holidays_by_branch;
321
322
sub get_number_of_holidays {
323
    my ( $start_date, $end_date ) = @_;
324
325
    $start_date = dt_from_string($start_date);
326
    $end_date   = dt_from_string($end_date);
327
328
    my @branches = Koha::Libraries->search( {}, { order_by => ['branchcode'] } );
329
    my $calendar;
330
331
    foreach my $branch ( @branches ) {
332
        my $date_to_run = $start_date->clone();
333
        my $branchcode  = $branch->branchcode;
334
        my $i           = 0;
335
336
        $calendar = Koha::Calendar->new( branchcode => $branchcode );
337
338
        while ( $date_to_run ne $end_date ) {
339
            # printf "\n Treatment of the day : %s \n", $date_to_run;
340
            if ( $calendar->is_holiday( $date_to_run ) ) {
341
                $i++;
342
            }
343
            $date_to_run->add( days => 1 );
344
        }
345
        push @holidays_by_branch, { 'branchcode' => $branchcode, 'nb_holidays' => $i };
346
    }
347
    return @holidays_by_branch;
348
}
349
315
my $dbh = C4::Context->dbh;
350
my $dbh = C4::Context->dbh;
316
351
317
my @available_categories = Koha::Patron::Categories->search()->get_column('categorycode');
352
my @available_categories = Koha::Patron::Categories->search()->get_column('categorycode');
Lines 384-394 foreach my $startrange (sort keys %$lost) { Link Here
384
    if( my $lostvalue = $lost->{$startrange} ) {
419
    if( my $lostvalue = $lost->{$startrange} ) {
385
        my ($date1) = bounds($startrange);
420
        my ($date1) = bounds($startrange);
386
        my ($date2) = bounds(  $endrange);
421
        my ($date2) = bounds(  $endrange);
422
423
        if ( C4::Context->preference( 'LongOverdueNoticeCalendar' ) ) {
424
            get_number_of_holidays( $date2, $date1 );
425
426
            foreach my $branch ( @holidays_by_branch ) {
427
428
                my $date2_with_holidays = dt_from_string($date2)
429
                  ->subtract( days => $branch->{'nb_holidays'} )->ymd;
430
                my $endrange_with_holidays =
431
                  $endrange + $branch->{'nb_holidays'};
432
433
                    $verbose and
434
                printf "\nBranchcode %s\nDue %3s - %3s days ago (%s to %s) - with %s holiday(s), lost => %s\n", $branch->{'branchcode'},
435
                $startrange, $endrange_with_holidays, $date2_with_holidays, $date1, $branch->{'nb_holidays'}, $lostvalue;
436
                $sth_items->execute($startrange, $endrange_with_holidays, $lostvalue);
437
            }
438
        } else {
439
387
        # print "\nRange ", ++$i, "\nDue $startrange - $endrange days ago ($date2 to $date1), lost => $lostvalue\n" if($verbose);
440
        # print "\nRange ", ++$i, "\nDue $startrange - $endrange days ago ($date2 to $date1), lost => $lostvalue\n" if($verbose);
388
        $verbose and
441
        $verbose and
389
            printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i,
442
            printf "\nRange %s\nDue %3s - %3s days ago (%s to %s), lost => %s\n", ++$i,
390
            $startrange, $endrange, $date2, $date1, $lostvalue;
443
            $startrange, $endrange, $date2, $date1, $lostvalue;
391
        $sth_items->execute($startrange, $endrange, $lostvalue);
444
        $sth_items->execute($startrange, $endrange, $lostvalue);
445
        }
392
        $count=0;
446
        $count=0;
393
        ITEM: while (my $row=$sth_items->fetchrow_hashref) {
447
        ITEM: while (my $row=$sth_items->fetchrow_hashref) {
394
            if( $filter_borrower_categories ) {
448
            if( $filter_borrower_categories ) {
Lines 438-445 sub summarize { Link Here
438
    }
492
    }
439
}
493
}
440
494
441
if (!$quiet){
495
if (!( C4::Context->preference( 'LongOverdueNoticeCalendar' ) )) {
442
    print "\n### LONGOVERDUE SUMMARY ###";
496
    if (!$quiet){
443
    summarize (\@report, 1);
497
        print "\n### LONGOVERDUE SUMMARY ###";
444
    print "\nTOTAL: $total items\n";
498
        summarize (\@report, 1);
499
        print "\nTOTAL: $total items\n";
500
    }
445
}
501
}
446
- 

Return to bug 18064