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

(-)a/C4/Serials.pm (-24 lines)
Lines 87-93 BEGIN { Link Here
87
      HasItems
87
      HasItems
88
      &GetSubscriptionsFromBorrower
88
      &GetSubscriptionsFromBorrower
89
      &subscriptionCurrentlyOnOrder
89
      &subscriptionCurrentlyOnOrder
90
      &GetSerialItemsInformations
91
90
92
    );
91
    );
93
}
92
}
Lines 2725-2753 sub _can_do_on_subscription { Link Here
2725
    return 0;
2724
    return 0;
2726
}
2725
}
2727
2726
2728
=head1 GetSerialItemsInformations
2729
2730
    @serialsitemsinformations = GetSerialItemsInformations (@serialid)
2731
2732
    return an array of specifique information of serials and serialitem a given array of serialid
2733
2734
=cut
2735
2736
sub GetSerialItemsInformations{
2737
    my (@serialid)=@_;
2738
    my @serialitemsinformation;
2739
    my $dbh = C4::Context->dbh;
2740
    foreach my $sid(@serialid){
2741
        my $sth = $dbh->prepare("select count(i.itemnumber) as countitems,s.itemnumber as itemnumber  from items i  natural join  serialitems s where s.serialid=?");
2742
        $sth->execute($sid);
2743
        my $line   = $sth->fetchrow_hashref;
2744
        if($line->{'countitems'}){
2745
            push @serialitemsinformation,$line;
2746
        }
2747
    }
2748
    return @serialitemsinformation;
2749
}
2750
2751
=head2 findSerialsByStatus
2727
=head2 findSerialsByStatus
2752
2728
2753
    @serials = findSerialsByStatus($status, $subscriptionid);
2729
    @serials = findSerialsByStatus($status, $subscriptionid);
(-)a/Koha/Serials.pm (+35 lines)
Lines 27-32 use Koha::Serial; Link Here
27
27
28
use base qw(Koha::Objects);
28
use base qw(Koha::Objects);
29
29
30
use vars qw(@ISA @EXPORT);
31
32
BEGIN {
33
    require Exporter;
34
    @ISA    = qw(Exporter);
35
    @EXPORT = qw(
36
        &GetSerialItemsInformations
37
    );
38
}
39
30
=head1 NAME
40
=head1 NAME
31
41
32
Koha::Serial - Koha Serial Object class
42
Koha::Serial - Koha Serial Object class
Lines 49-54 sub object_class { Link Here
49
    return 'Koha::Serial';
59
    return 'Koha::Serial';
50
}
60
}
51
61
62
=head2 GetSerialItemsInformations
63
64
    @serialsitemsinformations = GetSerialItemsInformations (@serialid)
65
66
    return an array of specifique information of serials and serialitem a given array of serialid
67
68
=cut
69
70
sub GetSerialItemsInformations{
71
    my ( @serialid ) = @_;
72
    my @serialitemsinformation;
73
    my $dbh = C4::Context->dbh;
74
75
    foreach my $sid ( @serialid ) {
76
        my $sth = $dbh->prepare("select count(i.itemnumber) as countitems,s.itemnumber as itemnumber  from items i natural join serialitems s where s.serialid=?");
77
        $sth->execute( $sid );
78
79
        my $line = $sth->fetchrow_hashref;
80
        if( $line->{'countitems'} ){
81
            push @serialitemsinformation, $line;
82
        }
83
    }
84
   return @serialitemsinformation;
85
}
86
52
=head1 AUTHOR
87
=head1 AUTHOR
53
88
54
Kyle M Hall <kyle@bywatersolutions.com>
89
Kyle M Hall <kyle@bywatersolutions.com>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt (-12 / +8 lines)
Lines 27-33 Link Here
27
           <input type="hidden" name="confdelete" value="1" />
27
           <input type="hidden" name="confdelete" value="1" />
28
           <input type="submit" class="approve" value="Yes, delete"/>
28
           <input type="submit" class="approve" value="Yes, delete"/>
29
       </form>
29
       </form>
30
       <form action=""/cgi-bin/koha/serials/serials-collection.pl/#">
30
       <form action="/cgi-bin/koha/serials/serials-collection.pl/#">
31
           <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
31
           <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
32
           <input type="submit" class="deny" value="No, don't delete"/>
32
           <input type="submit" class="deny" value="No, don't delete"/>
33
       </form>
33
       </form>
Lines 180-197 Link Here
180
                    [% IF ( serial.subscriptionexpired ) %]
