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

(-)a/cataloguing/additem.pl (-14 / +49 lines)
Lines 22-50 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 MIME::Base64 qw(decode_base64url encode_base64url);
28
use Storable qw(thaw freeze);
29
use URI::Escape;
30
25
use C4::Auth;
31
use C4::Auth;
26
use C4::Output;
27
use C4::Biblio;
32
use C4::Biblio;
28
use C4::Items;
29
use C4::Context;
30
use C4::Circulation;
33
use C4::Circulation;
31
use C4::Koha;
32
use C4::ClassSource;
34
use C4::ClassSource;
35
use C4::Context;
36
use C4::Items;
37
use C4::Koha;
38
use C4::Members;
39
use C4::Output;
40
use C4::Search;
41
42
use Koha::Biblio::Volume::Items;
43
use Koha::Biblio::Volumes;
33
use Koha::DateUtils;
44
use Koha::DateUtils;
34
use Koha::Items;
35
use Koha::ItemTypes;
45
use Koha::ItemTypes;
46
use Koha::Items;
36
use Koha::Libraries;
47
use Koha::Libraries;
37
use Koha::Patrons;
48
use Koha::Patrons;
38
use Koha::SearchEngine::Indexer;
49
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
use MIME::Base64 qw(decode_base64url encode_base64url);
48
50
49
our $dbh = C4::Context->dbh;
51
our $dbh = C4::Context->dbh;
50
52
Lines 74-79 sub get_item_from_barcode { Link Here
74
    return($result);
76
    return($result);
75
}
77
}
76
78
79
sub add_item_to_volume {
80
    my ( $biblionumber, $itemnumber, $volume, $volume_description ) = @_;
81
82
    return unless $volume;
83
84
    my $volume_id;
85
    if ( $volume eq 'create' ) {
86
        my $volume = Koha::Biblio::Volume->new(
87
            {
88
                biblionumber => $biblionumber,
89
                description  => $volume_description,
90
            }
91
        )->store();
92
93
        $volume_id = $volume->id;
94
    }
95
    else {
96
        $volume_id = $volume;
97
    }
98
99
    my $volume_item = Koha::Biblio::Volume::Item->new(
100
        {
101
            itemnumber => $itemnumber,
102
            volume_id  => $volume_id,
103
        }
104
    )->store();
105
}
106
77
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
107
# NOTE: This code is subject to change in the future with the implemenation of ajax based autobarcode code
78
# NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
108
# NOTE: 'incremental' is the ONLY autoBarcode option available to those not using javascript
79
sub _increment_barcode {
109
sub _increment_barcode {
Lines 412-417 my $fa_barcode = $input->param('barcode'); Link Here
412
my $fa_branch             = $input->param('branch');
442
my $fa_branch             = $input->param('branch');
413
my $fa_stickyduedate      = $input->param('stickyduedate');
443
my $fa_stickyduedate      = $input->param('stickyduedate');
414
my $fa_duedatespec        = $input->param('duedatespec');
444
my $fa_duedatespec        = $input->param('duedatespec');
445
my $volume                = $input->param('volume');
446
my $volume_description    = $input->param('volume_description');
415
447
416
my $frameworkcode = &GetFrameworkCode($biblionumber);
448
my $frameworkcode = &GetFrameworkCode($biblionumber);
417
449
Lines 519-524 if ($op eq "additem") { Link Here
519
        # if barcode exists, don't create, but report The problem.
551
        # if barcode exists, don't create, but report The problem.
520
        unless ($exist_itemnumber) {
552
        unless ($exist_itemnumber) {
521
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
553
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) = AddItemFromMarc( $record, $biblionumber );
554
            add_item_to_volume( $oldbiblionumber, $oldbibitemnum, $volume, $volume_description );
522
555
523
            # Pushing the last created item cookie back
556
            # Pushing the last created item cookie back
524
            if ($prefillitem && defined $record) {
557
            if ($prefillitem && defined $record) {
Lines 618-623 if ($op eq "additem") { Link Here
618
        if (!$exist_itemnumber) {
651
        if (!$exist_itemnumber) {
619
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
652
            my ( $oldbiblionumber, $oldbibnum, $oldbibitemnum ) =
620
                AddItemFromMarc( $record, $biblionumber, { skip_record_index => 1 } );
653
                AddItemFromMarc( $record, $biblionumber, { skip_record_index => 1 } );
654
                add_item_to_volume( $oldbiblionumber, $oldbibitemnum, $volume, $volume_description );
621
655
622
            # We count the item only if it was really added
656
            # We count the item only if it was really added
623
            # That way, all items are added, even if there was some already existing barcodes
657
            # That way, all items are added, even if there was some already existing barcodes
Lines 988-993 foreach my $tag ( keys %{$tagslib}){ Link Here
988
1022
989
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
1023
# what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit.
990
$template->param(
1024
$template->param(
1025
    volumes      => scalar Koha::Biblio::Volumes->search({ biblionumber => $biblionumber }),
991
    biblionumber => $biblionumber,
1026
    biblionumber => $biblionumber,
992
    title        => $oldrecord->{title},
1027
    title        => $oldrecord->{title},
993
    author       => $oldrecord->{author},
1028
    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