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

(-)a/cataloguing/additem.pl (-13 / +48 lines)
Lines 22-48 Link Here
22
use Modern::Perl;
22
use Modern::Perl;
23
23
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use List::MoreUtils qw/any/;
26
use MARC::File::XML;
27
use Storable qw(thaw freeze);
28
use URI::Escape;
29
25
use C4::Auth;
30
use C4::Auth;
26
use C4::Output;
27
use C4::Biblio;
31
use C4::Biblio;
28
use C4::Items;
29
use C4::Context;
30
use C4::Circulation;
32
use C4::Circulation;
31
use C4::Koha;
32
use C4::ClassSource;
33
use C4::ClassSource;
34
use C4::Context;
35
use C4::Items;
36
use C4::Koha;
37
use C4::Members;
38
use C4::Output;
39
use C4::Search;
40
41
use Koha::Biblio::Volume::Items;
42
use Koha::Biblio::Volumes;
33
use Koha::DateUtils;
43
use Koha::DateUtils;
34
use Koha::Items;
35
use Koha::ItemTypes;
44
use Koha::ItemTypes;
45
use Koha::Items;
36
use Koha::Libraries;
46
use Koha::Libraries;
37
use Koha::Patrons;
47
use Koha::Patrons;
38
use List::MoreUtils qw/any/;
39
use C4::Search;
40
use Storable qw(thaw freeze);
41
use URI::Escape;
42
use C4::Members;
43
44
use MARC::File::XML;
45
use URI::Escape;
46
48
47
our $dbh = C4::Context->dbh;
49
our $dbh = C4::Context->dbh;
48
50
Lines 86-91 sub set_item_default_location { Link Here
86
    $item->store;
88
    $item->store;
87
}
89
}
88
90
91
sub add_item_to_volume {
92
    my ( $biblionumber, $itemnumber, $volume, $volume_description ) = @_;
93
94
    return unless $volume;
95
96
    my $volume_id;
97
    if ( $volume eq 'create' ) {
98
        my $volume = Koha::Biblio::Volume->new(
99
            {
100
                biblionumber => $biblionumber,
101
                description  => $volume_description,
102
            }
103
        )->store();
104
105
        $volume_id = $volume->id;
106
    }
107
    else {
108
        $volume_id = $volume;
109
    }
110
111
    my $volume_item = Koha::Biblio::Volume::Item->new(
112
        {
113
            itemnumber => $itemnumber,
114
            volume_id  => $volume_id,
115
        }
116
    )->store();
117
}
118
89
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
119
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
90
# NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
120
# NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
91
sub _increment_barcode {
121
sub _increment_barcode {
Lines 406-411 my $fa_barcode = $input->param('barcode'); Link Here
406
my $fa_branch             = $input->param('branch');
436
my $fa_branch             = $input->param('branch');
407
my $fa_stickyduedate      = $input->param('stickyduedate');
437
my $fa_stickyduedate      = $input->param('stickyduedate');
408
my $fa_duedatespec        = $input->param('duedatespec');
438
my $fa_duedatespec        = $input->param('duedatespec');
439
my $volume                = $input->param('volume');
440
my $volume_description    = $input->param('volume_description');
409
441
410
my $frameworkcode = &GetFrameworkCode($biblionumber);
442
my $frameworkcode = &GetFrameworkCode($biblionumber);
411
443
Lines 515-520 if ($op eq "additem") { Link Here
515
        unless ($exist_itemnumber) {
547
        unless ($exist_itemnumber) {
516
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
548
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
517
            set_item_default_location($oldbibitemnum);
549
            set_item_default_location($oldbibitemnum);
550
            add_item_to_volume( $oldbiblionumber, $oldbibitemnum, $volume, $volume_description );
518
551
519
            # Pushing the last created item cookie back
552
            # Pushing the last created item cookie back
520
            if ($prefillitem && defined $record) {
553
            if ($prefillitem && defined $record) {
Lines 615-620 if ($op eq "additem") { Link Here
615
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
648
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
616
                AddItemFromMarc( $record, $biblionumber, { skip_modzebra_update => 1 } );
649
                AddItemFromMarc( $record, $biblionumber, { skip_modzebra_update => 1 } );
617
            set_item_default_location($oldbibitemnum);
650
            set_item_default_location($oldbibitemnum);
651
            add_item_to_volume( $oldbiblionumber, $oldbibitemnum, $volume, $volume_description );
618
652
619
            # We count the item only if it was really added
653
            # We count the item only if it was really added
620
            # That way, all items are added, even if there was some already existing barcodes
654
            # That way, all items are added, even if there was some already existing barcodes
Lines 974-979 foreach my $tag ( keys %{$tagslib}){ Link Here
974
1008
975
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
1009
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
976
$template->param(
1010
$template->param(
1011
    volumes      => scalar Koha::Biblio::Volumes->search({ biblionumber => $biblionumber }),
977
    biblionumber => $biblionumber,
1012
    biblionumber => $biblionumber,
978
    title        => $oldrecord->{title},
1013
    title        => $oldrecord->{title},
979
    author       => $oldrecord->{author},
1014
    author       => $oldrecord->{author},
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (+30 lines)
Lines 16-21 Link Here
16
[% INCLUDE 'calendar.inc' %]
16
[% INCLUDE 'calendar.inc' %]
17
[% INCLUDE 'str/cataloging_additem.inc' %]
17
[% INCLUDE 'str/cataloging_additem.inc' %]
18
[% Asset.js("js/cataloging_additem.js") | $raw %]
18
[% Asset.js("js/cataloging_additem.js") | $raw %]
19
<script>
20
  var has_volumes = [% volumes.count %];
21
</script>
19
</head>
22
</head>
20
23
21
<body id="cat_additem" class="cat">
24
<body id="cat_additem" class="cat">
Lines 228-233 Link Here
228
    <input type="hidden" name="indicator" value=" " />
231
    <input type="hidden" name="indicator" value=" " />
229
    <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
232
    <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
230
233
234
[% IF volumes.count && op != 'saveitem' %]
235
    <fieldset class="rows">
236
        <legend><i class="fa fa-plus"></i> Add to volume</legend>
237
238
        <p>
239
            <label for="select_volume">Options: </label>
240
            <select name="volume" id="volume-add-or-create-form-select">
241
                <optgroup label="Use existing volume">
242
                    [% FOREACH v IN volumes %]
243
                        <option value="[% v.id | html %]">Use: [% v.description | html %]</option>
244
                    [% END %]
245
                </optgroup>
246
                <optgroup label="Other options">
247
                    <option id="volume-add-or-create-form-no-add" value="">Do not add to volume</option>
248
                    <option value="create">Create new volume</option>
249
                </optgroup>
250
            </select>
251
        </p>
252
253
        <p id="volume-add-or-create-form-description-block">
254
            <label for="volume_description" class="required">Name: </label>
255
            <input name="volume_description" id="volume-add-or-create-form-description" type="text" size="30" class="required" />
256
            <span class="required">Required</span>
257
        </p>
258
    </fieldset>
259
[% END %]
260
231
<fieldset class="action">    [% IF op != 'saveitem' %]
261
<fieldset class="action">    [% IF op != 'saveitem' %]
232
    <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
262
    <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
233
    <!-- 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
263
    <!-- 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 / +21 lines)
Lines 70-75 $(document).ready(function(){ Link Here
70
    });
70
    });
71
71
72
    $('.subfield_line select').select2();
72
    $('.subfield_line select').select2();
73
74
    // Add new item to volume
75
    if ( has_volumes ) {
76
        $('#volume-add-or-create-form-description-block').hide();
77
        $('#volume-add-or-create-form-no-add').attr('selected', 'selected' );
78
79
        $('#volume-add-or-create-form-select').on('change', function(){
80
            if ( $(this).val() == 'create' ) {
81
                $('#volume-add-or-create-form-description')
82
                    .addClass('required')
83
                    .attr( 'required', 'required' );
84
                $('#volume-add-or-create-form-description-block').show();
85
            } else {
86
                $('#volume-add-or-create-form-description')
87
                    .removeClass('required')
88
                    .removeAttr('required');
89
                $('#volume-add-or-create-form-description-block').hide();
90
            }
91
        });
92
    }
93
73
});
94
});
74
95
75
function Check(f) {
96
function Check(f) {
76
- 

Return to bug 24857