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

(-)a/C4/Circulation.pm (-2 / +2 lines)
Lines 25-31 use Encode; Link Here
25
25
26
use C4::Context;
26
use C4::Context;
27
use C4::Stats qw( UpdateStats );
27
use C4::Stats qw( UpdateStats );
28
use C4::Reserves qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsItemOnHoldAndFound IsAvailableForItemLevelRequest );
28
use C4::Reserves qw( CheckReserves CanItemBeReserved MoveReserve ModReserve ModReserveMinusPriority RevertWaitingStatus IsAvailableForItemLevelRequest );
29
use C4::Biblio qw( UpdateTotalIssues );
29
use C4::Biblio qw( UpdateTotalIssues );
30
use C4::Items qw( ModItemTransfer ModDateLastSeen CartToShelf );
30
use C4::Items qw( ModItemTransfer ModDateLastSeen CartToShelf );
31
use C4::Accounts;
31
use C4::Accounts;
Lines 3080-3086 sub CanBookBeRenewed { Link Here
3080
3080
3081
                foreach my $other_item (@other_items) {
3081
                foreach my $other_item (@other_items) {
3082
                  next if defined $matched_items{$other_item->itemnumber};
3082
                  next if defined $matched_items{$other_item->itemnumber};
3083
                  next if IsItemOnHoldAndFound( $other_item->itemnumber );
3083
                  next if $other_item->holds->filter_by_found->count;
3084
                  next unless IsAvailableForItemLevelRequest($other_item, $patron_with_reserve, undef);
3084
                  next unless IsAvailableForItemLevelRequest($other_item, $patron_with_reserve, undef);
3085
                  next unless CanItemBeReserved($patron_with_reserve,$other_item,undef,{ignore_hold_counts=>1})->{status} eq 'OK';
3085
                  next unless CanItemBeReserved($patron_with_reserve,$other_item,undef,{ignore_hold_counts=>1})->{status} eq 'OK';
3086
                  # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
3086
                  # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
(-)a/C4/Reserves.pm (-29 / +2 lines)
Lines 137-144 BEGIN { Link Here
137
137
138
      CalculatePriority
138
      CalculatePriority
139
139
140
      IsItemOnHoldAndFound
141
142
      GetMaxPatronHoldsForRecord
140
      GetMaxPatronHoldsForRecord
143
141
144
      MergeHolds
142
      MergeHolds
Lines 1421-1427 sub IsAvailableForItemLevelRequest { Link Here
1421
        return $any_available ? 0 : 1;
1419
        return $any_available ? 0 : 1;
1422
1420
1423
    } else {  # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1421
    } else {  # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1424
        return $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber );
1422
        return $item->notforloan < 0 || $item->onloan || $item->holds->filter_by_found->count;
1425
    }
1423
    }
1426
}
1424
}
1427
1425
Lines 1453-1459 sub ItemsAnyAvailableAndNotRestricted { Link Here
1453
            || $i->notforloan # items with non-zero notforloan cannot be checked out
1451
            || $i->notforloan # items with non-zero notforloan cannot be checked out
1454
            || $i->withdrawn
1452
            || $i->withdrawn
1455
            || $i->onloan
1453
            || $i->onloan
1456
            || IsItemOnHoldAndFound( $i->id )
1454
            || $i->holds->filter_by_found->count
1457
            || ( $i->damaged
1455
            || ( $i->damaged
1458
                 && ! C4::Context->preference('AllowHoldsOnDamagedItems') )
1456
                 && ! C4::Context->preference('AllowHoldsOnDamagedItems') )
1459
            || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
1457
            || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
Lines 2283-2312 sub CalculatePriority { Link Here
2283
    return @row ? $row[0]+1 : 1;
2281
    return @row ? $row[0]+1 : 1;
2284
}
2282
}
2285
2283
2286
=head2 IsItemOnHoldAndFound
2287
2288
    my $bool = IsItemFoundHold( $itemnumber );
2289
2290
    Returns true if the item is currently on hold
2291
    and that hold has a non-null found status ( W, T, etc. )
2292
2293
=cut
2294
2295
sub IsItemOnHoldAndFound {
2296
    my ($itemnumber) = @_;
2297
2298
    my $rs = Koha::Database->new()->schema()->resultset('Reserve');
2299
2300
    my $found = $rs->count(
2301
        {
2302
            itemnumber => $itemnumber,
2303
            found      => { '!=' => undef }
2304
        }
2305
    );
2306
2307
    return $found;
2308
}
2309
2310
=head2 GetMaxPatronHoldsForRecord
2284
=head2 GetMaxPatronHoldsForRecord
2311
2285
2312
my $holds_per_record = ReservesControlBranch( $borrowernumber, $biblionumber );
2286
my $holds_per_record = ReservesControlBranch( $borrowernumber, $biblionumber );
2313
- 

Return to bug 17729