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