|
Lines 371-423
sub set_waiting {
Link Here
|
| 371 |
desk_id => $desk_id, |
371 |
desk_id => $desk_id, |
| 372 |
}; |
372 |
}; |
| 373 |
|
373 |
|
| 374 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
374 |
my $new_expiration_date; |
| 375 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
|
|
| 376 |
|
375 |
|
| 377 |
my $rule = Koha::CirculationRules->get_effective_rule( |
376 |
if ( C4::Context->preference('ReserveExpiration') ) { |
| 378 |
{ |
|
|
| 379 |
categorycode => $self->borrower->categorycode, |
| 380 |
itemtype => $self->item->effective_itemtype, |
| 381 |
branchcode => $self->branchcode, |
| 382 |
rule_name => 'holds_pickup_period', |
| 383 |
} |
| 384 |
); |
| 385 |
if ( defined($rule) and $rule->rule_value ne '' ) { |
| 386 |
|
| 387 |
# circulation rule overrides ReservesMaxPickUpDelay |
| 388 |
$max_pickup_delay = $rule->rule_value; |
| 389 |
} |
| 390 |
|
377 |
|
| 391 |
my $new_expiration_date = dt_from_string( $self->waitingdate )->clone->add( days => $max_pickup_delay ); |
378 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
|
|
379 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
| 392 |
|
380 |
|
| 393 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
381 |
my $rule = Koha::CirculationRules->get_effective_rule( |
| 394 |
my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; |
|
|
| 395 |
my $daysmode = Koha::CirculationRules->get_effective_daysmode( |
| 396 |
{ |
382 |
{ |
| 397 |
categorycode => $self->borrower->categorycode, |
383 |
categorycode => $self->borrower->categorycode, |
| 398 |
itemtype => $itemtype, |
384 |
itemtype => $self->item->effective_itemtype, |
| 399 |
branchcode => $self->branchcode, |
385 |
branchcode => $self->branchcode, |
|
|
386 |
rule_name => 'holds_pickup_period', |
| 400 |
} |
387 |
} |
| 401 |
); |
388 |
); |
| 402 |
my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); |
389 |
if ( defined($rule) and $rule->rule_value ne '' ) { |
| 403 |
|
390 |
|
| 404 |
$new_expiration_date = $calendar->days_forward( dt_from_string( $self->waitingdate ), $max_pickup_delay ); |
391 |
# circulation rule overrides ReservesMaxPickUpDelay |
| 405 |
} |
392 |
$max_pickup_delay = $rule->rule_value; |
|
|
393 |
} |
| 406 |
|
394 |
|
| 407 |
# If patron's requested expiration date is prior to the |
395 |
$new_expiration_date = dt_from_string( $self->waitingdate )->clone->add( days => $max_pickup_delay ); |
| 408 |
# calculated one, we keep the patron's one. |
|
|
| 409 |
if ( $self->patron_expiration_date ) { |
| 410 |
my $requested_expiration = dt_from_string( $self->patron_expiration_date ); |
| 411 |
|
396 |
|
| 412 |
my $cmp = |
397 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
| 413 |
$requested_expiration |
398 |
my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; |
| 414 |
? DateTime->compare( $requested_expiration, $new_expiration_date ) |
399 |
my $daysmode = Koha::CirculationRules->get_effective_daysmode( |
| 415 |
: 0; |
400 |
{ |
|
|
401 |
categorycode => $self->borrower->categorycode, |
| 402 |
itemtype => $itemtype, |
| 403 |
branchcode => $self->branchcode, |
| 404 |
} |
| 405 |
); |
| 406 |
my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); |
| 416 |
|
407 |
|
| 417 |
$new_expiration_date = $cmp == -1 ? $requested_expiration : $new_expiration_date; |
408 |
$new_expiration_date = $calendar->days_forward( dt_from_string( $self->waitingdate ), $max_pickup_delay ); |
| 418 |
} |
409 |
} |
|
|
410 |
|
| 411 |
# If patron's requested expiration date is prior to the |
| 412 |
# calculated one, we keep the patron's one. |
| 413 |
if ( $self->patron_expiration_date ) { |
| 414 |
my $requested_expiration = dt_from_string( $self->patron_expiration_date ); |
| 415 |
|
| 416 |
my $cmp = |
| 417 |
$requested_expiration |
| 418 |
? DateTime->compare( $requested_expiration, $new_expiration_date ) |
| 419 |
: 0; |
| 420 |
|
| 421 |
$new_expiration_date = $cmp == -1 ? $requested_expiration : $new_expiration_date; |
| 422 |
} |
| 423 |
|
| 424 |
} # ReserveExpiration |
| 419 |
|
425 |
|
| 420 |
$values->{expirationdate} = $new_expiration_date->ymd; |
426 |
$values->{expirationdate} = $new_expiration_date ? $new_expiration_date->ymd : undef; |
| 421 |
|
427 |
|
| 422 |
$self->set($values)->store(); |
428 |
$self->set($values)->store(); |
| 423 |
|
429 |
|
|
Lines 1109-1115
sub revert_found {
Link Here
|
| 1109 |
priority => 1, |
1115 |
priority => 1, |
| 1110 |
found => undef, |
1116 |
found => undef, |
| 1111 |
waitingdate => undef, |
1117 |
waitingdate => undef, |
| 1112 |
expirationdate => $self->patron_expiration_date, |
1118 |
expirationdate => undef, |
| 1113 |
itemnumber => $self->item_level_hold ? $self->itemnumber : undef, |
1119 |
itemnumber => $self->item_level_hold ? $self->itemnumber : undef, |
| 1114 |
( $self->is_waiting ? ( desk_id => undef ) : () ), |
1120 |
( $self->is_waiting ? ( desk_id => undef ) : () ), |
| 1115 |
} |
1121 |
} |