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

(-)a/C4/Reserves.pm (-8 / +8 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 740-745 sub GetLastPickupDate { Link Here
740
    } else {
736
    } else {
741
        $reservebranch = $reserve->branchcode;
737
        $reservebranch = $reserve->branchcode;
742
    }
738
    }
739
743
    if ( defined($issuingrule) && defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0 ) { #If holdspickupwait is <= 0, it means this feature is disabled for this type of material.
740
    if ( defined($issuingrule) && defined $issuingrule->holdspickupwait && $issuingrule->holdspickupwait > 0 ) { #If holdspickupwait is <= 0, it means this feature is disabled for this type of material.
744
        $date->add( days => $issuingrule->holdspickupwait );
741
        $date->add( days => $issuingrule->holdspickupwait );
745
        my $calendar = Koha::Calendar->new( branchcode => $reservebranch );
742
        my $calendar = Koha::Calendar->new( branchcode => $reservebranch );
Lines 748-753 sub GetLastPickupDate { Link Here
748
               $date->add( days => 1 );
745
               $date->add( days => 1 );
749
               $is_holiday = $calendar->is_holiday( $date );
746
               $is_holiday = $calendar->is_holiday( $date );
750
        }
747
        }
748
749
        if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) {
750
              $date = $calendar->days_forward( dt_from_string(), $issuingrule->holdspickupwait );
751
        }
752
751
        $reserve->{lastpickupdate} = $date->ymd();
753
        $reserve->{lastpickupdate} = $date->ymd();
752
        return $date;
754
        return $date;
753
     }
755
     }
Lines 920-926 sub CheckReserves { Link Here
920
922
921
  CancelExpiredReserves();
923
  CancelExpiredReserves();
922
924
923
Cancels all reserves with an expiration date from before today.
925
Cancels all reserves with a lastpickupdate value from before today.
924
926
925
=cut
927
=cut
926
928
Lines 928-941 sub CancelExpiredReserves { Link Here
928
    my $today = dt_from_string();
930
    my $today = dt_from_string();
929
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
931
    my $cancel_on_holidays = C4::Context->preference('ExpireReservesOnHolidays');
930
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
932
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
931
932
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
933
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
933
    my $params = { expirationdate => { '<', $dtf->format_date($today) } };
934
    my $params = { lastpickupdate => { '<', $dtf->format_date($today) } };
934
    $params->{found} = [ { '!=', 'W' }, undef ]  unless $expireWaiting;
935
    $params->{found} = [ { '!=', 'W' }, undef ]  unless $expireWaiting;
935
936
936
    # FIXME To move to Koha::Holds->search_expired (?)
937
    # FIXME To move to Koha::Holds->search_expired (?)
937
    my $holds = Koha::Holds->search( $params );
938
    my $holds = Koha::Holds->search( $params );
938
939
    while ( my $hold = $holds->next ) {
939
    while ( my $hold = $holds->next ) {
940
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
940
        my $calendar = Koha::Calendar->new( branchcode => $hold->branchcode );
941
941
(-)a/Koha/Hold.pm (-7 / +14 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-218 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
        $expirationdate = $calendar->days_forward( dt_from_string(), $issuingrule->{holdspickupwait} );
223
        $expirationdate = $calendar->days_forward( dt_from_string(), $issuingrule->holdspickupwait );
216
    }
224
    }
217
225
218
    # If patron's requested expiration date is prior to the
226
    # If patron's requested expiration date is prior to the
219
- 

Return to bug 8367