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

(-)a/C4/Reserves.pm (-1 / +5 lines)
Lines 741-747 sub CheckReserves { Link Here
741
    return if ( $damaged && !C4::Context->preference('AllowHoldsOnDamagedItems') );
741
    return if ( $damaged && !C4::Context->preference('AllowHoldsOnDamagedItems') );
742
742
743
    return unless $itemnumber; # bail if we got nothing.
743
    return unless $itemnumber; # bail if we got nothing.
744
745
    # if item is not for loan it cannot be reserved either.....
744
    # if item is not for loan it cannot be reserved either.....
746
    # except where items.notforloan < 0 :  This indicates the item is holdable.
745
    # except where items.notforloan < 0 :  This indicates the item is holdable.
747
    return if  ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype;
746
    return if  ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype;
Lines 761-766 sub CheckReserves { Link Here
761
760
762
        my $priority = 10000000;
761
        my $priority = 10000000;
763
        foreach my $res (@reserves) {
762
        foreach my $res (@reserves) {
763
764
            #Before allocating to bib-level hold check if reserve respects hold rule, i.e. can patron category/item type combination allow reserves
765
            my $checkreserve = Koha::Hold->check_if_existing_hold_matches_issuingrules( $res->{'borrowernumber'}, $itemnumber );
766
            next unless ($checkreserve eq 'OK');
767
764
            if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
768
            if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
765
                if ($res->{'found'} eq 'W') {
769
                if ($res->{'found'} eq 'W') {
766
                    return ( "Waiting", $res, \@reserves ); # Found it, it is waiting
770
                    return ( "Waiting", $res, \@reserves ); # Found it, it is waiting
(-)a/Koha/Hold.pm (-1 / +40 lines)
Lines 337-342 sub is_suspended { Link Here
337
    return $self->suspend();
337
    return $self->suspend();
338
}
338
}
339
339
340
=head3 check_if_existing_hold_matches_issuingrules
341
342
my $checkreserve = Koha::Hold->check_if_existing_hold_matches_issuingrules($res->{'borrowernumber'}, $itemnumber );
343
344
Upon checking in an item of a bibliographic record with a biblio-level hold on it, check if a bib-level hold can be allocated to a patron based on the current values in the issuingrules table
345
346
=cut
347
348
sub check_if_existing_hold_matches_issuingrules {
349
    my ( $self, $borrowernumber, $itemnumber ) = @_;
350
351
    #Get patron and item objects
352
    my $patron = Koha::Patrons->find( $borrowernumber );
353
    my $item = Koha::Items->find( $itemnumber );
354
    $item = $item->unblessed();
355
356
    #Get branchcode
357
    my $branchcode;
358
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
359
360
    if ( $controlbranch eq "ItemHomeLibrary" ) {
361
         $branchcode  = $item->{homebranch};
362
    }
363
    elsif ( $controlbranch eq "PatronLibrary" ) {
364
         $branchcode  = $patron->{branchcode};
365
    }
366
367
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
368
        branchcode => $branchcode,
369
        categorycode => $patron->categorycode,
370
        itemtype => $item->{itype},
371
    });
372
373
    #Check if the patron catgeory/item type combination is valid
374
    if ( ($issuingrule->reservesallowed || $issuingrule->holds_per_record) == 0 ) {
375
        return 'InvalidHold';
376
    } else {
377
        return 'OK';
378
    }
379
}
340
380
341
=head3 cancel
381
=head3 cancel
342
382
343
- 

Return to bug 23172