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

(-)a/Koha/Template/Plugin/Item.pm (+43 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Item;
2
3
# Copyright PTFS EUROPE 2024
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use Koha::Items;
26
27
=head1 METHODS
28
29
=head2 HasSerialItem
30
31
Checks whether a particular item has an associated serial item
32
33
=cut
34
35
sub HasSerialItem {
36
    my ( $self, $itemnumber ) = @_;
37
38
    my $serial_item = Koha::Items->find($itemnumber)->serial_item;
39
40
    return $serial_item ? 1 : 0;
41
}
42
43
1;
(-)a/cataloguing/additem.pl (+8 lines)
Lines 508-513 if ($op eq "cud-additem") { Link Here
508
    my $item = Koha::Items->find($itemnumber);
508
    my $item = Koha::Items->find($itemnumber);
509
    my $deleted;
509
    my $deleted;
510
    if( $item ) {
510
    if( $item ) {
511
        if ( $input->param('delete-serial-issues') ) {
512
            my $serial_item = $item->serial_item;
513
            my $serial      = Koha::Serials->find( $serial_item->serialid );
514
515
            $serial->delete;
516
            $serial_item->delete;
517
        }
518
511
        $deleted = $item->safe_delete;
519
        $deleted = $item->safe_delete;
512
    } else {
520
    } else {
513
        $deleted = Koha::Result::Boolean->new(0)->add_message({ message => 'item_not_found' });
521
        $deleted = Koha::Result::Boolean->new(0)->add_message({ message => 'item_not_found' });
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/delete_item_confirmation.inc (+30 lines)
Line 0 Link Here
1
[% USE Item %]
2
3
<!-- delete_item_confirmation.inc -->
4
    <!-- Item deletion confirmation dialog -->
5
    <div class="modal fade" id="delete-item-modal" tabindex="-1" role="dialog" aria-labelledby="claims-returned-modal-label">
6
        <div class="modal-dialog" role="document">
7
            <div class="modal-content">
8
                <div class="modal-header">
9
                    <h4 class="modal-title" id="delete-item-modal-label">Delete item</h4>
10
                </div>
11
                <div class="modal-body">
12
                    <h5 style="margin-bottom: 15px;">Are you sure you want to delete this item?</h5>
13
14
                    <div class="form-group">
15
                        <div class="checkbox">
16
                            <label for="delete_associated_serial_issues">
17
                            <input id="delete_associated_serial_issues" type="checkbox" value="1">
18
                                Delete serial issues linked to item
19
                            </label>
20
                        </div>
21
                    </div>
22
                    <input type="hidden" id="delete-item-itemnumber" />
23
                </div>
24
                <div class="modal-footer">
25
                    <button id="delete-item-modal-btn-submit" type="button" class="btn btn-primary"><i class="fa fa-exclamation-circle"></i> Delete item</button>
26
                    <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> Cancel</button>
27
                </div>
28
            </div>
29
        </div>
30
    </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +4 lines)
Lines 4-9 Link Here
4
[% USE Branches %]
4
[% USE Branches %]
5
[% USE KohaDates %]
5
[% USE KohaDates %]
6
[% USE Price %]
6
[% USE Price %]
7
[% USE Item %]
7
[% USE TablesSettings %]
8
[% USE TablesSettings %]
8
[% PROCESS 'i18n.inc' %]
9
[% PROCESS 'i18n.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
[% INCLUDE 'doc-head-open.inc' %]
Lines 143-150 Link Here
143
                                            <input type="hidden" name="biblionumber" value="[% item.biblionumber | html %]" />
144
                                            <input type="hidden" name="biblionumber" value="[% item.biblionumber | html %]" />
144
                                            <input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" />
145
                                            <input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" />
145
                                            <input type="hidden" name="searchid" value="[% searchid | html %]" />
146
                                            <input type="hidden" name="searchid" value="[% searchid | html %]" />
147
                                            <input type="hidden" name="delete-serial-issues" id="[% item.itemnumber | html %]-delete-serial-issues" value="" />
146
                                        </form>
148
                                        </form>
147
                                        <a class="delete" data-item="[% item.itemnumber | html %]" href="#">Delete</a>
149
                                        <a class="delete" data-itemnumber="[% item.itemnumber | html %]" data-has-serial-item="[% Item.HasSerialItem(item.itemnumber) | html %]" href="#">Delete</a>
148
                                    </li>
150
                                    </li>
149
                                [% END %]
151
                                [% END %]
150
                            [% END %]
152
                            [% END %]
Lines 373-378 Link Here
373
    </form>
375
    </form>
374
376
375
    [% INCLUDE 'modals/cataloguing_create_av.inc' %]
377
    [% INCLUDE 'modals/cataloguing_create_av.inc' %]
378
    [% INCLUDE 'modals/delete_item_confirmation.inc' %]
376
379
377
                            </div> <!-- /#cataloguing_additem_newitem -->
380
                            </div> <!-- /#cataloguing_additem_newitem -->
378
                        </div> <!-- /.col-sm-10 -->
381
                        </div> <!-- /.col-sm-10 -->
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js (-4 / +20 lines)
Lines 134-143 $(document).ready(function(){ Link Here
134
134
135
    $(document).on('click', '.delete', function(e) {
135
    $(document).on('click', '.delete', function(e) {
136
        e.preventDefault();
136
        e.preventDefault();
137
        if (confirmDelete(MSG_CONFIRM_DELETE_ITEM)) {
137
        var itemnumber = $(this).data('itemnumber');
138
            return $("#" + $(this).data("item") + "-delete-item-form").submit();
138
        var hasSerialItem = $(this).data('has-serial-item');
139
140
        $('#delete-item-itemnumber').val(itemnumber);
141
        $('#delete_associated_serial_issues').attr('checked', false);
142
        $('#delete-item-modal-btn-submit').data("item", itemnumber);
143
        if(!hasSerialItem) {
144
            $('.form-group').hide()
139
        }
145
        }
140
    }) ;
146
        $('#delete-item-modal').modal();
147
    });
148
    $(document).on('click', '#delete-item-modal-btn-submit', function(e) {
149
        e.preventDefault();
150
        var itemnumber = $('#delete-item-itemnumber').val();
151
        var deleteSerialIssues = $('#delete_associated_serial_issues').prop('checked') ? true : false;
152
        $('#delete-item-modal').modal('hide');
153
        if(deleteSerialIssues) {
154
            $('#' + itemnumber + '-delete-serial-issues').val('1');
155
        }
156
        return $("#" + $(this).data("item") + "-delete-item-form").submit();
157
    });
141
});
158
});
142
159
143
function CheckTemplateForm(f) {
160
function CheckTemplateForm(f) {
144
- 

Return to bug 37115