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 3105-3111 sub CanBookBeRenewed { Link Here
3105
3105
3106
                foreach my $other_item (@other_items) {
3106
                foreach my $other_item (@other_items) {
3107
                  next if defined $matched_items{$other_item->itemnumber};
3107
                  next if defined $matched_items{$other_item->itemnumber};
3108
                  next if IsItemOnHoldAndFound( $other_item->itemnumber );
3108
                  next if $other_item->holds->filter_by_found->count;
3109
                  next unless IsAvailableForItemLevelRequest($other_item, $patron_with_reserve, undef);
3109
                  next unless IsAvailableForItemLevelRequest($other_item, $patron_with_reserve, undef);
3110
                  next unless CanItemBeReserved($patron_with_reserve,$other_item,undef,{ignore_hold_counts=>1})->{status} eq 'OK';
3110
                  next unless CanItemBeReserved($patron_with_reserve,$other_item,undef,{ignore_hold_counts=>1})->{status} eq 'OK';
3111
                  # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
3111
                  # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
(-)a/C4/Reserves.pm (-29 / +2 lines)
Lines 135-142 BEGIN { Link Here
135
135
136
      CalculatePriority
136
      CalculatePriority
137
137
138
      IsItemOnHoldAndFound
139
140
      GetMaxPatronHoldsForRecord
138
      GetMaxPatronHoldsForRecord
141
139
142
      MergeHolds
140
      MergeHolds
Lines 1380-1386 sub IsAvailableForItemLevelRequest { Link Here
1380
        return $any_available ? 0 : 1;
1378
        return $any_available ? 0 : 1;
1381
1379
1382
    } else {  # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1380
    } else {  # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved)
1383
        return $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber );
1381
        return $item->notforloan < 0 || $item->onloan || $item->holds->filter_by_found->count;
1384
    }
1382
    }
1385
}
1383
}
1386
1384
Lines 1412-1418 sub ItemsAnyAvailableAndNotRestricted { Link Here
1412
            || $i->notforloan # items with non-zero notforloan cannot be checked out
1410
            || $i->notforloan # items with non-zero notforloan cannot be checked out
1413
            || $i->withdrawn
1411
            || $i->withdrawn
1414
            || $i->onloan
1412
            || $i->onloan
1415
            || IsItemOnHoldAndFound( $i->id )
1413
            || $i->holds->filter_by_found->count
1416
            || ( $i->damaged
1414
            || ( $i->damaged
1417
                 && ! C4::Context->preference('AllowHoldsOnDamagedItems') )
1415
                 && ! C4::Context->preference('AllowHoldsOnDamagedItems') )
1418
            || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
1416
            || Koha::ItemTypes->find( $i->effective_itemtype() )->notforloan
Lines 2243-2272 sub CalculatePriority { Link Here
2243
    return @row ? $row[0]+1 : 1;
2241
    return @row ? $row[0]+1 : 1;
2244
}
2242
}
2245
2243
2246
=head2 IsItemOnHoldAndFound
2247
2248
    my $bool = IsItemFoundHold( $itemnumber );
2249
2250
    Returns true if the item is currently on hold
2251
    and that hold has a non-null found status ( W, T, etc. )
2252
2253
=cut
2254
2255
sub IsItemOnHoldAndFound {
2256
    my ($itemnumber) = @_;
2257
2258
    my $rs = Koha::Database->new()->schema()->resultset('Reserve');
2259
2260
    my $found = $rs->count(
2261
        {
2262
            itemnumber => $itemnumber,
2263
            found      => { '!=' => undef }
2264
        }
2265
    );
2266
2267
    return $found;
2268
}
2269
2270
=head2 GetMaxPatronHoldsForRecord
2244
=head2 GetMaxPatronHoldsForRecord
2271
2245
2272
my $holds_per_record = ReservesControlBranch( $borrowernumber, $biblionumber );
2246
my $holds_per_record = ReservesControlBranch( $borrowernumber, $biblionumber );
2273
- 

Return to bug 17729