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

(-)a/cataloguing/additem.pl (+34 lines)
Lines 43-48 use C4::ClassSource qw( GetClassSources GetClassSource ); Link Here
43
use Koha::DateUtils qw( dt_from_string );
43
use Koha::DateUtils qw( dt_from_string );
44
use Koha::Items;
44
use Koha::Items;
45
use Koha::ItemTypes;
45
use Koha::ItemTypes;
46
use Koha::Items;
46
use Koha::Libraries;
47
use Koha::Libraries;
47
use Koha::Patrons;
48
use Koha::Patrons;
48
use Koha::SearchEngine::Indexer;
49
use Koha::SearchEngine::Indexer;
Lines 84-89 sub get_item_from_barcode { Link Here
84
    return($result);
85
    return($result);
85
}
86
}
86
87
88
sub add_item_to_volume {
89
    my ( $biblionumber, $itemnumber, $volume, $volume_description ) = @_;
90
91
    return unless $volume;
92
93
    my $volume_id;
94
    if ( $volume eq 'create' ) {
95
        my $volume = Koha::Biblio::Volume->new(
96
            {
97
                biblionumber => $biblionumber,
98
                description  => $volume_description,
99
            }
100
        )->store();
101
102
        $volume_id = $volume->id;
103
    }
104
    else {
105
        $volume_id = $volume;
106
    }
107
108
    my $volume_item = Koha::Biblio::Volume::Item->new(
109
        {
110
            itemnumber => $itemnumber,
111
            volume_id  => $volume_id,
112
        }
113
    )->store();
114
}
115
87
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
116
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
88
# NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
117
# NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
89
sub _increment_barcode {
118
sub _increment_barcode {
Lines 423-428 my $fa_barcode = $input->param('barcode'); Link Here
423
my $fa_branch             = $input->param('branch');
452
my $fa_branch             = $input->param('branch');
424
my $fa_stickyduedate      = $input->param('stickyduedate');
453
my $fa_stickyduedate      = $input->param('stickyduedate');
425
my $fa_duedatespec        = $input->param('duedatespec');
454
my $fa_duedatespec        = $input->param('duedatespec');
455
my $volume                = $input->param('volume');
456
my $volume_description    = $input->param('volume_description');
426
457
427
my $frameworkcode = &GetFrameworkCode($biblionumber);
458
my $frameworkcode = &GetFrameworkCode($biblionumber);
428
459
Lines 529-534 if ($op eq "additem") { Link Here
529
        # if barcode exists, don't create, but report The problem.
560
        # if barcode exists, don't create, but report The problem.
530
        unless ($exist_itemnumber) {
561
        unless ($exist_itemnumber) {
531
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
562
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
563
            add_item_to_volume( $oldbiblionumber, $oldbibitemnum, $volume, $volume_description );
532
564
533
            # Pushing the last created item cookie back
565
            # Pushing the last created item cookie back
534
            if ($prefillitem && defined $record) {
566
            if ($prefillitem && defined $record) {
Lines 628-633 if ($op eq "additem") { Link Here
628
        if (!$exist_itemnumber) {
660
        if (!$exist_itemnumber) {
629
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
661
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
630
                AddItemFromMarc( $record, $biblionumber, { skip_record_index => 1 } );
662
                AddItemFromMarc( $record, $biblionumber, { skip_record_index => 1 } );
663
                add_item_to_volume( $oldbiblionumber, $oldbibitemnum, $volume, $volume_description );
631
664
632
            # We count the item only if it was really added
665
            # We count the item only if it was really added
633
            # That way, all items are added, even if there was some already existing barcodes
666
            # That way, all items are added, even if there was some already existing barcodes
Lines 998-1003 foreach my $tag ( keys %{$tagslib}){ Link Here
998
1031
999
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
1032
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
1000
$template->param(
1033
$template->param(
1034
    volumes      => scalar Koha::Biblio::Volumes->search({ biblionumber => $biblionumber }),
1001
    biblionumber => $biblionumber,
1035
    biblionumber => $biblionumber,
1002
    title        => $oldrecord->{title},
1036
    title        => $oldrecord->{title},
1003
    author       => $oldrecord->{author},
1037
    author       => $oldrecord->{author},
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (+30 lines)
Lines 18-23 Link Here
18
[% INCLUDE 'calendar.inc' %]
18
[% INCLUDE 'calendar.inc' %]
19
[% INCLUDE 'str/cataloging_additem.inc' %]
19
[% INCLUDE 'str/cataloging_additem.inc' %]
20
[% Asset.js("js/cataloging_additem.js") | $raw %]
20
[% Asset.js("js/cataloging_additem.js") | $raw %]
21
<script>
22
  var has_volumes = [% volumes.count %];
23
</script>
21
</head>
24
</head>
22
25
23
<body id="cat_additem" class="cat">
26
<body id="cat_additem" class="cat">
Lines 238-243 Link Here
238
    <input type="hidden" name="indicator" value=" " />
241
    <input type="hidden" name="indicator" value=" " />
239
    <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
242
    <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
240
243
244
[% IF volumes.count && op != 'saveitem' %]
245
    <fieldset class="rows">
246
        <legend><i class="fa fa-plus"></i> Add to volume</legend>
247
248
        <p>
249
            <label for="select_volume">Options: </label>
250
            <select name="volume" id="volume-add-or-create-form-select">
251
                <optgroup label="Use existing volume">
252
                    [% FOREACH v IN volumes %]
253
                        <option value="[% v.id | html %]">Use: [% v.description | html %]</option>
254
                    [% END %]
255
                </optgroup>
256
                <optgroup label="Other options">
257
                    <option id="volume-add-or-create-form-no-add" value="">Do not add to volume</option>
258
                    <option value="create">Create new volume</option>
259
                </optgroup>
260
            </select>
261
        </p>
262
263
        <p id="volume-add-or-create-form-description-block">
264
            <label for="volume_description" class="required">Name: </label>
265
            <input name="volume_description" id="volume-add-or-create-form-description" type="text" size="30" class="required" />
266
            <span class="required">Required</span>
267
        </p>
268
    </fieldset>
269
[% END %]
270
241
<fieldset class="action">    [% IF op != 'saveitem' %]
271
<fieldset class="action">    [% IF op != 'saveitem' %]
242
    <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
272
    <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
243
    <!-- 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
273
    <!-- 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
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js (-1 / +20 lines)
Lines 69-74 $(document).ready(function(){ Link Here
69
        multiCopyControl.toggle();
69
        multiCopyControl.toggle();
70
    });
70
    });
71
71
72
    // Add new item to volume
73
    if ( has_volumes ) {
74
        $('#volume-add-or-create-form-description-block').hide();
75
        $('#volume-add-or-create-form-no-add').attr('selected', 'selected' );
76
77
        $('#volume-add-or-create-form-select').on('change', function(){
78
            if ( $(this).val() == 'create' ) {
79
                $('#volume-add-or-create-form-description')
80
                    .addClass('required')
81
                    .attr( 'required', 'required' );
82
                $('#volume-add-or-create-form-description-block').show();
83
            } else {
84
                $('#volume-add-or-create-form-description')
85
                    .removeClass('required')
86
                    .removeAttr('required');
87
                $('#volume-add-or-create-form-description-block').hide();
88
            }
89
        });
90
    }
91
72
});
92
});
73
93
74
function Check(f) {
94
function Check(f) {
75
- 

Return to bug 24857