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

(-)a/C4/Circulation.pm (-4 / +4 lines)
Lines 43-49 use Koha::Account; Link Here
43
use Koha::AuthorisedValues;
43
use Koha::AuthorisedValues;
44
use Koha::Biblioitems;
44
use Koha::Biblioitems;
45
use Koha::DateUtils;
45
use Koha::DateUtils;
46
use Koha::Calendar;
46
use Koha::DiscreteCalendar;
47
use Koha::Checkouts;
47
use Koha::Checkouts;
48
use Koha::IssuingRules;
48
use Koha::IssuingRules;
49
use Koha::Items;
49
use Koha::Items;
Lines 1211-1217 sub checkHighHolds { Link Here
1211
1211
1212
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1212
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1213
1213
1214
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1214
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
1215
1215
1216
        my $itype = $item_object->effective_itemtype;
1216
        my $itype = $item_object->effective_itemtype;
1217
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
1217
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branch, $borrower );
Lines 2151-2157 sub MarkIssueReturned { Link Here
2151
    my $query = 'UPDATE issues SET returndate=';
2151
    my $query = 'UPDATE issues SET returndate=';
2152
    my @bind;
2152
    my @bind;
2153
    if ($dropbox_branch) {
2153
    if ($dropbox_branch) {
2154
        my $calendar = Koha::Calendar->new( branchcode => $dropbox_branch );
2154
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $dropbox_branch );
2155
        my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 );
2155
        my $dropboxdate = $calendar->addDate( DateTime->now( time_zone => C4::Context->tz), -1 );
2156
        $query .= ' ? ';
2156
        $query .= ' ? ';
2157
        push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M');
2157
        push @bind, $dropboxdate->strftime('%Y-%m-%d %H:%M');
Lines 3474-3480 sub CalcDateDue { Link Here
3474
        else { # days
3474
        else { # days
3475
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3475
            $dur = DateTime::Duration->new( days => $loanlength->{$length_key});
3476
        }
3476
        }
3477
        my $calendar = Koha::Calendar->new( branchcode => $branch );
3477
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
3478
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3478
        $datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} );