180
                    [% IF ( serial.subscriptionexpired ) %]
181
                       <input type="checkbox" name="serialid" value="[% serial.serialid %]" disabled="disabled" />
181
                       <input type="checkbox" name="serialid" value="[% serial.serialid %]" disabled="disabled" />
182
                    [% ELSE %]
182
                    [% ELSE %]
183
                      [% IF ( serial.checked ) %]
183
                      [% IF ( delete ) %]
184
                         [% IF ( delete ) %]
184
                        [% IF serialsid.grep("${serial.serialid}").size %]
185
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" [% IF ( delete ) %] readonly [% END %] [% IF serialsid.grep("${serial.serialid}").size %] checked [% END %] />
185
                          <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" disabled checked />
186
                         [% ELSE %]
186
                        [% ELSE %]
187
                            <input type="checkbox" class="checkboxed" name="serialid" checked="checked" value="[% serial.serialid %]" />
187
                          <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" disabled />
188
                         [% END %]
188
                        [% END %]
189
                      [% ELSE %]
189
                      [% ELSE %]
190
                         [% IF ( delete ) %]
190
                        <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" />
191
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" [% IF ( delete ) %] readonly [% END %] [% IF serialsid.grep("${serial.serialid}").size %] checked [% END %] />
192
                         [% ELSE %]
193
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" />
194
                         [% END %]
195
                      [% END %]
191
                      [% END %]
196
                    [% END %]
192
                    [% END %]
197
                  [% END %]
193
                  [% END %]
(-)a/serials/serials-collection.pl (+1 lines)
Lines 28-33 use C4::Items; Link Here
28
use C4::Letters;
28
use C4::Letters;
29
use C4::Output;
29
use C4::Output;
30
use C4::Context;
30
use C4::Context;
31
use Koha::Serials;
31
32
32
use List::MoreUtils qw/uniq/;
33
use List::MoreUtils qw/uniq/;
33
34
(-)a/t/db_dependent/Serials.t (-10 / +8 lines)
Lines 16-21 use C4::Budgets; Link Here
16
use C4::Items;
16
use C4::Items;
17
use Koha::DateUtils;
17
use Koha::DateUtils;
18
use Koha::Acquisition::Booksellers;
18
use Koha::Acquisition::Booksellers;
19
use Koha::Serials;
19
use t::lib::Mocks;
20
use t::lib::Mocks;
20
use Test::More tests => 50;
21
use Test::More tests => 50;
21
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
Lines 31-38 my $dbh = C4::Context->dbh; Link Here
31
$dbh->{AutoCommit} = 0;
32
$dbh->{AutoCommit} = 0;
32
$dbh->{RaiseError} = 1;
33
$dbh->{RaiseError} = 1;
33
34
34
my $builder = t::lib::TestBuilder->new();
35
36
# This could/should be used for all untested methods
35
# This could/should be used for all untested methods
37
my @methods = ('updateClaim');
36
my @methods = ('updateClaim');
38
can_ok('C4::Serials', @methods);
37
can_ok('C4::Serials', @methods);
Lines 375-399 subtest "Test GetSerialItemsInformations " => sub { Link Here
375
        AddItem2Serial($serialid[0],$itemnumber1);
374
        AddItem2Serial($serialid[0],$itemnumber1);
376
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
375
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
377
        is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item");
376
        is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item");
378
        is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
377
        is ($result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
379
        AddItem2Serial($serialid[1],$itemnumber3);
378
        AddItem2Serial($serialid[1],$itemnumber3);
380
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
379
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
381
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 1 item");
380
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 1 item");
382
        is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
381
        is ($result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
383
        is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
382
        is ($result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
384
    };
383
    };
385
    subtest "Test with 2 serials and each have 2 items" => sub {
384
    subtest "Test with 2 serials and each have 2 items" => sub {
386
        plan tests => 6;
385
        plan tests => 6;
387
        AddItem2Serial($serialid[0],$itemnumber2);
386
        AddItem2Serial($serialid[0],$itemnumber2);
388
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
387
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
389
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials ");
388
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials ");
390
        is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
389
        is ($result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
391
        is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
390
        is ($result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
392
        AddItem2Serial($serialid[1],$itemnumber4);
391
        AddItem2Serial($serialid[1],$itemnumber4);
393
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
392
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
394
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items ");
393
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items ");
395
        is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
394
        is ($result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
396
        is (@result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2");
395
        is ($result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2");
397
    };
396
    };
398
};
397
};
399
398
400
- 

Return to bug 17674