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

(-)a/Koha/UI/Table/Builder/Items.pm (-5 / +2 lines)
Lines 19-25 use Modern::Perl; Link Here
19
use List::MoreUtils qw( uniq );
19
use List::MoreUtils qw( uniq );
20
use C4::Biblio qw( GetMarcStructure GetMarcFromKohaField IsMarcStructureInternal );
20
use C4::Biblio qw( GetMarcStructure GetMarcFromKohaField IsMarcStructureInternal );
21
use Koha::Items;
21
use Koha::Items;
22
use List::MoreUtils qw(first_index);
23
22
24
=head1 NAME
23
=head1 NAME
25
24
Lines 72-87 Use it with: Link Here
72
71
73
sub build_table {
72
sub build_table {
74
    my ( $self, $params ) = @_;
73
    my ( $self, $params ) = @_;
75
    my @itemnumbers = @{ $self->{itemnumbers} };
74
    my %itemnumbers_to_idx = map { $self->{itemnumbers}->[$_] => $_ } 0..$#{$self->{itemnumbers}};
76
    my $items = Koha::Items->search( { itemnumber => $self->{itemnumbers} } );
75
    my $items = Koha::Items->search( { itemnumber => $self->{itemnumbers} } );
77
76
78
    my @items;
77
    my @items;
79
    while ( my $item = $items->next ) {
78
    while ( my $item = $items->next ) {
80
        my $item_info = $item->columns_to_str;
79
        my $item_info = $item->columns_to_str;
81
        my $index = first_index { $_ eq $item->itemnumber } @itemnumbers;
82
        $item_info = {
80
        $item_info = {
83
            %$item_info,
81
            %$item_info,
84
            index          => $index,
82
            index          => $itemnumbers_to_idx{$item->itemnumber},
85
            biblio         => $item->biblio,
83
            biblio         => $item->biblio,
86
            safe_to_delete => $item->safe_to_delete,
84
            safe_to_delete => $item->safe_to_delete,
87
            holds          => $item->biblio->holds->count,
85
            holds          => $item->biblio->holds->count,
88
- 

Return to bug 31455