Lines 3581-3587
sub UpdateHoldingbranch {
Link Here
|
3581 |
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); |
3581 |
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); |
3582 |
|
3582 |
|
3583 |
this function calculates the due date given the start date and configured circulation rules, |
3583 |
this function calculates the due date given the start date and configured circulation rules, |
3584 |
checking against the holidays calendar as per the 'useDaysMode' syspref. |
3584 |
checking against the holidays calendar as per the useDaysMode circulation rule. |
3585 |
C<$startdate> = DateTime object representing start date of loan period (assumed to be today) |
3585 |
C<$startdate> = DateTime object representing start date of loan period (assumed to be today) |
3586 |
C<$itemtype> = itemtype code of item in question |
3586 |
C<$itemtype> = itemtype code of item in question |
3587 |
C<$branch> = location whose calendar to use |
3587 |
C<$branch> = location whose calendar to use |
Lines 3617-3624
sub CalcDateDue {
Link Here
|
3617 |
} |
3617 |
} |
3618 |
|
3618 |
|
3619 |
|
3619 |
|
|
|
3620 |
my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( |
3621 |
{ |
3622 |
categorycode => $borrower->{categorycode}, |
3623 |
itemtype => $itemtype, |
3624 |
branchcode => $branch, |
3625 |
} |
3626 |
); |
3627 |
|
3620 |
# calculate the datedue as normal |
3628 |
# calculate the datedue as normal |
3621 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3629 |
if ( $useDaysMode_value eq 'Days' ) |
3622 |
{ # ignoring calendar |
3630 |
{ # ignoring calendar |
3623 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3631 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3624 |
$datedue->add( hours => $loanlength->{$length_key} ); |
3632 |
$datedue->add( hours => $loanlength->{$length_key} ); |
Lines 3635-3641
sub CalcDateDue {
Link Here
|
3635 |
else { # days |
3643 |
else { # days |
3636 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3644 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3637 |
} |
3645 |
} |
3638 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
3646 |
my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value ); |
3639 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3647 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3640 |
if ($loanlength->{lengthunit} eq 'days') { |
3648 |
if ($loanlength->{lengthunit} eq 'days') { |
3641 |
$datedue->set_hour(23); |
3649 |
$datedue->set_hour(23); |
Lines 3673-3680
sub CalcDateDue {
Link Here
|
3673 |
$datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz ); |
3681 |
$datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz ); |
3674 |
} |
3682 |
} |
3675 |
} |
3683 |
} |
3676 |
if ( C4::Context->preference('useDaysMode') ne 'Days' ) { |
3684 |
if ( $useDaysMode_value ne 'Days' ) { |
3677 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
3685 |
my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value ); |
3678 |
if ( $calendar->is_holiday($datedue) ) { |
3686 |
if ( $calendar->is_holiday($datedue) ) { |
3679 |
# Don't return on a closed day |
3687 |
# Don't return on a closed day |
3680 |
$datedue = $calendar->prev_open_days( $datedue, 1 ); |
3688 |
$datedue = $calendar->prev_open_days( $datedue, 1 ); |