View | Details | Raw Unified | Return to bug 18296
Collapse All | Expand All

(-)a/C4/Items.pm (-21 lines)
Lines 71-77 BEGIN { Link Here
71
        GetItemLocation
71
        GetItemLocation
72
        GetLostItems
72
        GetLostItems
73
        GetItemsForInventory
73
        GetItemsForInventory
74
        GetItemInfosOf
75
        GetItemsByBiblioitemnumber
74
        GetItemsByBiblioitemnumber
76
        GetItemsInfo
75
        GetItemsInfo
77
	GetItemsLocationInfo
76
	GetItemsLocationInfo
Lines 1073-1098 sub GetItemsForInventory { Link Here
1073
    return (\@results, $iTotalRecords);
1072
    return (\@results, $iTotalRecords);
1074
}
1073
}
1075
1074
1076
=head2 GetItemInfosOf
1077
1078
  GetItemInfosOf(@itemnumbers);
1079
1080
=cut
1081
1082
sub GetItemInfosOf {
1083
    my @itemnumbers = @_;
1084
1085
    my $itemnumber_values = @itemnumbers ? join( ',', @itemnumbers ) : "''";
1086
1087
    my $dbh = C4::Context->dbh;
1088
    my $query = "
1089
        SELECT *
1090
        FROM items
1091
        WHERE itemnumber IN ($itemnumber_values)
1092
    ";
1093
    return $dbh->selectall_hashref($query, 'itemnumber');
1094
}
1095
1096
=head2 GetItemsByBiblioitemnumber
1075
=head2 GetItemsByBiblioitemnumber
1097
1076
1098
  GetItemsByBiblioitemnumber($biblioitemnumber);
1077
  GetItemsByBiblioitemnumber($biblioitemnumber);
(-)a/labels/label-item-search.pl (-1 lines)
Lines 30-36 use C4::Output qw(output_html_with_http_headers); Link Here
30
use C4::Context;
30
use C4::Context;
31
use C4::Search qw(SimpleSearch);
31
use C4::Search qw(SimpleSearch);
32
use C4::Biblio qw(TransformMarcToKoha);
32
use C4::Biblio qw(TransformMarcToKoha);
33
use C4::Items qw(GetItemInfosOf);
34
use C4::Creators::Lib qw(html_table);
33
use C4::Creators::Lib qw(html_table);
35
use C4::Debug;
34
use C4::Debug;
36
35
(-)a/reserve/request.pl (-10 / +11 lines)
Lines 294-321 foreach my $biblionumber (@biblionumbers) { Link Here
294
294
295
    my %itemnumbers_of_biblioitem;
295
    my %itemnumbers_of_biblioitem;
296
296
297
    ## $items is array of 'item' table numbers
298
    my $items = Koha::Items->search({ biblionumber => $biblionumber });
299
    my @itemnumbers = $items->get_column('itemnumber');
300
    my @hostitems = get_hostitemnumbers_of($biblionumber);
297
    my @hostitems = get_hostitemnumbers_of($biblionumber);
298
    my @itemnumbers;
301
    if (@hostitems){
299
    if (@hostitems){
302
        $template->param('hostitemsflag' => 1);
300
        $template->param('hostitemsflag' => 1);
303
        push(@itemnumbers, @hostitems);
301
        push(@itemnumbers, @hostitems);
304
    }
302
    }
305
303
306
    if (!@itemnumbers) {
304
    my $items = Koha::Items->search({ -or => { biblionumber => $biblionumber, itemnumber => { in => \@itemnumbers } } });
305
306
    unless ( $items->count ) {
307
        # FIXME Then why do we continue?
307
        $template->param('noitems' => 1);
308
        $template->param('noitems' => 1);
308
        $biblioloopiter{noitems} = 1;
309
        $biblioloopiter{noitems} = 1;
309
    }
310
    }
310
311
311
    ## Hash of item number to 'item' table fields
312
    my $iteminfos_of = GetItemInfosOf(@itemnumbers);
313
314
    ## Here we go backwards again to create hash of biblioitemnumber to itemnumbers,
312
    ## Here we go backwards again to create hash of biblioitemnumber to itemnumbers,
315
    ## when by definition all of the itemnumber have the same biblioitemnumber
313
    ## when by definition all of the itemnumber have the same biblioitemnumber
316
    foreach my $itemnumber (@itemnumbers) {
314
    my ( $itemnumbers_of_biblioitem, $iteminfos_of);
317
        my $biblioitemnumber = $iteminfos_of->{$itemnumber}->{biblioitemnumber};
315
    while ( my $item = $items->next ) {
316
        $item = $item->unblessed;
317
        my $biblioitemnumber = $item->{biblioitemnumber};
318
        my $itemnumber = $item->{itemnumber};
318
        push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
319
        push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
320
        $iteminfos_of->{$itemnumber} = $item;
319
    }
321
    }
320
322
321
    ## Should be same as biblionumber
323
    ## Should be same as biblionumber
322
- 

Return to bug 18296