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

(-)a/C4/Serials.pm (-24 lines)
Lines 85-91 BEGIN { Link Here
85
      &CountIssues
85
      &CountIssues
86
      HasItems
86
      HasItems
87
      &subscriptionCurrentlyOnOrder
87
      &subscriptionCurrentlyOnOrder
88
      &GetSerialItemsInformations
89
88
90
    );
89
    );
91
}
90
}
Lines 2596-2624 sub _can_do_on_subscription { Link Here
2596
    return 0;
2595
    return 0;
2597
}
2596
}
2598
2597
2599
=head1 GetSerialItemsInformations
2600
2601
    @serialsitemsinformations = GetSerialItemsInformations (@serialid)
2602
2603
    return an array of specifique information of serials and serialitem a given array of serialid
2604
2605
=cut
2606
2607
sub GetSerialItemsInformations{
2608
    my (@serialid)=@_;
2609
    my @serialitemsinformation;
2610
    my $dbh = C4::Context->dbh;
2611
    foreach my $sid(@serialid){
2612
        my $sth = $dbh->prepare("select count(i.itemnumber) as countitems,s.itemnumber as itemnumber  from items i  natural join  serialitems s where s.serialid=?");
2613
        $sth->execute($sid);
2614
        my $line   = $sth->fetchrow_hashref;
2615
        if($line->{'countitems'}){
2616
            push @serialitemsinformation,$line;
2617
        }
2618
    }
2619
    return @serialitemsinformation;
2620
}
2621
2622
=head2 findSerialsByStatus
2598
=head2 findSerialsByStatus
2623
2599
2624
    @serials = findSerialsByStatus($status, $subscriptionid);
2600
    @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 29-35 Link Here
29
           <input type="hidden" name="confdelete" value="1" />
29
           <input type="hidden" name="confdelete" value="1" />
30
           <input type="submit" class="approve" value="Yes, delete"/>
30
           <input type="submit" class="approve" value="Yes, delete"/>
31
       </form>
31
       </form>
32
       <form action=""/cgi-bin/koha/serials/serials-collection.pl/#">
32
       <form action="/cgi-bin/koha/serials/serials-collection.pl/#">
33
           <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
33
           <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
34
           <input type="submit" class="deny" value="No, don't delete"/>
34
           <input type="submit" class="deny" value="No, don't delete"/>
35
       </form>
35
       </form>
Lines 185-202 Link Here
185
                    [% IF ( serial.subscriptionexpired ) %]
185
                    [% IF ( serial.subscriptionexpired ) %]
186
                       <input type="checkbox" name="serialid" value="[% serial.serialid | html %]" disabled="disabled" />
186
                       <input type="checkbox" name="serialid" value="[% serial.serialid | html %]" disabled="disabled" />
187
                    [% ELSE %]
187
                    [% ELSE %]
188
                      [% IF ( serial.checked ) %]
188
                      [% IF ( delete ) %]
189
                         [% IF ( delete ) %]
189
                        [% IF serialsid.grep("${serial.serialid}").size %]
190
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid | html %]" [% IF ( delete ) %] readonly [% END %] [% IF serialsid.grep("${serial.serialid}").size %] checked [% END %] />
190
                          <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid | html %]" disabled checked />
191
                         [% ELSE %]
191
                        [% ELSE %]
192
                            <input type="checkbox" class="checkboxed" name="serialid" checked="checked" value="[% serial.serialid | html %]" />
192
                          <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid | html %]" disabled />
193
                         [% END %]
193
                        [% END %]
194
                      [% ELSE %]
194
                      [% ELSE %]
195
                         [% IF ( delete ) %]
195
                        <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid | html %]" />
196
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid | html %]" [% IF ( delete ) %] readonly [% END %] [% IF serialsid.grep("${serial.serialid}").size %] checked [% END %] />
197
                         [% ELSE %]
198
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid | html %]" />
199
                         [% END %]
200
                      [% END %]
196
                      [% END %]
201
                    [% END %]
197
                    [% END %]
202
                  [% END %]
198
                  [% 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 Koha::DateUtils qw( dt_from_string );
33
use Koha::DateUtils qw( dt_from_string );
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 371-395 subtest "Test GetSerialItemsInformations " => sub { Link Here
371
        AddItem2Serial($serialid[0],$itemnumber1);
370
        AddItem2Serial($serialid[0],$itemnumber1);
372
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
371
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
373
        is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item");
372
        is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item");
374
        is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
373
        is ($result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
375
        AddItem2Serial($serialid[1],$itemnumber3);
374
        AddItem2Serial($serialid[1],$itemnumber3);
376
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
375
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
377
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 1 item");
376
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 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
        is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
378
        is ($result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
380
    };
379
    };
381
    subtest "Test with 2 serials and each have 2 items" => sub {
380
    subtest "Test with 2 serials and each have 2 items" => sub {
382
        plan tests => 6;
381
        plan tests => 6;
383
        AddItem2Serial($serialid[0],$itemnumber2);
382
        AddItem2Serial($serialid[0],$itemnumber2);
384
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
383
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
385
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials ");
384
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials ");
386
        is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
385
        is ($result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
387
        is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
386
        is ($result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
388
        AddItem2Serial($serialid[1],$itemnumber4);
387
        AddItem2Serial($serialid[1],$itemnumber4);
389
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
388
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
390
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items ");
389
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items ");
391
        is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
390
        is ($result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
392
        is (@result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2");
391
        is ($result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2");
393
    };
392
    };
394
};
393
};
395
394
396
- 

Return to bug 17674