Bugzilla – Attachment 75646 Details for
Bug 17674
Allow UI to delete serials issues in batch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17674: Move subroutine GetSerialItemsInformations to Koha/Serials.pm
Bug-17674-Move-subroutine-GetSerialItemsInformatio.patch (text/plain), 9.53 KB, created by
David Bourgault
on 2018-05-29 19:20:34 UTC
(
hide
)
Description:
Bug 17674: Move subroutine GetSerialItemsInformations to Koha/Serials.pm
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2018-05-29 19:20:34 UTC
Size:
9.53 KB
patch
obsolete
>From 01437ae83b0405786076bd81427e35c20db04bbb Mon Sep 17 00:00:00 2001 >From: David Bourgault <david.bourgault@inlibro.com> >Date: Tue, 7 Nov 2017 13:51:45 -0500 >Subject: [PATCH] Bug 17674: Move subroutine GetSerialItemsInformations to > Koha/Serials.pm >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > C4/Serials.pm | 24 --------------- > Koha/Serials.pm | 35 ++++++++++++++++++++++ > .../prog/en/modules/serials/serials-collection.tt | 20 +++++-------- > serials/serials-collection.pl | 1 + > t/db_dependent/Serials.t | 17 +++++------ > 5 files changed, 52 insertions(+), 45 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 2418b26..ac21dad 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -87,7 +87,6 @@ BEGIN { > HasItems > &GetSubscriptionsFromBorrower > &subscriptionCurrentlyOnOrder >- &GetSerialItemsInformations > > ); > } >@@ -2725,29 +2724,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..e5ba33c 100644 >--- a/Koha/Serials.pm >+++ b/Koha/Serials.pm >@@ -27,6 +27,16 @@ 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 +59,31 @@ sub object_class { > return 'Koha::Serial'; > } > >+=head2 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 <kyle@bywatersolutions.com> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >index 91c669b..d19580b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >@@ -28,7 +28,7 @@ > <input type="hidden" name="confdelete" value="1" /> > <input type="submit" class="approve" value="Yes, delete"/> > </form> >- <form action=""/cgi-bin/koha/serials/serials-collection.pl/#"> >+ <form action="/cgi-bin/koha/serials/serials-collection.pl/#"> > <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" /> > <input type="submit" class="deny" value="No, don't delete"/> > </form> >@@ -184,18 +184,14 @@ > [% IF ( serial.subscriptionexpired ) %] > <input type="checkbox" name="serialid" value="[% serial.serialid %]" disabled="disabled" /> > [% ELSE %] >- [% IF ( serial.checked ) %] >- [% IF ( delete ) %] >- <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" [% IF ( delete ) %] readonly [% END %] [% IF serialsid.grep("${serial.serialid}").size %] checked [% END %] /> >- [% ELSE %] >- <input type="checkbox" class="checkboxed" name="serialid" checked="checked" value="[% serial.serialid %]" /> >- [% END %] >+ [% IF ( delete ) %] >+ [% IF serialsid.grep("${serial.serialid}").size %] >+ <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" disabled checked /> >+ [% ELSE %] >+ <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" disabled /> >+ [% END %] > [% ELSE %] >- [% IF ( delete ) %] >- <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" [% IF ( delete ) %] readonly [% END %] [% IF serialsid.grep("${serial.serialid}").size %] checked [% END %] /> >- [% ELSE %] >- <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" /> >- [% END %] >+ <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" /> > [% END %] > [% END %] > [% END %] >diff --git a/serials/serials-collection.pl b/serials/serials-collection.pl >index 1cf5ca9..e0c61ac 100755 >--- a/serials/serials-collection.pl >+++ b/serials/serials-collection.pl >@@ -28,6 +28,7 @@ use C4::Items; > use C4::Letters; > use C4::Output; > use C4::Context; >+use Koha::Serials; > > use Koha::DateUtils qw( dt_from_string ); > >diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t >index 201bc6f..d5f4996 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 Test::More tests => 50; > use t::lib::TestBuilder; >@@ -31,8 +32,6 @@ my $dbh = C4::Context->dbh; > $dbh->{AutoCommit} = 0; > $dbh->{RaiseError} = 1; > >-my $builder = t::lib::TestBuilder->new(); >- > # This could/should be used for all untested methods > my @methods = ('updateClaim'); > can_ok('C4::Serials', @methods); >@@ -375,25 +374,25 @@ subtest "Test GetSerialItemsInformations " => sub { > AddItem2Serial($serialid[0],$itemnumber1); > my @result = C4::Serials::GetSerialItemsInformations(@serialid); > is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item"); >- is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1"); >+ is ($result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1"); > AddItem2Serial($serialid[1],$itemnumber3); > @result = C4::Serials::GetSerialItemsInformations(@serialid); > is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 1 item"); >- is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1"); >- is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2"); >+ is ($result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1"); >+ is ($result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2"); > }; > subtest "Test with 2 serials and each have 2 items" => sub { > plan tests => 6; > AddItem2Serial($serialid[0],$itemnumber2); > my @result = C4::Serials::GetSerialItemsInformations(@serialid); > is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials "); >- is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1"); >- is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2"); >+ is ($result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1"); >+ is ($result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2"); > AddItem2Serial($serialid[1],$itemnumber4); > @result = C4::Serials::GetSerialItemsInformations(@serialid); > is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items "); >- is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1"); >- is (@result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2"); >+ is ($result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1"); >+ is ($result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2"); > }; > }; > >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17674
:
57731
|
58262
|
58263
|
58264
|
60925
|
61314
|
61315
|
61316
|
66565
|
69007
|
69010
|
69011
|
69013
|
69976
|
69977
|
69978
|
69979
|
71865
|
71866
|
71867
|
71868
|
71869
|
72985
|
73032
|
73035
|
73036
|
73037
|
73038
|
73039
|
73040
|
74318
|
74359
|
74472
|
75643
|
75644
|
75645
|
75646
|
75647
|
75648
|
75649
|
77745
|
77746
|
77747
|
77748
|
77749
|
77750
|
77751
|
77861
|
77862
|
77863
|
77864
|
77865
|
77866
|
77867
|
77868
|
79415
|
79420
|
79421
|
79422
|
79423
|
79424
|
79425
|
79426
|
79427
|
79428
|
79453
|
79454
|
79455
|
79456
|
79457
|
79458
|
79459
|
79460
|
80859
|
80944
|
80955
|
82237
|
86689
|
95474
|
99434
|
99944
|
99945
|
100906
|
100907