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

(-)a/cataloguing/additem.pl (-13 / +48 lines)
Lines 22-49 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 Koha::SearchEngine::Indexer;
48
use Koha::SearchEngine::Indexer;
39
use List::MoreUtils qw/any/;
40
use C4::Search;
41
use Storable qw(thaw freeze);
42
use URI::Escape;
43
use C4::Members;
44
45
use MARC::File::XML;
46
use URI::Escape;
47
49
48
our $dbh = C4::Context->dbh;
50
our $dbh = C4::Context->dbh;
49
51
Lines 87-92 sub set_item_default_location { Link Here
87
    $item->store;
89
    $item->store;
88
}
90
}
89
91
92
sub add_item_to_volume {
93
    my ( $biblionumber, $itemnumber, $volume, $volume_description ) = @_;
94
95
    return unless $volume;
96
97
    my $volume_id;
98
    if ( $volume eq 'create' ) {
99
        my $volume = Koha::Biblio::Volume->new(
100
            {
101
                biblionumber => $biblionumber,
102
                description  => $volume_description,
103
            }
104
        )->store();
105
106
        $volume_id = $volume->id;
107
    }
108
    else {
109
        $volume_id = $volume;
110
    }
111
112
    my $volume_item = Koha::Biblio::Volume::Item->new(
113
        {
114
            itemnumber => $itemnumber,
115
            volume_id  => $volume_id,
116
        }
117
    )->store();
118
}
119
90
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
120
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
91
# NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
121
# NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
92
sub _increment_barcode {
122
sub _increment_barcode {
Lines 419-424 my $fa_barcode = $input->param('barcode'); Link Here
419
my $fa_branch             = $input->param('branch');
449
my $fa_branch             = $input->param('branch');
420
my $fa_stickyduedate      = $input->param('stickyduedate');
450
my $fa_stickyduedate      = $input->param('stickyduedate');
421
my $fa_duedatespec        = $input->param('duedatespec');
451
my $fa_duedatespec        = $input->param('duedatespec');
452
my $volume                = $input->param('volume');
453
my $volume_description    = $input->param('volume_description');
422
454
423
my $frameworkcode = &GetFrameworkCode($biblionumber);
455
my $frameworkcode = &GetFrameworkCode($biblionumber);
424
456
Lines 527-532 if ($op eq "additem") { Link Here
527
        unless ($exist_itemnumber) {
559
        unless ($exist_itemnumber) {
528
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
560
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
529
            set_item_default_location($oldbibitemnum);
561
            set_item_default_location($oldbibitemnum);
562
            add_item_to_volume( $oldbiblionumber, $oldbibitemnum, $volume, $volume_description );
530
563
531
            # Pushing the last created item cookie back
564
            # Pushing the last created item cookie back
532
            if ($prefillitem && defined $record) {
565
            if ($prefillitem && defined $record) {
Lines 627-632 if ($op eq "additem") { Link Here
627
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
660
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
628
                AddItemFromMarc( $record, $biblionumber, { skip_record_index => 1 } );
661
                AddItemFromMarc( $record, $biblionumber, { skip_record_index => 1 } );
629
            set_item_default_location($oldbibitemnum);
662
            set_item_default_location($oldbibitemnum);
663
            add_item_to_volume( $oldbiblionumber, $oldbibitemnum, $volume, $volume_description );
630
664
631
            # We count the item only if it was really added
665
            # We count the item only if it was really added
632
            # 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 997-1002 foreach my $tag ( keys %{$tagslib}){ Link Here
997
1031
998
# 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.
999
$template->param(
1033
$template->param(
1034
    volumes      => scalar Koha::Biblio::Volumes->search({ biblionumber => $biblionumber }),
1000
    biblionumber => $biblionumber,
1035
    biblionumber => $biblionumber,
1001
    title        => $oldrecord->{title},
1036
    title        => $oldrecord->{title},
1002
    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 230-235 Link Here
230
    <input type="hidden" name="indicator" value=" " />
233
    <input type="hidden" name="indicator" value=" " />
231
    <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
234
    <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
232
235
236
[% IF volumes.count && op != 'saveitem' %]
237
    <fieldset class="rows">
238
        <legend><i class="fa fa-plus"></i> Add to volume</legend>
239
240
        <p>
241
            <label for="select_volume">Options: </label>
242
            <select name="volume" id="volume-add-or-create-form-select">
243
                <optgroup label="Use existing volume">
244
                    [% FOREACH v IN volumes %]
245
                        <option value="[% v.id | html %]">Use: [% v.description | html %]</option>
246
                    [% END %]
247
                </optgroup>
248
                <optgroup label="Other options">
249
                    <option id="volume-add-or-create-form-no-add" value="">Do not add to volume</option>
250
                    <option value="create">Create new volume</option>
251
                </optgroup>
252
            </select>
253
        </p>
254
255
        <p id="volume-add-or-create-form-description-block">
256
            <label for="volume_description" class="required">Name: </label>
257
            <input name="volume_description" id="volume-add-or-create-form-description" type="text" size="30" class="required" />
258
            <span class="required">Required</span>
259
        </p>
260
    </fieldset>
261
[% END %]
262
233
<fieldset class="action">    [% IF op != 'saveitem' %]
263
<fieldset class="action">    [% IF op != 'saveitem' %]
234
    <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
264
    <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
235
    <!-- 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
265
    <!-- 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