Lines 185-221
sub set_waiting {
Link Here
|
185 |
desk_id => $desk_id, |
185 |
desk_id => $desk_id, |
186 |
}; |
186 |
}; |
187 |
|
187 |
|
188 |
if ( !C4::Context->preference('ReserveExpiration') ){ |
188 |
my $requested_expiration; |
189 |
$values->{expirationdate} = undef; |
189 |
if ($self->expirationdate) { |
190 |
} else { |
190 |
$requested_expiration = dt_from_string($self->expirationdate); |
191 |
my $requested_expiration; |
191 |
} |
192 |
if ($self->expirationdate) { |
|
|
193 |
$requested_expiration = dt_from_string($self->expirationdate); |
194 |
} |
195 |
|
192 |
|
196 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
193 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
197 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
194 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
198 |
|
195 |
|
199 |
my $expirationdate = $today->clone; |
196 |
my $expirationdate = $today->clone; |
200 |
$expirationdate->add(days => $max_pickup_delay); |
197 |
$expirationdate->add(days => $max_pickup_delay); |
201 |
|
198 |
|
202 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
199 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
203 |
my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; |
200 |
my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; |
204 |
my $daysmode = Koha::CirculationRules->get_effective_daysmode( |
201 |
my $daysmode = Koha::CirculationRules->get_effective_daysmode( |
205 |
{ |
202 |
{ |
206 |
categorycode => $self->borrower->categorycode, |
203 |
categorycode => $self->borrower->categorycode, |
207 |
itemtype => $itemtype, |
204 |
itemtype => $itemtype, |
208 |
branchcode => $self->branchcode, |
205 |
branchcode => $self->branchcode, |
209 |
} |
206 |
} |
210 |
); |
207 |
); |
211 |
my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); |
208 |
my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode ); |
212 |
$expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); |
209 |
$expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); |
213 |
} |
210 |
} |
214 |
|
211 |
|
|
|
212 |
if ( C4::Context->preference('ExpireReservesMaxPickUpDelay') ) { |
215 |
# If patron's requested expiration date is prior to the |
213 |
# If patron's requested expiration date is prior to the |
216 |
# calculated one, we keep the patron's one. |
214 |
# calculated one, we keep the patron's one. |
217 |
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; |
215 |
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; |
218 |
$values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; |
216 |
$values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; |
|
|
217 |
} else { |
218 |
# if holds don't need a waiting expiration date to be expired automatically, don't set one |
219 |
$values->{expirationdate} = undef; |
219 |
} |
220 |
} |
220 |
|
221 |
|
221 |
$self->set($values)->store(); |
222 |
$self->set($values)->store(); |
222 |
- |
|
|