Lines 3455-3466
sub CalcDateDue {
Link Here
|
3455 |
->truncate( to => 'minute' ); |
3455 |
->truncate( to => 'minute' ); |
3456 |
} |
3456 |
} |
3457 |
|
3457 |
|
3458 |
|
3458 |
my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); |
3459 |
# calculate the datedue as normal |
3459 |
# calculate the datedue as normal |
3460 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3460 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3461 |
{ # ignoring calendar |
3461 |
{ # ignoring calendar |
3462 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3462 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3463 |
$datedue->add( hours => $loanlength->{$length_key} ); |
3463 |
$datedue->add( hours => $loanlength->{$length_key} ); |
|
|
3464 |
}elsif ($loanlength->{lengthunit} eq 'minutes') { |
3465 |
$datedue->add( minutes => $loanlength->{$length_key}); |
3464 |
} else { # days |
3466 |
} else { # days |
3465 |
$datedue->add( days => $loanlength->{$length_key} ); |
3467 |
$datedue->add( days => $loanlength->{$length_key} ); |
3466 |
$datedue->set_hour(23); |
3468 |
$datedue->set_hour(23); |
Lines 3470-3480
sub CalcDateDue {
Link Here
|
3470 |
my $dur; |
3472 |
my $dur; |
3471 |
if ($loanlength->{lengthunit} eq 'hours') { |
3473 |
if ($loanlength->{lengthunit} eq 'hours') { |
3472 |
$dur = DateTime::Duration->new( hours => $loanlength->{$length_key}); |
3474 |
$dur = DateTime::Duration->new( hours => $loanlength->{$length_key}); |
3473 |
} |
3475 |
}elsif ($loanlength->{lengthunit} eq 'minutes') { |
3474 |
else { # days |
3476 |
$dur = DateTime::Duration->new( minutes => $loanlength->{$length_key}); |
|
|
3477 |
}else { # days |
3475 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3478 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3476 |
} |
3479 |
} |
3477 |
my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); |
|
|
3478 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3480 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3479 |
if ($loanlength->{lengthunit} eq 'days') { |
3481 |
if ($loanlength->{lengthunit} eq 'days') { |
3480 |
$datedue->set_hour(23); |
3482 |
$datedue->set_hour(23); |
Lines 3521-3526
sub CalcDateDue {
Link Here
|
3521 |
} |
3523 |
} |
3522 |
} |
3524 |
} |
3523 |
|
3525 |
|
|
|
3526 |
#check if it's minutes or hourly loan and set due date to close hour, if the current due date is passed closing hours. |
3527 |
if ($loanlength->{lengthunit} eq 'hours' || $loanlength->{lengthunit} eq 'minutes'){ |
3528 |
my $dateInfo = $calendar->get_date_info($datedue); |
3529 |
my $close = dt_from_string($dateInfo->{date} ." ". $dateInfo->{closehour}, 'iso', C4::Context->tz()); |
3530 |
|
3531 |
my $close_datetime = $datedue->clone()->set(hour => $close->hour(), minute=> $close->minute()); |
3532 |
|
3533 |
if(DateTime->compare($datedue, $close_datetime) > 0) { |
3534 |
$datedue = $close_datetime->clone(); |
3535 |
} |
3536 |
} |
3537 |
|
3524 |
return $datedue; |
3538 |
return $datedue; |
3525 |
} |
3539 |
} |
3526 |
|
3540 |
|