From 5d6efd4847cfb81ef9752f58e95ed761b50d13b4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 6 Aug 2018 17:56:38 -0300 Subject: [PATCH] Bug 21202: Replace C4::Items::GetItemsByBiblioitemnumber calls http://lists.koha-community.org/pipermail/koha-devel/2018-August/044757.html Prior to this patch, GetRecords returned timestampX, cardX and borrowerX for the last 3 patrons who checked out the items. I have no idea if it is a desired effects but, as this code has been there for a very long time (2005), I suspect it's not. The "doc" (/ilsdi.pl?service=Describe&verb=GetRecords) does not say anything about the checkouts info. Test plan: hit /ilsdi.pl?service=GetRecords&id=1 and confirm the info about items are displayed correctly Signed-off-by: Josef Moravec Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens --- C4/ILSDI/Services.pm | 2 +- C4/Items.pm | 58 -------------------------------------------- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index f3b15da566..d3920dcc2f 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -228,7 +228,7 @@ sub GetRecords { my $biblioitemnumber = $biblioitem->{'biblioitemnumber'}; my $holds = $biblio->current_holds->unblessed; my $issues = GetBiblioIssues($biblionumber); - my $items = GetItemsByBiblioitemnumber($biblioitemnumber); + my $items = $biblio->items->unblessed; # We loop over the items to clean them foreach my $item (@$items) { diff --git a/C4/Items.pm b/C4/Items.pm index f4e6d65146..6a8cb078d9 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -69,7 +69,6 @@ BEGIN { CheckItemPreSave GetItemsForInventory - GetItemsByBiblioitemnumber GetItemsInfo GetItemsLocationInfo GetHostItemsInfo @@ -780,11 +779,6 @@ The following functions provide various ways of getting an item record, a set of item records, or lists of authorized values for certain item fields. -Some of the functions in this group are candidates -for refactoring -- for example, some of the code -in C and C -has copy-and-paste work. - =cut =head2 GetItemsForInventory @@ -937,58 +931,6 @@ sub GetItemsForInventory { return (\@results, $iTotalRecords); } -=head2 GetItemsByBiblioitemnumber - - GetItemsByBiblioitemnumber($biblioitemnumber); - -Returns an arrayref of hashrefs suitable for use in a TMPL_LOOP -Called by C - -=cut - -sub GetItemsByBiblioitemnumber { - my ( $bibitem ) = @_; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT * FROM items WHERE items.biblioitemnumber = ?") || die $dbh->errstr; - # Get all items attached to a biblioitem - my $i = 0; - my @results; - $sth->execute($bibitem) || die $sth->errstr; - while ( my $data = $sth->fetchrow_hashref ) { - # Foreach item, get circulation information - my $sth2 = $dbh->prepare( "SELECT * FROM issues,borrowers - WHERE itemnumber = ? - AND issues.borrowernumber = borrowers.borrowernumber" - ); - $sth2->execute( $data->{'itemnumber'} ); - if ( my $data2 = $sth2->fetchrow_hashref ) { - # if item is out, set the due date and who it is out too - $data->{'date_due'} = $data2->{'date_due'}; - $data->{'cardnumber'} = $data2->{'cardnumber'}; - $data->{'borrowernumber'} = $data2->{'borrowernumber'}; - } - else { - # set date_due to blank, so in the template we check itemlost, and withdrawn - $data->{'date_due'} = ''; - } # else - # Find the last 3 people who borrowed this item. - my $query2 = "SELECT * FROM old_issues, borrowers WHERE itemnumber = ? - AND old_issues.borrowernumber = borrowers.borrowernumber - ORDER BY returndate desc,timestamp desc LIMIT 3"; - $sth2 = $dbh->prepare($query2) || die $dbh->errstr; - $sth2->execute( $data->{'itemnumber'} ) || die $sth2->errstr; - my $i2 = 0; - while ( my $data2 = $sth2->fetchrow_hashref ) { - $data->{"timestamp$i2"} = $data2->{'timestamp'}; - $data->{"card$i2"} = $data2->{'cardnumber'}; - $data->{"borrower$i2"} = $data2->{'borrowernumber'}; - $i2++; - } - push(@results,$data); - } - return (\@results); -} - =head2 GetItemsInfo @results = GetItemsInfo($biblionumber); -- 2.39.5