|
Lines 129-154
sub set_waiting {
Link Here
|
| 129 |
waitingdate => $today->ymd, |
129 |
waitingdate => $today->ymd, |
| 130 |
}; |
130 |
}; |
| 131 |
|
131 |
|
| 132 |
my $requested_expiration; |
132 |
if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) { |
| 133 |
if ($self->expirationdate) { |
|
|
| 134 |
$requested_expiration = dt_from_string($self->expirationdate); |
| 135 |
} |
| 136 |
|
133 |
|
| 137 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
134 |
my $requested_expiration; |
| 138 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
135 |
if ($self->expirationdate) { |
| 139 |
my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); |
136 |
$requested_expiration = dt_from_string($self->expirationdate); |
|
|
137 |
} |
| 140 |
|
138 |
|
| 141 |
my $expirationdate = $today->clone; |
139 |
my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay"); |
| 142 |
$expirationdate->add(days => $max_pickup_delay); |
140 |
my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays'); |
|
|
141 |
my $calendar = Koha::Calendar->new( branchcode => $self->branchcode ); |
| 143 |
|
142 |
|
| 144 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
143 |
my $expirationdate = $today->clone; |
| 145 |
$expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); |
144 |
$expirationdate->add(days => $max_pickup_delay); |
| 146 |
} |
|
|
| 147 |
|
145 |
|
| 148 |
# If patron's requested expiration date is prior to the |
146 |
if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { |
| 149 |
# calculated one, we keep the patron's one. |
147 |
$expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay ); |
| 150 |
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; |
148 |
} |
| 151 |
$values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; |
149 |
|
|
|
150 |
# If patron's requested expiration date is prior to the |
| 151 |
# calculated one, we keep the patron's one. |
| 152 |
my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0; |
| 153 |
$values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd; |
| 154 |
|
| 155 |
} |
| 152 |
|
156 |
|
| 153 |
$self->set($values)->store(); |
157 |
$self->set($values)->store(); |
| 154 |
|
158 |
|
| 155 |
- |
|
|