Bug 11650: multiplicated authorities after link_bibs_to_authorities.pl
[koha_fer] / C4 / HoldsQueue.pm
index 6c36402..0d645bd 100755 (executable)
@@ -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};
@@ -433,7 +432,6 @@ sub MapItemsToHoldRequests {
                 }
             }
             $holdingbranch = $pickup_branch;
-            $itemnumber ||= $holding_branch_items->[0]->{itemnumber};
         }
         elsif ($transport_cost_matrix) {
             $pull_branches = [keys %items_by_branch];
@@ -468,6 +466,7 @@ 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;
@@ -477,7 +476,7 @@ sub MapItemsToHoldRequests {
 
             unless ( $itemnumber ) {
                 foreach my $current_item ( @{ $items_by_branch{$holdingbranch} } ) {
-                    if ( $holdingbranch && ( $current_item->{holdallowed} == 2 || $pickup_branch eq $current_item->{homebranch} ) ) {
+                    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
                     }