Lines 209-214
foreach my $item ( @all_items ) {
Link Here
|
209 |
push @{$all_items->{$item->biblionumber}}, $item; |
209 |
push @{$all_items->{$item->biblionumber}}, $item; |
210 |
} |
210 |
} |
211 |
|
211 |
|
|
|
212 |
# patrons count per biblio |
213 |
my $patrons_count = { |
214 |
map { $_->{biblionumber} => $_->{patrons_count} } @{ Koha::Holds->search( |
215 |
{}, |
216 |
{ |
217 |
select => [ 'biblionumber', { count => { distinct => 'borrowernumber' } } ], |
218 |
as => [qw( biblionumber patrons_count )], |
219 |
group_by => [qw( biblionumber )] |
220 |
}, |
221 |
)->unblessed |
222 |
} |
223 |
}; |
212 |
|
224 |
|
213 |
# make final reserves hash and fill with info |
225 |
# make final reserves hash and fill with info |
214 |
my $reserves; |
226 |
my $reserves; |
Lines 253-265
foreach my $bibnum ( @biblionumbers ){
Link Here
|
253 |
$reserves->{$bibnum}->{items_count} = $items_count; |
265 |
$reserves->{$bibnum}->{items_count} = $items_count; |
254 |
|
266 |
|
255 |
# patrons with holds |
267 |
# patrons with holds |
256 |
my $patrons_count = Koha::Holds->search( |
268 |
$hold_info->{patrons_count} = $patrons_count->{$bibnum}; |
257 |
{ biblionumber => $bibnum }, |
|
|
258 |
{ distinct => 1, columns => qw(me.borrowernumber) } |
259 |
)->count; |
260 |
$reserves->{$bibnum}->{patrons_count} = $patrons_count; |
261 |
|
269 |
|
262 |
my $pull_count = $items_count <= $patrons_count ? $items_count : $patrons_count; |
270 |
my $pull_count = $items_count <= $patrons_count->{$bibnum} ? $items_count : $patrons_count->{$bibnum}; |
263 |
if ( $pull_count == 0 ) { |
271 |
if ( $pull_count == 0 ) { |
264 |
delete($reserves->{$bibnum}); |
272 |
delete($reserves->{$bibnum}); |
265 |
next; |
273 |
next; |
266 |
- |
|
|