View | Details | Raw Unified | Return to bug 21729
Collapse All | Expand All

(-)a/C4/Reserves.pm (-4 / +11 lines)
Lines 185-191 sub AddReserve { Link Here
185
    my $biblionumber   = $params->{biblionumber};
185
    my $biblionumber   = $params->{biblionumber};
186
    my $priority       = $params->{priority};
186
    my $priority       = $params->{priority};
187
    my $resdate        = $params->{reservation_date};
187
    my $resdate        = $params->{reservation_date};
188
    my $expdate        = $params->{expiration_date};
188
    my $patron_expiration_date = $params->{expiration_date};
189
    my $notes          = $params->{notes};
189
    my $notes          = $params->{notes};
190
    my $title          = $params->{title};
190
    my $title          = $params->{title};
191
    my $checkitem      = $params->{itemnumber};
191
    my $checkitem      = $params->{itemnumber};
Lines 196-202 sub AddReserve { Link Here
196
    $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
196
    $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
197
        or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
197
        or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
198
198
199
    $expdate = output_pref({ str => $expdate, dateonly => 1, dateformat => 'iso' });
199
    $patron_expiration_date = output_pref({ str => $patron_expiration_date, dateonly => 1, dateformat => 'iso' });
200
200
201
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
201
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
202
    # of the document, we force the value $priority and $found .
202
    # of the document, we force the value $priority and $found .
Lines 252-258 sub AddReserve { Link Here
252
            itemnumber     => $checkitem,
252
            itemnumber     => $checkitem,
253
            found          => $found,
253
            found          => $found,
254
            waitingdate    => $waitingdate,
254
            waitingdate    => $waitingdate,
255
            expirationdate => $expdate,
255
            patron_expiration_date => $patron_expiration_date,
256
            itemtype       => $itemtype,
256
            itemtype       => $itemtype,
257
            item_level_hold => $checkitem ? 1 : 0,
257
            item_level_hold => $checkitem ? 1 : 0,
258
            non_priority   => $non_priority ? 1 : 0,
258
            non_priority   => $non_priority ? 1 : 0,
Lines 946-952 sub CancelExpiredReserves { Link Here
946
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
946
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
947
947
948
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
948
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
949
    my $params = { expirationdate => { '<', $dtf->format_date($today) } };
949
    my $params = {
950
        -or => [
951
            { expirationdate => { '<', $dtf->format_date($today) } },
952
            { patron_expiration_date => { '<' => $dtf->format_date($today) } }
953
        ]
954
    };
955
950
    $params->{found} = [ { '!=', 'W' }, undef ]  unless $expireWaiting;
956
    $params->{found} = [ { '!=', 'W' }, undef ]  unless $expireWaiting;
951
957
952
    # FIXME To move to Koha::Holds->search_expired (?)
958
    # FIXME To move to Koha::Holds->search_expired (?)
Lines 2099-2104 sub RevertWaitingStatus { Link Here
2099
            priority    => 1,
2105
            priority    => 1,
2100
            found       => undef,
2106
            found       => undef,
2101
            waitingdate => undef,
2107
            waitingdate => undef,
2108
            expirationdate => $hold->patron_expiration_date,
2102
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2109
            itemnumber  => $hold->item_level_hold ? $hold->itemnumber : undef,
2103
        }
2110
        }
2104
    )->store();
2111
    )->store();
(-)a/Koha/Hold.pm (-10 / +19 lines)
Lines 185-200 sub set_waiting { Link Here
185
        desk_id => $desk_id,
185
        desk_id => $desk_id,
186
    };
186
    };
187
187
188
    my $requested_expiration;
189
    if ($self->expirationdate) {
190
        $requested_expiration = dt_from_string($self->expirationdate);
191
    }
192
193
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
188
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
194
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
189
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
195
190
196
    my $expirationdate = $today->clone;
191
    my $new_expiration_date = $today->clone->add(days => $max_pickup_delay);
197
    $expirationdate->add(days => $max_pickup_delay);
198
192
199
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
193
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
200
        my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
194
        my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype;
Lines 207-219 sub set_waiting { Link Here
207
        );
201
        );
208
        my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
202
        my $calendar = Koha::Calendar->new( branchcode => $self->branchcode, days_mode => $daysmode );
209
203
210
        $expirationdate = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
204
        $new_expiration_date = $calendar->days_forward( dt_from_string(), $max_pickup_delay );
211
    }
205
    }
212
206
213
    # If patron's requested expiration date is prior to the
207
    # If patron's requested expiration date is prior to the
214
    # calculated one, we keep the patron's one.
208
    # calculated one, we keep the patron's one.
215
    my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
209
    if ( $self->patron_expiration_date ) {
216
    $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd;
210
        my $requested_expiration = dt_from_string( $self->patron_expiration_date );
211
212
        my $cmp =
213
          $requested_expiration
214
          ? DateTime->compare( $requested_expiration, $new_expiration_date )
215
          : 0;
216
217
        $new_expiration_date =
218
          $cmp == -1 ? $requested_expiration : $new_expiration_date;
219
    }
220
221
    $values->{expirationdate} = $new_expiration_date->ymd;
217
222
218
    $self->set($values)->store();
223
    $self->set($values)->store();
219
224
Lines 585-590 sub store { Link Here
585
    my ($self) = @_;
590
    my ($self) = @_;
586
591
587
    if ( !$self->in_storage ) {
592
    if ( !$self->in_storage ) {
593
        if ( ! $self->expirationdate && $self->patron_expiration_date ) {
594
            $self->expirationdate($self->patron_expiration_date);
595
        }
596
588
        if (
597
        if (
589
            C4::Context->preference('DefaultHoldExpirationdate')
598
            C4::Context->preference('DefaultHoldExpirationdate')
590
            and ( not defined $self->expirationdate
599
            and ( not defined $self->expirationdate
(-)a/opac/opac-reserve.pl (-3 / +2 lines)
Lines 273-279 if ( $query->param('place_reserve') ) { Link Here
273
            $startdate = $query->param("reserve_date_$biblioNum");
273
            $startdate = $query->param("reserve_date_$biblioNum");
274
        }
274
        }
275
275
276
        my $expiration_date = $query->param("expiration_date_$biblioNum");
276
        my $patron_expiration_date = $query->param("expiration_date_$biblioNum");
277
277
278
        my $rank = $biblioData->{rank};
278
        my $rank = $biblioData->{rank};
279
        if ( $itemNum ne '' ) {
279
        if ( $itemNum ne '' ) {
Lines 314-320 if ( $query->param('place_reserve') ) { Link Here
314
                    biblionumber     => $biblioNum,
314
                    biblionumber     => $biblioNum,
315
                    priority         => $rank,
315
                    priority         => $rank,
316
                    reservation_date => $startdate,
316
                    reservation_date => $startdate,
317
                    expiration_date  => $expiration_date,
317
                    expiration_date  => $patron_expiration_date,
318
                    notes            => $notes,
318
                    notes            => $notes,
319
                    title            => $biblioData->{title},
319
                    title            => $biblioData->{title},
320
                    itemnumber       => $itemNum,
320
                    itemnumber       => $itemNum,
321
- 

Return to bug 21729