Lines 3566-3572
sub UpdateHoldingbranch {
Link Here
|
3566 |
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); |
3566 |
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); |
3567 |
|
3567 |
|
3568 |
this function calculates the due date given the start date and configured circulation rules, |
3568 |
this function calculates the due date given the start date and configured circulation rules, |
3569 |
checking against the holidays calendar as per the 'useDaysMode' syspref. |
3569 |
checking against the holidays calendar as per the useDaysMode circulation rule. |
3570 |
C<$startdate> = DateTime object representing start date of loan period (assumed to be today) |
3570 |
C<$startdate> = DateTime object representing start date of loan period (assumed to be today) |
3571 |
C<$itemtype> = itemtype code of item in question |
3571 |
C<$itemtype> = itemtype code of item in question |
3572 |
C<$branch> = location whose calendar to use |
3572 |
C<$branch> = location whose calendar to use |
Lines 3602-3609
sub CalcDateDue {
Link Here
|
3602 |
} |
3602 |
} |
3603 |
|
3603 |
|
3604 |
|
3604 |
|
|
|
3605 |
my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( |
3606 |
{ |
3607 |
categorycode => $borrower->{categorycode}, |
3608 |
itemtype => $itemtype, |
3609 |
branchcode => $branch, |
3610 |
} |
3611 |
); |
3612 |
|
3605 |
# calculate the datedue as normal |
3613 |
# calculate the datedue as normal |
3606 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3614 |
if ( $useDaysMode_value eq 'Days' ) |
3607 |
{ # ignoring calendar |
3615 |
{ # ignoring calendar |
3608 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3616 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3609 |
$datedue->add( hours => $loanlength->{$length_key} ); |
3617 |
$datedue->add( hours => $loanlength->{$length_key} ); |
Lines 3620-3626
sub CalcDateDue {
Link Here
|
3620 |
else { # days |
3628 |
else { # days |
3621 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3629 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3622 |
} |
3630 |
} |
3623 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
3631 |
my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value ); |
3624 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3632 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3625 |
if ($loanlength->{lengthunit} eq 'days') { |
3633 |
if ($loanlength->{lengthunit} eq 'days') { |
3626 |
$datedue->set_hour(23); |
3634 |
$datedue->set_hour(23); |
Lines 3658-3665
sub CalcDateDue {
Link Here
|
3658 |
$datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz ); |
3666 |
$datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz ); |
3659 |
} |
3667 |
} |
3660 |
} |
3668 |
} |
3661 |
if ( C4::Context->preference('useDaysMode') ne 'Days' ) { |
3669 |
if ( $useDaysMode_value ne 'Days' ) { |
3662 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
3670 |
my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value ); |
3663 |
if ( $calendar->is_holiday($datedue) ) { |
3671 |
if ( $calendar->is_holiday($datedue) ) { |
3664 |
# Don't return on a closed day |
3672 |
# Don't return on a closed day |
3665 |
$datedue = $calendar->prev_open_days( $datedue, 1 ); |
3673 |
$datedue = $calendar->prev_open_days( $datedue, 1 ); |