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

(-)a/cataloguing/additem.pl (+35 lines)
Lines 39-44 use C4::Barcodes::ValueBuilder; Link Here
39
use Koha::DateUtils qw( dt_from_string );
39
use Koha::DateUtils qw( dt_from_string );
40
use Koha::Items;
40
use Koha::Items;
41
use Koha::ItemTypes;
41
use Koha::ItemTypes;
42
use Koha::Items;
42
use Koha::Libraries;
43
use Koha::Libraries;
43
use Koha::Patrons;
44
use Koha::Patrons;
44
use Koha::SearchEngine::Indexer;
45
use Koha::SearchEngine::Indexer;
Lines 57-62 use List::MoreUtils qw( any uniq ); Link Here
57
58
58
our $dbh = C4::Context->dbh;
59
our $dbh = C4::Context->dbh;
59
60
61
sub add_item_to_volume {
62
    my ( $biblionumber, $itemnumber, $volume, $volume_description ) = @_;
63
64
    return unless $volume;
65
66
    my $volume_id;
67
    if ( $volume eq 'create' ) {
68
        my $volume = Koha::Biblio::ItemGroup->new(
69
            {
70
                biblionumber => $biblionumber,
71
                description  => $volume_description,
72
            }
73
        )->store();
74
75
        $volume_id = $volume->id;
76
    }
77
    else {
78
        $volume_id = $volume;
79
    }
80
81
    my $volume_item = Koha::Biblio::ItemGroup::Item->new(
82
        {
83
            itemnumber => $itemnumber,
84
            volume_id  => $volume_id,
85
        }
86
    )->store();
87
}
88
60
sub get_item_from_cookie {
89
sub get_item_from_cookie {
61
    my ( $input ) = @_;
90
    my ( $input ) = @_;
62
91
Lines 102-107 my $fa_barcode = $input->param('barcode'); Link Here
102
my $fa_branch             = $input->param('branch');
131
my $fa_branch             = $input->param('branch');
103
my $fa_stickyduedate      = $input->param('stickyduedate');
132
my $fa_stickyduedate      = $input->param('stickyduedate');
104
my $fa_duedatespec        = $input->param('duedatespec');
133
my $fa_duedatespec        = $input->param('duedatespec');
134
my $volume                = $input->param('volume');
135
my $volume_description    = $input->param('volume_description');
105
136
106
our $frameworkcode = &GetFrameworkCode($biblionumber);
137
our $frameworkcode = &GetFrameworkCode($biblionumber);
107
138
Lines 206-211 if ($op eq "additem") { Link Here
206
        }
237
        }
207
        else {
238
        else {
208
            $item->store->discard_changes;
239
            $item->store->discard_changes;
240
            add_item_to_volume( $item->biblionumber, $item->biblioitemnumber, $volume, $volume_description );
209
241
210
            # This is a bit tricky : if there is a cookie for the last created item and
242
            # This is a bit tricky : if there is a cookie for the last created item and
211
            # we just added an item, the cookie value is not correct yet (it will be updated
243
            # we just added an item, the cookie value is not correct yet (it will be updated
Lines 316-321 if ($op eq "additem") { Link Here
316
                        { skip_record_index => 1 } );
348
                        { skip_record_index => 1 } );
317
                    $current_item->discard_changes; # Cannot chain discard_changes
349
                    $current_item->discard_changes; # Cannot chain discard_changes
318
                    $current_item = $current_item->unblessed;
350
                    $current_item = $current_item->unblessed;
351
                    add_item_to_volume( $item->biblionumber, $item->biblioitemnumber, $volume, $volume_description );
319
352
320
# We count the item only if it was really added
353
# We count the item only if it was really added
321
# That way, all items are added, even if there was some already existing barcodes
354
# That way, all items are added, even if there was some already existing barcodes
Lines 606-615 if( my $default_location = C4::Context->preference('NewItemsDefaultLocation') ) Link Here
606
    $location_field->{marc_value}->{value} ||= $default_location;
639
    $location_field->{marc_value}->{value} ||= $default_location;
607
}
640
}
608
641
642
my @ig = Koha::Biblio::ItemGroups->search({ biblio_id => $biblionumber })->as_list();
609
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
643
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
610
$template->param(
644
$template->param(
611
    biblio       => $biblio,
645
    biblio       => $biblio,
612
    items        => \@items,
646
    items        => \@items,
647
    item_groups      => \@ig,
613
    item_header_loop => \@header_value_loop,
648
    item_header_loop => \@header_value_loop,
614
    subfields        => $subfields,
649
    subfields        => $subfields,
615
    itemnumber       => $itemnumber,
650
    itemnumber       => $itemnumber,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (+35 lines)
Lines 23-28 Link Here
23
[% INCLUDE 'calendar.inc' %]
23
[% INCLUDE 'calendar.inc' %]
24
[% INCLUDE 'str/cataloging_additem.inc' %]
24
[% INCLUDE 'str/cataloging_additem.inc' %]
25
[% Asset.js("js/cataloging_additem.js") | $raw %]
25
[% Asset.js("js/cataloging_additem.js") | $raw %]
26
    <script>
27
      var has_item_groups = "[% item_groups.size | html %]";
28
    </script>
26
</head>
29
</head>
27
30
28
<body id="cat_additem" class="cat">
31
<body id="cat_additem" class="cat">
Lines 159-164 Link Here
159
        <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
162
        <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
160
    [% END %]
163
    [% END %]
161
164
165
[% IF item_groups.size && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %]
166
    <fieldset class="rows">
167
        <legend><i class="fa fa-plus"></i> Add to item group</legend>
168
        [% FOREACH ig IN item_groups %]
169
            <input type="hidden" id="item-group-[% ig.id | html %]" value="[% ig.description | html %]" />
170
        [% END %]
171
        <p>
172
            <label for="select_item_group">Options: </label>
173
            <select name="item_group" id="item-group-add-or-create-form-select">
174
                <optgroup label="Use existing item group">
175
                    [% FOREACH ig IN item_groups %]
176
                        <option value="[% ig.id | html %]">Use: [% ig.description | html %]</option>
177
                    [% END %]
178
                </optgroup>
179
                <optgroup label="Other options">
180
                    <option id="item-group-add-or-create-form-no-add" value="">Do not add to item group</option>
181
                    <option value="create">Create new item group</option>
182
                </optgroup>
183
            </select>
184
        </p>
185
186
        <p id="item-group-add-or-create-form-description-block">
187
            <label for="item_group_description" class="required">Name: </label>
188
            <input name="item_group_description" id="item-group-add-or-create-form-description" type="text" size="30" class="required" />
189
            <span class="required">Required</span>
190
        </p>
191
    </fieldset>
192
[% END %]
193
162
<fieldset class="action">    [% IF op != 'saveitem' %]
194
<fieldset class="action">    [% IF op != 'saveitem' %]
163
    <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
195
    <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
164
    <!-- Note : We use here a false submit button because we have several submit buttons and we don't want the user to believe they validated the adding of multiple items
196
    <!-- Note : We use here a false submit button because we have several submit buttons and we don't want the user to believe they validated the adding of multiple items
Lines 208-211 Link Here
208
        </div> <!-- /.col-sm-12 -->
240
        </div> <!-- /.col-sm-12 -->
209
    </div> <!-- /.row -->
241
    </div> <!-- /.row -->
210
242
243
[% MACRO jsinclude BLOCK %]
244
[% END %]
245
211
[% INCLUDE 'intranet-bottom.inc' %]
246
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js (-1 / +27 lines)
Lines 69-74 $(document).ready(function(){ Link Here
69
        multiCopyControl.toggle();
69
        multiCopyControl.toggle();
70
    });
70
    });
71
71
72
    // Add new item to an item group
73
    if ( has_item_groups ) {
74
        $('#item-group-add-or-create-form-description-block').hide();
75
        $('#item-group-add-or-create-form-no-add').attr('selected', 'selected' );
76
77
        $('#item-group-add-or-create-form-select').on('change', function(){
78
            if ( $(this).val() == 'create' ) {
79
                $('#item-group-add-or-create-form-description')
80
                    .addClass('required')
81
                    .attr( 'required', 'required' );
82
                $('#item-group-add-or-create-form-description-block').show();
83
            } else {
84
                $('#item-group-add-or-create-form-description')
85
                    .removeClass('required')
86
                    .removeAttr('required');
87
                $('#item-group-add-or-create-form-description-block').hide();
88
            }
89
        });
90
    }
91
92
    $('#item-group-add-or-create-form-select').on('change', function() {
93
        if ( ! $('input.items-enumchron').val() ) {
94
            let item_group_selector = '#item-group-' + $(this).val();
95
            let enumchron = $(item_group_selector).val();
96
            $('input.items-enumchron').val( enumchron );
97
        }
98
    });
72
});
99
});
73
100
74
function Check(f) {
101
function Check(f) {
75
- 

Return to bug 24857