|
Lines 289-341
sub set_waiting {
Link Here
|
| 289 |
desk_id => $desk_id, |
289 |
desk_id => $desk_id, |
| 290 |
}; |
290 |
}; |
| 291 |
|
291 |
|
| 292 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
292 |
my $new_expiration_date; |
| 293 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
|
|
| 294 |
|
293 |
|
| 295 |
my $rule = Koha::CirculationRules->get_effective_rule( |
294 |
if ( C4::Context->preference('ReserveExpiration') ) { |
| 296 |
{ |
|
|
| 297 |
categorycode => $self->borrower->categorycode, |
| 298 |
itemtype => $self->item->effective_itemtype, |
| 299 |
branchcode => $self->branchcode, |
| 300 |
rule_name => 'holds_pickup_period', |
| 301 |
} |
| 302 |
); |
| 303 |
if ( defined($rule) and $rule->rule_value ne '' ) { |
| 304 |
|
| 305 |
# circulation rule overrides ReservesMaxPickUpDelay |
| 306 |
$max_pickup_delay = $rule->rule_value; |
| 307 |
} |
| 308 |
|
295 |
|
| 309 |
my $new_expiration_date = dt_from_string( $self->waitingdate )->clone->add( days => $max_pickup_delay ); |
296 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
|
|
297 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
| 310 |
|
298 |
|
| 311 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
299 |
my $rule = Koha::CirculationRules->get_effective_rule( |
| 312 |
my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; |
|
|
| 313 |
my $daysmode = Koha::CirculationRules->get_effective_daysmode( |
| 314 |
{ |
300 |
{ |
| 315 |
categorycode => $self->borrower->categorycode, |
301 |
categorycode => $self->borrower->categorycode, |
| 316 |
itemtype => $itemtype, |
302 |
itemtype => $self->item->effective_itemtype, |
| 317 |
branchcode => $self->branchcode, |
303 |
branchcode => $self->branchcode, |
|
|
304 |
rule_name => 'holds_pickup_period', |
| 318 |
} |
305 |
} |
| 319 |
); |
306 |
); |
| 320 |
my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); |
307 |
if ( defined($rule) and $rule->rule_value ne '' ) { |
| 321 |
|
308 |
|
| 322 |
$new_expiration_date = $calendar->days_forward( dt_from_string( $self->waitingdate ), $max_pickup_delay ); |
309 |
# circulation rule overrides ReservesMaxPickUpDelay |
| 323 |
} |
310 |
$max_pickup_delay = $rule->rule_value; |
|
|
311 |
} |
| 324 |
|
312 |
|
| 325 |
# If patron's requested expiration date is prior to the |
313 |
$new_expiration_date = dt_from_string( $self->waitingdate )->clone->add( days => $max_pickup_delay ); |
| 326 |
# calculated one, we keep the patron's one. |
|
|
| 327 |
if ( $self->patron_expiration_date ) { |
| 328 |
my $requested_expiration = dt_from_string( $self->patron_expiration_date ); |
| 329 |
|
314 |
|
| 330 |
my $cmp = |
315 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
| 331 |
$requested_expiration |
316 |
my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; |
| 332 |
? DateTime->compare( $requested_expiration, $new_expiration_date ) |
317 |
my $daysmode = Koha::CirculationRules->get_effective_daysmode( |
| 333 |
: 0; |
318 |
{ |
|
|
319 |
categorycode => $self->borrower->categorycode, |
| 320 |
itemtype => $itemtype, |
| 321 |
branchcode => $self->branchcode, |
| 322 |
} |
| 323 |
); |
| 324 |
my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); |
| 334 |
|
325 |
|
| 335 |
$new_expiration_date = $cmp == -1 ? $requested_expiration : $new_expiration_date; |
326 |
$new_expiration_date = $calendar->days_forward( dt_from_string( $self->waitingdate ), $max_pickup_delay ); |
| 336 |
} |
327 |
} |
|
|
328 |
|
| 329 |
# If patron's requested expiration date is prior to the |
| 330 |
# calculated one, we keep the patron's one. |
| 331 |
if ( $self->patron_expiration_date ) { |
| 332 |
my $requested_expiration = dt_from_string( $self->patron_expiration_date ); |
| 333 |
|
| 334 |
my $cmp = |
| 335 |
$requested_expiration |
| 336 |
? DateTime->compare( $requested_expiration, $new_expiration_date ) |
| 337 |
: 0; |
| 338 |
|
| 339 |
$new_expiration_date = $cmp == -1 ? $requested_expiration : $new_expiration_date; |
| 340 |
} |
| 341 |
|
| 342 |
} # ReserveExpiration |
| 337 |
|
343 |
|
| 338 |
$values->{expirationdate} = $new_expiration_date->ymd; |
344 |
$values->{expirationdate} = $new_expiration_date ? $new_expiration_date->ymd : undef; |
| 339 |
|
345 |
|
| 340 |
$self->set($values)->store(); |
346 |
$self->set($values)->store(); |
| 341 |
|
347 |
|
|
Lines 1010-1016
sub revert_found {
Link Here
|
| 1010 |
priority => 1, |
1016 |
priority => 1, |
| 1011 |
found => undef, |
1017 |
found => undef, |
| 1012 |
waitingdate => undef, |
1018 |
waitingdate => undef, |
| 1013 |
expirationdate => $self->patron_expiration_date, |
1019 |
expirationdate => undef, |
| 1014 |
itemnumber => $self->item_level_hold ? $self->itemnumber : undef, |
1020 |
itemnumber => $self->item_level_hold ? $self->itemnumber : undef, |
| 1015 |
( $self->is_waiting ? ( desk_id => undef ) : () ), |
1021 |
( $self->is_waiting ? ( desk_id => undef ) : () ), |
| 1016 |
} |
1022 |
} |