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

(-)a/C4/Reserves.pm (-8 / +2 lines)
Lines 724-733 sub GetLastPickupDate { Link Here
724
    } elsif ( $controlbranch eq "PatronLibrary" ) {
724
    } elsif ( $controlbranch eq "PatronLibrary" ) {
725
         $branchcode = $borrower->branchcode;
725
         $branchcode = $borrower->branchcode;
726
    }
726
    }
727
    warn 'getlastpickup';
728
    warn $branchcode;
729
    warn $borrower->{'categorycode'};
730
    warn $item->{itype};
731
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
727
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
732
            branchcode   => $branchcode,
728
            branchcode   => $branchcode,
733
            categorycode => $borrower->{'categorycode'},
729
            categorycode => $borrower->{'categorycode'},
Lines 920-926 sub CheckReserves { Link Here
920
916
921
  CancelExpiredReserves();
917
  CancelExpiredReserves();
922
918
923
Cancels all reserves with an expiration date from before today.
919
Cancels all reserves with a lastpickupdate value from before today.
924
920
925
=cut
921
=cut
926
922
Lines 928-941 sub CancelExpiredReserves { Link Here
928
    my $today = dt_from_string();
924
    my $today = dt_from_string();
929
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
925
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
930
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
926
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
931
932
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
927
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
933
    my $params = { expirationdate => { '<', $dtf->format_date($today) } };
928
    my $params = { lastpickupdate => { '<', $dtf->format_date($today) } };
934
    $params->{found} = [ { '!=', 'W' }, undef ]  unless $expireWaiting;
929
    $params->{found} = [ { '!=', 'W' }, undef ]  unless $expireWaiting;
935
930
936
    # FIXME To move to Koha::Holds->search_expired (?)
931
    # FIXME To move to Koha::Holds->search_expired (?)
937
    my $holds = Koha::Holds->search( $params );
932
    my $holds = Koha::Holds->search( $params );
938
939
    while ( my $hold = $holds->next ) {
933
    while ( my $hold = $holds->next ) {
940
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
934
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
941
935
(-)a/Koha/Hold.pm (-6 / +13 lines)
Lines 186-192 sub set_waiting { Link Here
186
    my $patron = Koha::Patrons->find( {borrowernumber => $self->borrowernumber} );
186
    my $patron = Koha::Patrons->find( {borrowernumber => $self->borrowernumber} );
187
    my $item = Koha::Items->find( $self->itemnumber() );
187
    my $item = Koha::Items->find( $self->itemnumber() );
188
    my $hold = Koha::Holds->find( $self->reserve_id );
188
    my $hold = Koha::Holds->find( $self->reserve_id );
189
#    my $lastpickupdate = C4::Reserves->GetLastPickupDate( $hold, $item, $patron);
190
189
191
    # Get the controlbranch
190
    # Get the controlbranch
192
    my $controlbranch = C4::Reserves->GetReservesControlBranch( $item, $patron );
191
    my $controlbranch = C4::Reserves->GetReservesControlBranch( $item, $patron );
Lines 198-206 sub set_waiting { Link Here
198
        $branchcode = $patron->branchcode;
197
        $branchcode = $patron->branchcode;
199
    }
198
    }
200
199
201
     warn $branchcode;
202
     warn $patron->categorycode;
203
     warn $item->itype;
204
     my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
200
     my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
205
             branchcode   => $branchcode,
201
             branchcode   => $branchcode,
206
             categorycode => $patron->categorycode,
202
             categorycode => $patron->categorycode,
Lines 208-214 sub set_waiting { Link Here
208
     });
204
     });
209
205
210
    if ( defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0) {
206
    if ( defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0) {
211
        $expirationdate->add(days => $issuingrule->holdspickupwait);
207
        if ( defined($issuingrule) && defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0 ) {
208
            #If holdspickupwait is <=      0, it means this feature is disabled for this type of material.
209
            if ($cancel_on_holidays) {
210
                $expirationdate->add(days => $issuingrule->holdspickupwait);
211
            } else {
212
                 $expirationdate->add(days => $issuingrule->holdspickupwait);
213
                 my $is_holiday = $calendar->is_holiday( $expirationdate );
214
                 while ( $is_holiday ) {
215
                     $expirationdate->add( days => 1 );
216
                     $is_holiday = $calendar->is_holiday( $expirationdate );
217
                 }
218
             }
219
         }
212
    }
220
    }
213
221
214
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
222
    if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
215
- 

Return to bug 8367