3479
        if ($loanlength->{lengthunit} eq 'days') {
3479
        if ($loanlength->{lengthunit} eq 'days') {
3480
            $datedue->set_hour(23);
3480
            $datedue->set_hour(23);
(-)a/C4/HoldsQueue.pm (-4 / +4 lines)
Lines 30-36 use C4::Members; Link Here
30
use C4::Biblio;
30
use C4::Biblio;
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use Koha::Patrons;
32
use Koha::Patrons;
33
33
use Koha::DiscreteCalendar;
34
use List::Util qw(shuffle);
34
use List::Util qw(shuffle);
35
use List::MoreUtils qw(any);
35
use List::MoreUtils qw(any);
36
use Data::Dumper;
36
use Data::Dumper;
Lines 77-83 sub TransportCostMatrix { Link Here
77
        };
77
        };
78
78
79
        if ( C4::Context->preference("HoldsQueueSkipClosed") ) {
79
        if ( C4::Context->preference("HoldsQueueSkipClosed") ) {
80
            $calendars->{$from} ||= Koha::Calendar->new( branchcode => $from );
80
            $calendars->{$from} ||= Koha::DiscreteCalendar->new( branchcode => $from );
81
            $transport_cost_matrix{$to}{$from}{disable_transfer} ||=
81
            $transport_cost_matrix{$to}{$from}{disable_transfer} ||=
82
              $calendars->{$from}->is_holiday( $today );
82
              $calendars->{$from}->is_holiday( $today );
83
        }
83
        }
Lines 206-212 sub CreateQueue { Link Here
206
        $total_requests        += scalar(@$hold_requests);
206
        $total_requests        += scalar(@$hold_requests);
207
        $total_available_items += scalar(@$available_items);
207
        $total_available_items += scalar(@$available_items);
208
208
209
        my $item_map = MapItemsToHoldRequests($hold_requests, $available_items, $branches_to_use, $transport_cost_matrix);
209
       my $item_map = MapItemsToHoldRequests($hold_requests, $available_items, $branches_to_use, $transport_cost_matrix);
210
        $item_map  or next;
210
        $item_map  or next;
211
        my $item_map_size = scalar(keys %$item_map)
211
        my $item_map_size = scalar(keys %$item_map)
212
          or next;
212
          or next;
Lines 742-748 sub load_branches_to_pull_from { Link Here
742
    my $today = dt_from_string();
742
    my $today = dt_from_string();
743
    if ( C4::Context->preference('HoldsQueueSkipClosed') ) {
743
    if ( C4::Context->preference('HoldsQueueSkipClosed') ) {
744
        @branches_to_use = grep {
744
        @branches_to_use = grep {
745
            !Koha::Calendar->new( branchcode => $_ )
745
            !Koha::DiscreteCalendar->new( branchcode => $_ )
746
              ->is_holiday( $today )
746
              ->is_holiday( $today )
747
        } @branches_to_use;
747
        } @branches_to_use;
748
    }
748
    }
(-)a/C4/Overdues.pm (-2 / +3 lines)
Lines 34-39 use C4::Accounts; Link Here
34
use C4::Log; # logaction
34
use C4::Log; # logaction
35
use C4::Debug;
35
use C4::Debug;
36
use Koha::DateUtils;
36
use Koha::DateUtils;
37
use Koha::DiscreteCalendar;
37
use Koha::Account::Line;
38
use Koha::Account::Line;
38
use Koha::Account::Lines;
39
use Koha::Account::Lines;
39
use Koha::IssuingRules;
40
use Koha::IssuingRules;
Lines 298-304 sub get_chargeable_units { Link Here
298
    my $charge_duration;
299
    my $charge_duration;
299
    if ($unit eq 'hours') {
300
    if ($unit eq 'hours') {
300
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
301
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
301
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
302
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
302
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
303
            $charge_duration = $calendar->hours_between( $date_due, $date_returned );
303
        } else {
304
        } else {
304
            $charge_duration = $date_returned->delta_ms( $date_due );
305
            $charge_duration = $date_returned->delta_ms( $date_due );
Lines 310-316 sub get_chargeable_units { Link Here
310
    }
311
    }
311
    else { # days
312
    else { # days
312
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
313
        if(C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed') {
313
            my $calendar = Koha::Calendar->new( branchcode => $branchcode );
314
            my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
314
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
315
            $charge_duration = $calendar->days_between( $date_due, $date_returned );
315
        } else {
316
        } else {
316
            $charge_duration = $date_returned->delta_days( $date_due );
317
            $charge_duration = $date_returned->delta_days( $date_due );
(-)a/C4/Reserves.pm (-2 / +2 lines)
Lines 38-44 use C4::Log; Link Here
38
38
39
use Koha::Biblios;
39
use Koha::Biblios;
40
use Koha::DateUtils;
40
use Koha::DateUtils;
41
use Koha::Calendar;
41
use Koha::DiscreteCalendar;
42
use Koha::Database;
42
use Koha::Database;
43
use Koha::Hold;
43
use Koha::Hold;
44
use Koha::Old::Hold;
44
use Koha::Old::Hold;
Lines 811-817 sub CancelExpiredReserves { Link Here
811
    );
811
    );
812
812
813
    while ( my $hold = $holds->next ) {
813
    while ( my $hold = $holds->next ) {
814
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
814
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $hold->branchcode );
815
815
816
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
816
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
817
817
(-)a/Koha/Hold.pm (-2 / +2 lines)
Lines 25-31 use Data::Dumper qw(Dumper); Link Here
25
25
26
use C4::Context qw(preference);
26
use C4::Context qw(preference);
27
use C4::Log;
27
use C4::Log;
28
28
use Koha::DiscreteCalendar;
29
use Koha::DateUtils qw(dt_from_string output_pref);
29
use Koha::DateUtils qw(dt_from_string output_pref);
30
use Koha::Patrons;
30
use Koha::Patrons;
31
use Koha::Biblios;
31
use Koha::Biblios;
Lines 136-142 sub set_waiting { Link Here
136
136
137
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
137
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
138
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
138
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
139
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
139
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $self->branchcode );
140
140
141
    my $expirationdate = $today->clone;
141
    my $expirationdate = $today->clone;
142
    $expirationdate->add(days => $max_pickup_delay);
142
    $expirationdate->add(days => $max_pickup_delay);
(-)a/circ/returns.pl (-2 / +3 lines)
Lines 51-57 use C4::Koha; # FIXME : is it still useful ? Link Here
51
use C4::RotatingCollections;
51
use C4::RotatingCollections;
52
use Koha::AuthorisedValues;
52
use Koha::AuthorisedValues;
53
use Koha::DateUtils;
53
use Koha::DateUtils;
54
use Koha::Calendar;
54
use Koha::DiscreteCalendar;
55
use Koha::Checkouts;
55
use Koha::BiblioFrameworks;
56
use Koha::BiblioFrameworks;
56
use Koha::Checkouts;
57
use Koha::Checkouts;
57
use Koha::Holds;
58
use Koha::Holds;
Lines 211-217 my $dropboxmode = $query->param('dropboxmode'); Link Here
211
my $dotransfer  = $query->param('dotransfer');
212
my $dotransfer  = $query->param('dotransfer');
212
my $canceltransfer = $query->param('canceltransfer');
213
my $canceltransfer = $query->param('canceltransfer');
213
my $dest = $query->param('dest');
214
my $dest = $query->param('dest');
214
my $calendar    = Koha::Calendar->new( branchcode => $userenv_branch );
215
my $calendar    = Koha::DiscreteCalendar->new( branchcode => $userenv_branch );
215
#dropbox: get last open day (today - 1)
216
#dropbox: get last open day (today - 1)
216
my $today       = DateTime->now( time_zone => C4::Context->tz());
217
my $today       = DateTime->now( time_zone => C4::Context->tz());
217
my $dropboxdate = $calendar->addDate($today, -1);
218
my $dropboxdate = $calendar->addDate($today, -1);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 79-84 Link Here
79
    <dd>Define days when the library is closed</dd>
79
    <dd>Define days when the library is closed</dd>
80
    [% END %]
80
    [% END %]
81
81
82
    [% IF ( CAN_user_tools_edit_calendar ) %]
83
    <dt><a href="/cgi-bin/koha/tools/discrete_calendar.pl">Discrete Calendar</a></dt>
84
    <dd>Define days when the library is closed</dd>
85
    [% END %]
86
82
    [% IF ( CAN_user_tools_manage_csv_profiles ) %]
87
    [% IF ( CAN_user_tools_manage_csv_profiles ) %]
83
    <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt>
88
    <dt><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></dt>
84
	<dd>Manage CSV export profiles</dd>
89
	<dd>Manage CSV export profiles</dd>
(-)a/misc/cronjobs/fines.pl (-2 / +2 lines)
Lines 36-42 use Getopt::Long; Link Here
36
use Carp;
36
use Carp;
37
use File::Spec;
37
use File::Spec;
38
38
39
use Koha::Calendar;
39
use Koha::DiscreteCalendar;
40
use Koha::DateUtils;
40
use Koha::DateUtils;
41
use C4::Log;
41
use C4::Log;
42
42
Lines 176-182 EOM Link Here
176
sub set_holiday {
176
sub set_holiday {
177
    my ( $branch, $dt ) = @_;
177
    my ( $branch, $dt ) = @_;
178
178
179
    my $calendar = Koha::Calendar->new( branchcode => $branch );
179
    my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch );
180
    return $calendar->is_holiday($dt);
180
    return $calendar->is_holiday($dt);
181
}
181
}
182
182
(-)a/misc/cronjobs/overdue_notices.pl (-11 / +7 lines)
Lines 40-46 use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_lette Link Here
40
use C4::Log;
40
use C4::Log;
41
use Koha::Patron::Debarments qw(AddUniqueDebarment);
41
use Koha::Patron::Debarments qw(AddUniqueDebarment);
42
use Koha::DateUtils;
42
use Koha::DateUtils;
43
use Koha::Calendar;
43
use Koha::DiscreteCalendar;
44
use Koha::Libraries;
44
use Koha::Libraries;
45
use Koha::Acquisition::Currencies;
45
use Koha::Acquisition::Currencies;
46
46
Lines 443-451 elsif ( defined $text_filename ) { Link Here
443
}
443
}
444
444
445
foreach my $branchcode (@branches) {
445
foreach my $branchcode (@branches) {
446
    my $calendar;
447
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
446
    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
448
        $calendar = Koha::Calendar->new( branchcode => $branchcode );
447
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
449
        if ( $calendar->is_holiday($date_to_run) ) {
448
        if ( $calendar->is_holiday($date_to_run) ) {
450
            next;
449
            next;
451
        }
450
        }
Lines 546-558 END_SQL Link Here
546
                my $days_between;
545
                my $days_between;
547
                if ( C4::Context->preference('OverdueNoticeCalendar') )
546
                if ( C4::Context->preference('OverdueNoticeCalendar') )
548
                {
547
                {
549
                    $days_between =
548
                    my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
550
                      $calendar->days_between( dt_from_string($data->{date_due}),
549
                    $days_between = $calendar->days_between( dt_from_string($data->{date_due}), $date_to_run );
551
                        $date_to_run );
552
                }
550
                }
553
                else {
551
                else {
554
                    $days_between =
552
                    $days_between = $date_to_run->delta_days( dt_from_string($data->{date_due}) );
555
                      $date_to_run->delta_days( dt_from_string($data->{date_due}) );
556
                }
553
                }
557
                $days_between = $days_between->in_units('days');
554
                $days_between = $days_between->in_units('days');
558
                if ($triggered) {
555
                if ($triggered) {
Lines 628-636 END_SQL Link Here
628
                my $exceededPrintNoticesMaxLines = 0;
625
                my $exceededPrintNoticesMaxLines = 0;
629
                while ( my $item_info = $sth2->fetchrow_hashref() ) {
626
                while ( my $item_info = $sth2->fetchrow_hashref() ) {
630
                    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
627
                    if ( C4::Context->preference('OverdueNoticeCalendar') ) {
631
                        $days_between =
628
                        my $calendar = Koha::DiscreteCalendar->new( branchcode => $branchcode );
632
                          $calendar->days_between(
629
                        $days_between = $calendar->days_between( dt_from_string( $item_info->{date_due} ), $date_to_run );
633
                            dt_from_string( $item_info->{date_due} ), $date_to_run );
634
                    }
630
                    }
635
                    else {
631
                    else {
636
                        $days_between =
632
                        $days_between =
(-)a/misc/cronjobs/staticfines.pl (-2 / +2 lines)
Lines 40-46 use Date::Calc qw/Date_to_Days/; Link Here
40
use C4::Context;
40
use C4::Context;
41
use C4::Circulation;
41
use C4::Circulation;
42
use C4::Overdues;
42
use C4::Overdues;
43
use C4::Calendar qw();    # don't need any exports from Calendar
43
use Koha::DiscreteCalendar qw();    # don't need any exports from Calendar
44
use C4::Biblio;
44
use C4::Biblio;
45
use C4::Debug;            # supplying $debug and $cgi_debug
45
use C4::Debug;            # supplying $debug and $cgi_debug
46
use C4::Log;
46
use C4::Log;
Lines 176-182 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
176
176
177
    my $calendar;
177
    my $calendar;
178
    unless ( defined( $calendars{$branchcode} ) ) {
178
    unless ( defined( $calendars{$branchcode} ) ) {
179
        $calendars{$branchcode} = C4::Calendar->new( branchcode => $branchcode );
179
        $calendars{$branchcode} = Koha::DiscreteCalendar->new( branchcode => $branchcode );
180
    }
180
    }
181
    $calendar = $calendars{$branchcode};
181
    $calendar = $calendars{$branchcode};
182
    my $isHoliday = $calendar->isHoliday( $tday, $tmonth, $tyear );
182
    my $isHoliday = $calendar->isHoliday( $tday, $tmonth, $tyear );
(-)a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl (-3 / +2 lines)
Lines 35-41 use C4::Context; Link Here
35
use C4::Items;
35
use C4::Items;
36
use C4::Letters;
36
use C4::Letters;
37
use C4::Overdues;
37
use C4::Overdues;
38
use Koha::Calendar;
38
use Koha::DiscreteCalendar;
39
use Koha::DateUtils;
39
use Koha::DateUtils;
40
40
41
sub usage {
41
sub usage {
Lines 294-300 sub GetWaitingHolds { Link Here
294
    $sth->execute();
294
    $sth->execute();
295
    my @results;
295
    my @results;
296
    while ( my $issue = $sth->fetchrow_hashref() ) {
296
    while ( my $issue = $sth->fetchrow_hashref() ) {
297
        my $calendar = Koha::Calendar->new( branchcode => $issue->{'site'} );
297
        my $calendar = Koha::DiscreteCalendar->new( branchcode => $issue->{'site'} );
298
298
299
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
299
        my $waiting_date = dt_from_string( $issue->{waitingdate}, 'sql' );
300
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
300
        my $pickup_date = $waiting_date->clone->add( days => $pickupdelay );
301
- 

Return to bug 17015