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

(-)a/Koha/Template/Plugin/ItemGroups.pm (-3 / +3 lines)
Lines 50-64 sub listGroups { Link Here
50
    );
50
    );
51
}
51
}
52
52
53
=head3 count
53
=head3 getCount
54
54
55
[% ItemGroups.count %]
55
[% ItemGroups.getCount %]
56
56
57
returns count of item groups on a particular bibliographic record
57
returns count of item groups on a particular bibliographic record
58
58
59
=cut
59
=cut
60
60
61
sub count {
61
sub getCount {
62
    my ( $self, $biblionumber ) = @_;
62
    my ( $self, $biblionumber ) = @_;
63
    return Koha::Biblio::ItemGroups->search(
63
    return Koha::Biblio::ItemGroups->search(
64
        { biblio_id => $biblionumber },
64
        { biblio_id => $biblionumber },
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-2 / +2 lines)
Lines 37-43 Link Here
37
[% INCLUDE 'str/cataloging_additem.inc' %]
37
[% INCLUDE 'str/cataloging_additem.inc' %]
38
[% Asset.js("js/cataloging_additem.js") | $raw %]
38
[% Asset.js("js/cataloging_additem.js") | $raw %]
39
    <script>
39
    <script>
40
        var has_item_groups = "[% ItemGroups.count(biblio.biblionumber) | html %]";
40
        var has_item_groups = "[% ItemGroups.getCount(biblio.biblionumber) | html %]";
41
    </script>
41
    </script>
42
</head>
42
</head>
43
43
Lines 250-256 Link Here
250
    [% IF op != 'add_item' %]
250
    [% IF op != 'add_item' %]
251
        <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
251
        <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
252
    [% END %]
252
    [% END %]
253
[% IF ItemGroups.count(biblio.biblionumber) && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %]
253
[% IF ItemGroups.getCount(biblio.biblionumber) && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %]
254
    <fieldset class="rows">
254
    <fieldset class="rows">
255
        <legend><i class="fa fa-plus"></i> Add to item group</legend>
255
        <legend><i class="fa fa-plus"></i> Add to item group</legend>
256
        [% FOREACH ig IN ItemGroups.listGroups(biblio.biblionumber) %]
256
        [% FOREACH ig IN ItemGroups.listGroups(biblio.biblionumber) %]
(-)a/t/db_dependent/Template/Plugin/ItemGroups.t (-1 / +57 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
17
use Modern::Perl;
18
19
use Test::More tests => 2;
20
21
use t::lib::TestBuilder;
22
use t::lib::Mocks;
23
use Koha::Biblio::ItemGroups;
24
use Koha::Template::Plugin::ItemGroups;
25
26
my $schema  = Koha::Database->schema;
27
my $builder = t::lib::TestBuilder->new;
28
29
$schema->storage->txn_begin;
30
31
ok( my $settings = Koha::Template::Plugin::ItemGroups->new(), 'Able to instantiate template plugin' );
32
33
subtest 'Item_Groups' => sub {
34
    plan tests => 2;
35
36
    my $biblio           = $builder->build_sample_biblio();
37
    my $item_group_count = Koha::Template::Plugin::ItemGroups->getCount( $biblio->id );
38
39
    is( $item_group_count, 0, '0 items correctly counted in the item group' );
40
41
    #Add some item groups to the bib
42
    my $item_group_1 =
43
        Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 2, description => "Vol 2" } )
44
        ->store();
45
    my $item_group_2 =
46
        Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 3, description => "Vol 3" } )
47
        ->store();
48
    my $item_group_3 =
49
        Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 1, description => "Vol 1" } )
50
        ->store();
51
52
    $item_group_count = Koha::Template::Plugin::ItemGroups->getCount( $biblio->id );
53
54
    is( $item_group_count, 3, '3 items correctly counted in the item group' );
55
};
56
57
$schema->storage->txn_rollback;

Return to bug 34234