Lines 3438-3449
sub CalcDateDue {
Link Here
|
3438 |
->truncate( to => 'minute' ); |
3438 |
->truncate( to => 'minute' ); |
3439 |
} |
3439 |
} |
3440 |
|
3440 |
|
3441 |
|
3441 |
my $calendar = Koha::DiscreteCalendar->new( branchcode => $branch ); |
3442 |
# calculate the datedue as normal |
3442 |
# calculate the datedue as normal |
3443 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3443 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3444 |
{ # ignoring calendar |
3444 |
{ # ignoring calendar |
3445 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3445 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3446 |
$datedue->add( hours => $loanlength->{$length_key} ); |
3446 |
$datedue->add( hours => $loanlength->{$length_key} ); |
|
|
3447 |
} elsif ( $loanlength->{lengthunit} eq 'minutes' ) { |
3448 |
$datedue->add( minutes => $loanlength->{$length_key}); |
3447 |
} else { # days |
3449 |
} else { # days |
3448 |
$datedue->add( days => $loanlength->{$length_key} ); |
3450 |
$datedue->add( days => $loanlength->{$length_key} ); |
3449 |
$datedue->set_hour(23); |
3451 |
$datedue->set_hour(23); |
Lines 3454-3463
sub CalcDateDue {
Link Here
|
3454 |
if ($loanlength->{lengthunit} eq 'hours') { |
3456 |
if ($loanlength->{lengthunit} eq 'hours') { |
3455 |
$dur = DateTime::Duration->new( hours => $loanlength->{$length_key}); |
3457 |
$dur = DateTime::Duration->new( hours => $loanlength->{$length_key}); |
3456 |
} |
3458 |
} |
|
|
3459 |
elsif ($loanlength->{lengthunit} eq 'minutes') { |
3460 |
$dur = DateTime::Duration->new( minutes => $loanlength->{$length_key}); |
3461 |
} |
3457 |
else { # days |
3462 |
else { # days |
3458 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3463 |
$dur = DateTime::Duration->new( days => $loanlength->{$length_key}); |
3459 |
} |
3464 |
} |
3460 |
my $calendar = Koha::DiscreteCalendar->new({ branchcode => $branch }); |
|
|
3461 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3465 |
$datedue = $calendar->addDate( $datedue, $dur, $loanlength->{lengthunit} ); |
3462 |
if ($loanlength->{lengthunit} eq 'days') { |
3466 |
if ($loanlength->{lengthunit} eq 'days') { |
3463 |
$datedue->set_hour(23); |
3467 |
$datedue->set_hour(23); |
Lines 3503-3508
sub CalcDateDue {
Link Here
|
3503 |
} |
3507 |
} |
3504 |
} |
3508 |
} |
3505 |
} |
3509 |
} |
|
|
3510 |
|
3511 |
#check if it's minutes or hourly loan and set due date to close hour, if the current due date is passed closing hours. |
3512 |
if ($loanlength->{lengthunit} eq 'hours' || $loanlength->{lengthunit} eq 'minutes'){ |
3513 |
my $dateInfo = $calendar->get_date_info($datedue); |
3514 |
my $close = dt_from_string($dateInfo->{date} ." ". $dateInfo->{closehour}, 'iso', C4::Context->tz()); |
3515 |
|
3516 |
my $close_datetime = $datedue->clone()->set(hour => $close->hour(), minute=> $close->minute()); |
3517 |
|
3518 |
if(DateTime->compare($datedue, $close_datetime) > 0) { |
3519 |
$datedue = $close_datetime->clone(); |
3520 |
} |
3521 |
} |
3522 |
|
3506 |
return $datedue; |
3523 |
return $datedue; |
3507 |
} |
3524 |
} |
3508 |
|
3525 |
|