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