Lines 3487-3498
sub CalcDateDue {
Link Here
|
3487 |
->truncate( to => 'minute' ); |
3487 |
->truncate( to => 'minute' ); |
3488 |
} |
3488 |
} |
3489 |
|
3489 |
|
3490 |
|
3490 |
my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); |
3491 |
# calculate the datedue as normal |
3491 |
# calculate the datedue as normal |
3492 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3492 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3493 |
{ # ignoring calendar |
3493 |
{ # ignoring calendar |
3494 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3494 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3495 |
$datedue->add( hours => $loanlength->{$length_key} ); |
3495 |
$datedue->add( hours => $loanlength->{$length_key} ); |
|
|
3496 |
}elsif ($loanlength->{lengthunit} eq 'minutes') { |
3497 |
$datedue->add( minutes => $loanlength->{$length_key}); |
3496 |
} else { # days |
3498 |
} else { # days |
3497 |
$datedue->add( days => $loanlength->{$length_key} ); |
3499 |
$datedue->add( days => $loanlength->{$length_key} ); |
3498 |
$datedue->set_hour(23); |
3500 |
$datedue->set_hour(23); |
Lines 3502-3512
sub CalcDateDue {
Link Here
|
3502 |
my $dur; |
3504 |
my $dur; |
3503 |
if ($loanlength->{lengthunit} eq 'hours') { |
3505 |
if ($loanlength->{lengthunit} eq 'hours') { |
3504 |
$dur = DateTime::Duration->new( hours => $loanlength->{$length_key}); |
3506 |
$dur = DateTime::Duration->new( hours => $loanlength->{$length_key}); |
3505 |
} |
3507 |
}elsif ($loanlength->{lengthunit} eq 'minutes') { |
3506 |
else { # days |
3508 |
$dur = DateTime::Duration->new( minutes => $loanlength->{$length_key}); |
|
|
3509 |
}else { # days |
3507 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3510 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3508 |
} |
3511 |
} |
3509 |
my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); |
|
|
3510 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3512 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3511 |
if ($loanlength->{lengthunit} eq 'days') { |
3513 |
if ($loanlength->{lengthunit} eq 'days') { |
3512 |
$datedue->set_hour(23); |
3514 |
$datedue->set_hour(23); |
Lines 3546-3551
sub CalcDateDue {
Link Here
|
3546 |
} |
3548 |
} |
3547 |
} |
3549 |
} |
3548 |
|
3550 |
|
|
|
3551 |
#check if it's minutes or hourly loan and set due date to close hour, if the current due date is passed closing hours. |
3552 |
if ($loanlength->{lengthunit} eq 'hours' || $loanlength->{lengthunit} eq 'minutes'){ |
3553 |
my $dateInfo = $calendar->get_date_info($datedue); |
3554 |
my $close = dt_from_string($dateInfo->{date} ." ". $dateInfo->{closehour}, 'iso', C4::Context->tz()); |
3555 |
|
3556 |
my $close_datetime = $datedue->clone()->set(hour => $close->hour(), minute=> $close->minute()); |
3557 |
|
3558 |
if(DateTime->compare($datedue, $close_datetime) > 0) { |
3559 |
$datedue = $close_datetime->clone(); |
3560 |
} |
3561 |
} |
3562 |
|
3549 |
return $datedue; |
3563 |
return $datedue; |
3550 |
} |
3564 |
} |
3551 |
|
3565 |
|