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 2722-2750 sub _can_do_on_subscription { Link Here
2722
    return 0;
2721
    return 0;
2723
}
2722
}
2724
2723
2725
=head1 GetSerialItemsInformations
2726
2727
    @serialsitemsinformations = GetSerialItemsInformations (@serialid)
2728
2729
    return an array of specifique information of serials and serialitem a given array of serialid
2730
2731
=cut
2732
2733
sub GetSerialItemsInformations{
2734
    my (@serialid)=@_;
2735
    my @serialitemsinformation;
2736
    my $dbh = C4::Context->dbh;
2737
    foreach my $sid(@serialid){
2738
        my $sth = $dbh->prepare("select count(i.itemnumber) as countitems,s.itemnumber as itemnumber  from items i  natural join  serialitems s where s.serialid=?");
2739
        $sth->execute($sid);
2740
        my $line   = $sth->fetchrow_hashref;
2741
        if($line->{'countitems'}){
2742
            push @serialitemsinformation,$line;
2743
        }
2744
    }
2745
    return @serialitemsinformation;
2746
}
2747
2748
=head2 findSerialsByStatus
2724
=head2 findSerialsByStatus
2749
2725
2750
    @serials = findSerialsByStatus($status, $subscriptionid);
2726
    @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 121-127 $(document).ready(function() { Link Here
121
           <input type="hidden" name="confdelete" value="1" />
121
           <input type="hidden" name="confdelete" value="1" />
122
           <input type="submit" class="approve" value="Yes, delete"/>
122
           <input type="submit" class="approve" value="Yes, delete"/>
123
       </form>
123
       </form>
124
       <form action=""/cgi-bin/koha/serials/serials-collection.pl/#">
124
       <form action="/cgi-bin/koha/serials/serials-collection.pl/#">
125
           <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
125
           <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
126
           <input type="submit" class="deny" value="No, don't delete"/>
126
           <input type="submit" class="deny" value="No, don't delete"/>
127
       </form>
127
       </form>
Lines 274-291 $(document).ready(function() { Link Here
274
                    [% IF ( serial.subscriptionexpired ) %]
274
                    [% IF ( serial.subscriptionexpired ) %]
275
                       <input type="checkbox" name="serialid" value="[% serial.serialid %]" disabled="disabled" />
275
                       <input type="checkbox" name="serialid" value="[% serial.serialid %]" disabled="disabled" />
276
                    [% ELSE %]
276
                    [% ELSE %]
277
                      [% IF ( serial.checked ) %]
277
                      [% IF ( delete ) %]
278
                         [% IF ( delete ) %]
278
                        [% IF serialsid.grep("${serial.serialid}").size %]
279
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" [% IF ( delete ) %] readonly [% END %] [% IF serialsid.grep("${serial.serialid}").size %] checked [% END %] />
279
                          <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" disabled checked />
280
                         [% ELSE %]
280
                        [% ELSE %]
281
                            <input type="checkbox" class="checkboxed" name="serialid" checked="checked" value="[% serial.serialid %]" />
281
                          <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" disabled />
282
                         [% END %]
282
                        [% END %]
283
                      [% ELSE %]
283
                      [% ELSE %]
284
                         [% IF ( delete ) %]
284
                        <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" />
285
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" [% IF ( delete ) %] readonly [% END %] [% IF serialsid.grep("${serial.serialid}").size %] checked [% END %] />
286
                         [% ELSE %]
287
                            <input type="checkbox" class="checkboxed" name="serialid" value="[% serial.serialid %]" />
288
                         [% END %]
289
                      [% END %]
285
                      [% END %]
290
                    [% END %]
286
                    [% END %]
291
                  [% END %]
287
                  [% END %]
(-)a/serials/serials-collection.pl (+1 lines)
Lines 29-34 use C4::Items; Link Here
29
use C4::Letters;
29
use C4::Letters;
30
use C4::Output;
30
use C4::Output;
31
use C4::Context;
31
use C4::Context;
32
use Koha::Serials;
32
33
33
use List::MoreUtils qw/uniq/;
34
use List::MoreUtils qw/uniq/;
34
35
(-)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 374-398 subtest "Test GetSerialItemsInformations " => sub { Link Here
374
        AddItem2Serial($serialid[0],$itemnumber1);
373
        AddItem2Serial($serialid[0],$itemnumber1);
375
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
374
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
376
        is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item");
375
        is (scalar @result, 1 , "GetSerialItemsInformation return right length of array using 1 serial with 1 item");
377
        is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
376
        is ($result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
378
        AddItem2Serial($serialid[1],$itemnumber3);
377
        AddItem2Serial($serialid[1],$itemnumber3);
379
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
378
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
380
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 1 item");
379
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 1 item");
381
        is (@result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
380
        is ($result[0]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial1");
382
        is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
381
        is ($result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
383
    };
382
    };
384
    subtest "Test with 2 serials and each have 2 items" => sub {
383
    subtest "Test with 2 serials and each have 2 items" => sub {
385
        plan tests => 6;
384
        plan tests => 6;
386
        AddItem2Serial($serialid[0],$itemnumber2);
385
        AddItem2Serial($serialid[0],$itemnumber2);
387
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
386
        my @result = C4::Serials::GetSerialItemsInformations(@serialid);
388
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials ");
387
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials ");
389
        is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
388
        is ($result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
390
        is (@result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
389
        is ($result[1]->{countitems}, 1 , "GetSerialItemsInformation return right number items of serial2");
391
        AddItem2Serial($serialid[1],$itemnumber4);
390
        AddItem2Serial($serialid[1],$itemnumber4);
392
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
391
        @result = C4::Serials::GetSerialItemsInformations(@serialid);
393
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items ");
392
        is (scalar @result, 2 , "GetSerialItemsInformation return right length of array using 2 serials and each have 2 items ");
394
        is (@result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
393
        is ($result[0]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial1");
395
        is (@result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2");
394
        is ($result[1]->{countitems}, 2 , "GetSerialItemsInformation return right number items of serial2");
396
    };
395
    };
397
};
396
};
398
397
399
- 

Return to bug 17674