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

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