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

(-)a/C4/Reserves.pm (-8 / +2 lines)
Lines 765-774 sub GetLastPickupDate { Link Here
765
    } elsif ( $controlbranch eq "PatronLibrary" ) {
765
    } elsif ( $controlbranch eq "PatronLibrary" ) {
766
         $branchcode = $borrower->branchcode;
766
         $branchcode = $borrower->branchcode;
767
    }
767
    }
768
    warn 'getlastpickup';
769
    warn $branchcode;
770
    warn $borrower->{'categorycode'};
771
    warn $item->{itype};
772
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
768
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
773
            branchcode   => $branchcode,
769
            branchcode   => $branchcode,
774
            categorycode => $borrower->{'categorycode'},
770
            categorycode => $borrower->{'categorycode'},
Lines 961-967 sub CheckReserves { Link Here
961
957
962
  CancelExpiredReserves();
958
  CancelExpiredReserves();
963
959
964
Cancels all reserves with an expiration date from before today.
960
Cancels all reserves with an lastpickupdate value from before today.
965
961
966
=cut
962
=cut
967
963
Lines 969-982 sub CancelExpiredReserves { Link Here
969
    my $today = dt_from_string();
965
    my $today = dt_from_string();
970
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
966
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
971
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
967
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
972
973
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
968
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
974
    my $params = { expirationdate => { '<', $dtf->format_date($today) } };
969
    my $params = { lastpickupdate => { '<', $dtf->format_date($today) } };
975
    $params->{found} = undef unless $expireWaiting;
970
    $params->{found} = undef unless $expireWaiting;
976
971
977
    # FIXME To move to Koha::Holds->search_expired (?)
972
    # FIXME To move to Koha::Holds->search_expired (?)
978
    my $holds = Koha::Holds->search( $params );
973
    my $holds = Koha::Holds->search( $params );
979
980
    while ( my $hold = $holds->next ) {
974
    while ( my $hold = $holds->next ) {
981
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
975
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
982
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
976
        next if !$cancel_on_holidays && $calendar->is_holiday( $today );
(-)a/Koha/Hold.pm (-9 / +14 lines)
Lines 163-169 sub set_waiting { Link Here
163
        $requested_expiration = dt_from_string($self->expirationdate);
163
        $requested_expiration = dt_from_string($self->expirationdate);
164
    }
164
    }
165
165
166
    my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
167
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
166
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
168
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
167
    my $calendar = Koha::Calendar->new( branchcode => $self->branchcode );
169
168
Lines 172-178 sub set_waiting { Link Here
172
    my $patron = Koha::Patrons->find( {borrowernumber => $self->borrowernumber} );
171
    my $patron = Koha::Patrons->find( {borrowernumber => $self->borrowernumber} );
173
    my $item = Koha::Items->find( $self->itemnumber() );
172
    my $item = Koha::Items->find( $self->itemnumber() );
174
    my $hold = Koha::Holds->find( $self->reserve_id );
173
    my $hold = Koha::Holds->find( $self->reserve_id );
175
#    my $lastpickupdate = C4::Reserves->GetLastPickupDate( $hold, $item, $patron);
176
174
177
    # Get the controlbranch
175
    # Get the controlbranch
178
    my $controlbranch = C4::Reserves->GetReservesControlBranch( $item, $patron );
176
    my $controlbranch = C4::Reserves->GetReservesControlBranch( $item, $patron );
Lines 184-200 sub set_waiting { Link Here
184
        $branchcode = $patron->branchcode;
182
        $branchcode = $patron->branchcode;
185
    }
183
    }
186
184
187
     warn $branchcode;
185
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
188
     warn $patron->categorycode;
189
     warn $item->itype;
190
     my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
191
             branchcode   => $branchcode,
186
             branchcode   => $branchcode,
192
             categorycode => $patron->categorycode,
187
             categorycode => $patron->categorycode,
193
             itemtype     => $item->itype,
188
             itemtype     => $item->itype,
194
     });
189
    });
195
190
196
    if ( defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0) {
191
    if ( defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0) {
197
        $expirationdate->add(days => $issuingrule->holdspickupwait);
192
         if ( defined($issuingrule) && defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0 ) { #If holdspickupwait is <=      0, it means this feature is disabled for this type of material.
193
            if ($cancel_on_holidays) {
194
                $expirationdate->add(days => $issuingrule->holdspickupwait);
195
            } else {
196
                $expirationdate->add(days => $issuingrule->holdspickupwait);
197
                my $is_holiday = $calendar->is_holiday( $expirationdate );
198
                while ( $is_holiday ) {
199
                    $expirationdate->add( days => 1 );
200
                    $is_holiday = $calendar->is_holiday( $expirationdate );
201
                }
202
            }
203
         }
198
    }
204
    }
199
205
200
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
206
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
201
- 

Return to bug 8367