From 88e50b6a68a9b433c55cea2d2c8d525edc1887ea Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Mar 2017 19:50:18 -0300 Subject: [PATCH] Bug 18296: C4::Items - Remove GetItemInfosOf At this point this subroutine is only used once, from reserve/request.pl. Since we already have the items, it's easy to populate the different hashes as the rest of the code is expecting it. Test plan: You need to create analytical record relationships ( EasyAnalyticalRecords needs to be set). Link an item to a biblio using the 'Edit > Link to host item' menu from the biblio detail page. From the staff interface place a hold on the biblio. You should see the items from the biblio and the one you just linked Signed-off-by: Josef Moravec Signed-off-by: Marcel de Rooy --- C4/Items.pm | 21 --------------------- labels/label-item-search.pl | 1 - reserve/request.pl | 20 +++++++++++--------- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 5d2f8aeb57..26c14a13c7 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -69,7 +69,6 @@ BEGIN { CheckItemPreSave GetItemsForInventory - GetItemInfosOf GetItemsByBiblioitemnumber GetItemsInfo GetItemsLocationInfo @@ -923,26 +922,6 @@ sub GetItemsForInventory { return (\@results, $iTotalRecords); } -=head2 GetItemInfosOf - - GetItemInfosOf(@itemnumbers); - -=cut - -sub GetItemInfosOf { - my @itemnumbers = @_; - - my $itemnumber_values = @itemnumbers ? join( ',', @itemnumbers ) : "''"; - - my $dbh = C4::Context->dbh; - my $query = " - SELECT * - FROM items - WHERE itemnumber IN ($itemnumber_values) - "; - return $dbh->selectall_hashref($query, 'itemnumber'); -} - =head2 GetItemsByBiblioitemnumber GetItemsByBiblioitemnumber($biblioitemnumber); diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl index d3189871d9..ddc0bf88dd 100755 --- a/labels/label-item-search.pl +++ b/labels/label-item-search.pl @@ -30,7 +30,6 @@ use C4::Output qw(output_html_with_http_headers); use C4::Context; use C4::Search qw(SimpleSearch); use C4::Biblio qw(TransformMarcToKoha); -use C4::Items qw(GetItemInfosOf); use C4::Creators::Lib qw(html_table); use C4::Debug; diff --git a/reserve/request.pl b/reserve/request.pl index b33ae70b3a..9ec204c327 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -294,28 +294,30 @@ foreach my $biblionumber (@biblionumbers) { my %itemnumbers_of_biblioitem; - ## $items is array of 'item' table numbers - my $items = Koha::Items->search({ biblionumber => $biblionumber }); - my @itemnumbers = $items->get_column('itemnumber'); my @hostitems = get_hostitemnumbers_of($biblionumber); + my @itemnumbers; if (@hostitems){ $template->param('hostitemsflag' => 1); push(@itemnumbers, @hostitems); } - if (!@itemnumbers) { + my $items = Koha::Items->search({ -or => { biblionumber => $biblionumber, itemnumber => { in => \@itemnumbers } } }); + + unless ( $items->count ) { + # FIXME Then why do we continue? $template->param('noitems' => 1); $biblioloopiter{noitems} = 1; } - ## Hash of item number to 'item' table fields - my $iteminfos_of = GetItemInfosOf(@itemnumbers); - ## Here we go backwards again to create hash of biblioitemnumber to itemnumbers, ## when by definition all of the itemnumber have the same biblioitemnumber - foreach my $itemnumber (@itemnumbers) { - my $biblioitemnumber = $iteminfos_of->{$itemnumber}->{biblioitemnumber}; + my ( $itemnumbers_of_biblioitem, $iteminfos_of); + while ( my $item = $items->next ) { + $item = $item->unblessed; + my $biblioitemnumber = $item->{biblioitemnumber}; + my $itemnumber = $item->{itemnumber}; push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber ); + $iteminfos_of->{$itemnumber} = $item; } ## Should be same as biblionumber -- 2.39.5