Lines 3576-3582
sub updateWrongTransfer {
Link Here
|
3576 |
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); |
3576 |
$newdatedue = CalcDateDue($startdate,$itemtype,$branchcode,$borrower); |
3577 |
|
3577 |
|
3578 |
this function calculates the due date given the start date and configured circulation rules, |
3578 |
this function calculates the due date given the start date and configured circulation rules, |
3579 |
checking against the holidays calendar as per the 'useDaysMode' syspref. |
3579 |
checking against the holidays calendar as per the useDaysMode circulation rule. |
3580 |
C<$startdate> = DateTime object representing start date of loan period (assumed to be today) |
3580 |
C<$startdate> = DateTime object representing start date of loan period (assumed to be today) |
3581 |
C<$itemtype> = itemtype code of item in question |
3581 |
C<$itemtype> = itemtype code of item in question |
3582 |
C<$branch> = location whose calendar to use |
3582 |
C<$branch> = location whose calendar to use |
Lines 3610-3617
sub CalcDateDue {
Link Here
|
3610 |
} |
3610 |
} |
3611 |
|
3611 |
|
3612 |
|
3612 |
|
|
|
3613 |
my $useDaysMode_value = Koha::CirculationRules->get_useDaysMode_effective_value( |
3614 |
{ |
3615 |
categorycode => $borrower->{categorycode}, |
3616 |
itemtype => $itemtype, |
3617 |
branchcode => $branch, |
3618 |
} |
3619 |
); |
3620 |
|
3613 |
# calculate the datedue as normal |
3621 |
# calculate the datedue as normal |
3614 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3622 |
if ( $useDaysMode_value eq 'Days' ) |
3615 |
{ # ignoring calendar |
3623 |
{ # ignoring calendar |
3616 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3624 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3617 |
$datedue->add( hours => $loanlength->{$length_key} ); |
3625 |
$datedue->add( hours => $loanlength->{$length_key} ); |
Lines 3628-3634
sub CalcDateDue {
Link Here
|
3628 |
else { # days |
3636 |
else { # days |
3629 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3637 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3630 |
} |
3638 |
} |
3631 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
3639 |
my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value ); |
3632 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3640 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3633 |
if ($loanlength->{lengthunit} eq 'days') { |
3641 |
if ($loanlength->{lengthunit} eq 'days') { |
3634 |
$datedue->set_hour(23); |
3642 |
$datedue->set_hour(23); |
Lines 3666-3673
sub CalcDateDue {
Link Here
|
3666 |
$datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz ); |
3674 |
$datedue = $expiry_dt->clone->set_time_zone( C4::Context->tz ); |
3667 |
} |
3675 |
} |
3668 |
} |
3676 |
} |
3669 |
if ( C4::Context->preference('useDaysMode') ne 'Days' ) { |
3677 |
if ( $useDaysMode_value ne 'Days' ) { |
3670 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
3678 |
my $calendar = Koha::Calendar->new( branchcode => $branch, days_mode => $useDaysMode_value ); |
3671 |
if ( $calendar->is_holiday($datedue) ) { |
3679 |
if ( $calendar->is_holiday($datedue) ) { |
3672 |
# Don't return on a closed day |
3680 |
# Don't return on a closed day |
3673 |
$datedue = $calendar->prev_open_days( $datedue, 1 ); |
3681 |
$datedue = $calendar->prev_open_days( $datedue, 1 ); |