From aecaf39bf4b179e3dbe86f23868aa06169b6749b Mon Sep 17 00:00:00 2001 From: Paudet Date: Mon, 28 Aug 2017 15:33:12 -0400 Subject: [PATCH] Bug 17674 - Move subroutine GetSerialItemsInformations to Koha/Serials.pm --- C4/Serials.pm | 24 ------------------------ Koha/Serials.pm | 33 +++++++++++++++++++++++++++++++++ serials/serials-collection.pl | 1 + t/db_dependent/Serials.t | 1 + 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index b881e95..d79c0a5 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -87,7 +87,6 @@ BEGIN { HasItems &GetSubscriptionsFromBorrower &subscriptionCurrentlyOnOrder - &GetSerialItemsInformations ); } @@ -2722,29 +2721,6 @@ sub _can_do_on_subscription { return 0; } -=head1 GetSerialItemsInformations - - @serialsitemsinformations = GetSerialItemsInformations (@serialid) - - return an array of specifique information of serials and serialitem a given array of serialid - -=cut - -sub GetSerialItemsInformations{ - my (@serialid)=@_; - my @serialitemsinformation; - my $dbh = C4::Context->dbh; - foreach my $sid(@serialid){ - my $sth = $dbh->prepare("select count(i.itemnumber) as countitems,s.itemnumber as itemnumber from items i natural join serialitems s where s.serialid=?"); - $sth->execute($sid); - my $line = $sth->fetchrow_hashref; - if($line->{'countitems'}){ - push @serialitemsinformation,$line; - } - } - return @serialitemsinformation; -} - =head2 findSerialsByStatus @serials = findSerialsByStatus($status, $subscriptionid); diff --git a/Koha/Serials.pm b/Koha/Serials.pm index e970448..8d80a77 100644 --- a/Koha/Serials.pm +++ b/Koha/Serials.pm @@ -27,6 +27,17 @@ use Koha::Serial; use base qw(Koha::Objects); + +use vars qw(@ISA @EXPORT); + +BEGIN { + require Exporter; + @ISA = qw(Exporter); + @EXPORT = qw( + &GetSerialItemsInformations + ); +} + =head1 NAME Koha::Serial - Koha Serial Object class @@ -49,6 +60,28 @@ sub object_class { return 'Koha::Serial'; } +=head1 GetSerialItemsInformations + + @serialsitemsinformations = GetSerialItemsInformations (@serialid) + + return an array of specifique information of serials and serialitem a given array of serialid + +=cut + +sub GetSerialItemsInformations{ + my (@serialid)=@_; + my @serialitemsinformation; + my $dbh = C4::Context->dbh; + foreach my $sid(@serialid){ + my $sth = $dbh->prepare("select count(i.itemnumber) as countitems,s.itemnumber as itemnumber from items i natural join serialitems s where s.serialid=?"); + $sth->execute($sid); + my $line = $sth->fetchrow_hashref; + if($line->{'countitems'}){ + push @serialitemsinformation,$line; + } + } + return @serialitemsinformation; +} =head1 AUTHOR Kyle M Hall diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl index 02cd788..3490a45 100755 --- a/serials/serials-collection.pl +++ b/serials/serials-collection.pl @@ -29,6 +29,7 @@ use C4::Items; use C4::Letters; use C4::Output; use C4::Context; +use Koha::Serials; use List::MoreUtils qw/uniq/; diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index 6958cb0..270f4a2 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -16,6 +16,7 @@ use C4::Budgets; use C4::Items; use Koha::DateUtils; use Koha::Acquisition::Booksellers; +use Koha::Serials; use t::lib::Mocks; use t::lib::TestBuilder; use Test::More tests => 50; -- 1.9.1