Lines 191-222
if ( C4::Context->preference('IndependentBranches') ){
Link Here
|
191 |
# get all distinct unfulfilled reserves |
191 |
# get all distinct unfulfilled reserves |
192 |
my $distinct_holds = Koha::Holds->search( |
192 |
my $distinct_holds = Koha::Holds->search( |
193 |
{ %where }, |
193 |
{ %where }, |
194 |
{ join => 'itembib', alias => 'reserve' } |
194 |
{ join => 'itembib', alias => 'reserve', columns => [ 'biblionumber' ] } |
195 |
); |
195 |
); |
196 |
my @biblionumbers = uniq $distinct_holds->get_column('biblionumber'); |
196 |
my @biblionumbers = uniq $distinct_holds->get_column('biblionumber'); |
197 |
|
197 |
|
198 |
my @branchtransfers = map { $_->itemnumber } Koha::Item::Transfers->search({ datearrived => undef }, { columns => [ 'itemnumber' ], collapse => 1 }); |
198 |
my @branchtransfers = map { $_->itemnumber } Koha::Item::Transfers->search({ datearrived => undef }, { columns => [ 'itemnumber' ], collapse => 1 }); |
199 |
my @waiting_holds = map { $_->itemnumber } Koha::Holds->search({'found' => 'W'}, { columns => [ 'itemnumber' ], collapse => 1 }); |
199 |
my @waiting_holds = map { $_->itemnumber } Koha::Holds->search({'found' => 'W'}, { columns => [ 'itemnumber' ], collapse => 1 }); |
200 |
|
200 |
|
|
|
201 |
my @all_items = Koha::Items->search( |
202 |
{ |
203 |
biblionumber => { in => \@biblionumbers }, |
204 |
itemlost => 0, |
205 |
withdrawn => 0, |
206 |
notforloan => 0, |
207 |
onloan => undef, |
208 |
itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] }, |
209 |
} |
210 |
); |
211 |
|
212 |
my $all_items; |
213 |
foreach my $item ( @all_items ) { |
214 |
push @{$all_items->{$item->biblionumber}}, $item; |
215 |
} |
216 |
|
217 |
|
201 |
# make final reserves hash and fill with info |
218 |
# make final reserves hash and fill with info |
202 |
my $reserves; |
219 |
my $reserves; |
203 |
foreach my $bibnum ( @biblionumbers ){ |
220 |
foreach my $bibnum ( @biblionumbers ){ |
204 |
|
221 |
|
205 |
my @items = Koha::Items->search( |
222 |
my $items = $all_items->{$bibnum}; |
206 |
{ |
|
|
207 |
biblionumber => $bibnum, |
208 |
itemlost => 0, |
209 |
withdrawn => 0, |
210 |
notforloan => 0, |
211 |
onloan => undef, |
212 |
itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] }, |
213 |
} |
214 |
); |
215 |
|
223 |
|
216 |
# get available item types for each biblio |
224 |
# get available item types for each biblio |
217 |
my @res_itemtypes; |
225 |
my @res_itemtypes; |
218 |
if ( C4::Context->preference('item-level_itypes') ){ |
226 |
if ( C4::Context->preference('item-level_itypes') ){ |
219 |
@res_itemtypes = uniq map { defined $_->itype ? $_->itype : () } @items; |
227 |
@res_itemtypes = uniq map { defined $_->itype ? $_->itype : () } @$items; |
220 |
} else { |
228 |
} else { |
221 |
@res_itemtypes = Koha::Biblioitems->search( |
229 |
@res_itemtypes = Koha::Biblioitems->search( |
222 |
{ biblionumber => $bibnum, itemtype => { '!=', undef } }, |
230 |
{ biblionumber => $bibnum, itemtype => { '!=', undef } }, |
Lines 228-252
foreach my $bibnum ( @biblionumbers ){
Link Here
|
228 |
$reserves->{$bibnum}->{itemtypes} = \@res_itemtypes; |
236 |
$reserves->{$bibnum}->{itemtypes} = \@res_itemtypes; |
229 |
|
237 |
|
230 |
# get available locations for each biblio |
238 |
# get available locations for each biblio |
231 |
$reserves->{$bibnum}->{locations} = [ uniq map { defined $_->location ? $_->location : () } @items ]; |
239 |
$reserves->{$bibnum}->{locations} = [ uniq map { defined $_->location ? $_->location : () } @$items ]; |
232 |
|
240 |
|
233 |
# get available callnumbers for each biblio |
241 |
# get available callnumbers for each biblio |
234 |
$reserves->{$bibnum}->{callnumbers} = [ uniq map { defined $_->itemcallnumber ? $_->itemcallnumber : () } @items ]; |
242 |
$reserves->{$bibnum}->{callnumbers} = [ uniq map { defined $_->itemcallnumber ? $_->itemcallnumber : () } @$items ]; |
235 |
|
243 |
|
236 |
# get available enumchrons for each biblio |
244 |
# get available enumchrons for each biblio |
237 |
$reserves->{$bibnum}->{enumchrons} = [ uniq map { defined $_->enumchron ? $_->enumchron : () } @items ]; |
245 |
$reserves->{$bibnum}->{enumchrons} = [ uniq map { defined $_->enumchron ? $_->enumchron : () } @$items ]; |
238 |
|
246 |
|
239 |
# get available copynumbers for each biblio |
247 |
# get available copynumbers for each biblio |
240 |
$reserves->{$bibnum}->{copynumbers} = [ uniq map { defined $_->copynumber ? $_->copynumber : () } @items ]; |
248 |
$reserves->{$bibnum}->{copynumbers} = [ uniq map { defined $_->copynumber ? $_->copynumber : () } @$items ]; |
241 |
|
249 |
|
242 |
# get available barcodes for each biblio |
250 |
# get available barcodes for each biblio |
243 |
$reserves->{$bibnum}->{barcodes} = [ uniq map { defined $_->barcode ? $_->barcode : () } @items ]; |
251 |
$reserves->{$bibnum}->{barcodes} = [ uniq map { defined $_->barcode ? $_->barcode : () } @$items ]; |
244 |
|
252 |
|
245 |
# get available holding branches for each biblio |
253 |
# get available holding branches for each biblio |
246 |
$reserves->{$bibnum}->{holdingbranches} = [ uniq map { defined $_->holdingbranch ? $_->holdingbranch : () } @items ]; |
254 |
$reserves->{$bibnum}->{holdingbranches} = [ uniq map { defined $_->holdingbranch ? $_->holdingbranch : () } @$items ]; |
247 |
|
255 |
|
248 |
# items available |
256 |
# items available |
249 |
my $items_count = scalar @items; |
257 |
my $items_count = scalar @$items; |
250 |
$reserves->{$bibnum}->{items_count} = $items_count; |
258 |
$reserves->{$bibnum}->{items_count} = $items_count; |
251 |
|
259 |
|
252 |
# patrons with holds |
260 |
# patrons with holds |
253 |
- |
|
|