X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FHoldsQueue.pm;h=0d645bdfdd9d7eaaddcaed6b7611ab485e160db3;hb=b140b8cc0841494ac03fcb3c5faf83e1678d2bd2;hp=ce4594b882996b5947a096f9fc82c4feb23f0a96;hpb=d46657f8af980524a4351e40abe0b901d1af3e6a;p=koha_fer diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index ce4594b882..0d645bdfdd 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -135,7 +135,6 @@ sub GetHoldsQueueItems { $sth->execute(@bind_params); my $items = []; while ( my $row = $sth->fetchrow_hashref ){ - $row->{reservedate} = format_date($row->{reservedate}); my $record = GetMarcBiblio($row->{biblionumber}); if ($record){ $row->{subtitle} = GetRecordValue('subtitle',$record,'')->[0]->{subfield}; @@ -299,6 +298,7 @@ to fill a hold request if and only if: * it is not currently in transit * it is not lost * it is not sitting on the hold shelf + * it is not damaged (unless AllowHoldsOnDamagedItems is on) =cut @@ -318,7 +318,7 @@ sub GetItemsAvailableToFillHoldRequestsForBib { $items_query .= "WHERE items.notforloan = 0 AND holdingbranch IS NOT NULL AND itemlost = 0 - AND wthdrawn = 0"; + AND withdrawn = 0"; $items_query .= " AND damaged = 0" unless C4::Context->preference('AllowHoldsOnDamagedItems'); $items_query .= " AND items.onloan IS NULL AND (itemtypes.notforloan IS NULL OR itemtypes.notforloan = 0) @@ -330,8 +330,6 @@ sub GetItemsAvailableToFillHoldRequestsForBib { AND (found IS NOT NULL OR priority = 0) ) AND items.biblionumber = ?"; - $items_query .= " AND damaged = 0 " - unless C4::Context->preference('AllowHoldsOnDamagedItems'); my @params = ($biblionumber, $biblionumber); if ($branches_to_use && @$branches_to_use) { @@ -345,7 +343,7 @@ sub GetItemsAvailableToFillHoldRequestsForBib { my @items = grep { ! scalar GetTransfers($_->{itemnumber}) } @$itm; return [ grep { my $rule = GetBranchItemRule($_->{homebranch}, $_->{itype}); - $_->{holdallowed} = $rule->{holdallowed} != 0 + $_->{holdallowed} = $rule->{holdallowed}; } @items ]; } @@ -434,7 +432,6 @@ sub MapItemsToHoldRequests { } } $holdingbranch = $pickup_branch; - $itemnumber ||= $holding_branch_items->[0]->{itemnumber}; } elsif ($transport_cost_matrix) { $pull_branches = [keys %items_by_branch]; @@ -448,7 +445,6 @@ sub MapItemsToHoldRequests { $itemnumber = $item->{itemnumber}; last; } - $itemnumber ||= $holding_branch_items->[0]->{itemnumber}; } else { warn "No transport costs for $pickup_branch"; @@ -470,14 +466,22 @@ sub MapItemsToHoldRequests { $holdingbranch ||= $branch; foreach my $item (@$holding_branch_items) { next if $pickup_branch ne $item->{homebranch}; + next if ( $item->{holdallowed} == 1 && $item->{homebranch} ne $request->{borrowerbranch} ); $itemnumber = $item->{itemnumber}; $holdingbranch = $branch; last PULL_BRANCHES; } } - $itemnumber ||= $items_by_branch{$holdingbranch}->[0]->{itemnumber} - if $holdingbranch; + + unless ( $itemnumber ) { + foreach my $current_item ( @{ $items_by_branch{$holdingbranch} } ) { + if ( $holdingbranch && ( $current_item->{holdallowed} == 2 || $request->{borrowerbranch} eq $current_item->{homebranch} ) ) { + $itemnumber = $current_item->{itemnumber}; + last; # quit this loop as soon as we have a suitable item + } + } + } } if ($itemnumber) {