Bugzilla – Attachment 167847 Details for
Bug 37115
Add the option to delete linked serials when deleting items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37115: Delete linked serial when deleting a single item
Bug-37115-Delete-linked-serial-when-deleting-a-sin.patch (text/plain), 7.94 KB, created by
Matt Blenkinsop
on 2024-06-18 13:57:48 UTC
(
hide
)
Description:
Bug 37115: Delete linked serial when deleting a single item
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-06-18 13:57:48 UTC
Size:
7.94 KB
patch
obsolete
>From af799ba1622250f708b977aadb9a4c6ab0ec28f3 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Fri, 31 May 2024 16:31:24 +0000 >Subject: [PATCH] Bug 37115: Delete linked serial when deleting a single item > >--- > Koha/Template/Plugin/Item.pm | 43 +++++++++++++++++++ > cataloguing/additem.pl | 8 ++++ > .../modals/delete_item_confirmation.inc | 30 +++++++++++++ > .../prog/en/modules/cataloguing/additem.tt | 5 ++- > .../prog/js/cataloging_additem.js | 23 ++++++++-- > 5 files changed, 105 insertions(+), 4 deletions(-) > create mode 100644 Koha/Template/Plugin/Item.pm > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/modals/delete_item_confirmation.inc > >diff --git a/Koha/Template/Plugin/Item.pm b/Koha/Template/Plugin/Item.pm >new file mode 100644 >index 0000000000..784a95c516 >--- /dev/null >+++ b/Koha/Template/Plugin/Item.pm >@@ -0,0 +1,43 @@ >+package Koha::Template::Plugin::Item; >+ >+# Copyright PTFS EUROPE 2024 >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Template::Plugin; >+use base qw( Template::Plugin ); >+ >+use Koha::Items; >+ >+=head1 METHODS >+ >+=head2 HasSerialItem >+ >+Checks whether a particular item has an associated serial item >+ >+=cut >+ >+sub HasSerialItem { >+ my ( $self, $itemnumber ) = @_; >+ >+ my $serial_item = Koha::Items->find($itemnumber)->serial_item; >+ >+ return $serial_item ? 1 : 0; >+} >+ >+1; >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index b930565ce4..279de91077 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -508,6 +508,14 @@ if ($op eq "cud-additem") { > my $item = Koha::Items->find($itemnumber); > my $deleted; > if( $item ) { >+ if ( $input->param('delete-serial-issues') ) { >+ my $serial_item = $item->serial_item; >+ my $serial = Koha::Serials->find( $serial_item->serialid ); >+ >+ $serial->delete; >+ $serial_item->delete; >+ } >+ > $deleted = $item->safe_delete; > } else { > $deleted = Koha::Result::Boolean->new(0)->add_message({ message => 'item_not_found' }); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modals/delete_item_confirmation.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/delete_item_confirmation.inc >new file mode 100644 >index 0000000000..705ee18e28 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modals/delete_item_confirmation.inc >@@ -0,0 +1,30 @@ >+[% USE Item %] >+ >+<!-- delete_item_confirmation.inc --> >+ <!-- Item deletion confirmation dialog --> >+ <div class="modal fade" id="delete-item-modal" tabindex="-1" role="dialog" aria-labelledby="claims-returned-modal-label"> >+ <div class="modal-dialog" role="document"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h4 class="modal-title" id="delete-item-modal-label">Delete item</h4> >+ </div> >+ <div class="modal-body"> >+ <h5 style="margin-bottom: 15px;">Are you sure you want to delete this item?</h5> >+ >+ <div class="form-group"> >+ <div class="checkbox"> >+ <label for="delete_associated_serial_issues"> >+ <input id="delete_associated_serial_issues" type="checkbox" value="1"> >+ Delete serial issues linked to item >+ </label> >+ </div> >+ </div> >+ <input type="hidden" id="delete-item-itemnumber" /> >+ </div> >+ <div class="modal-footer"> >+ <button id="delete-item-modal-btn-submit" type="button" class="btn btn-primary"><i class="fa fa-exclamation-circle"></i> Delete item</button> >+ <button class="btn btn-default deny cancel" href="#" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> Cancel</button> >+ </div> >+ </div> >+ </div> >+ </div> >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index 87756e4819..fdb94c80d8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -4,6 +4,7 @@ > [% USE Branches %] > [% USE KohaDates %] > [% USE Price %] >+[% USE Item %] > [% USE TablesSettings %] > [% PROCESS 'i18n.inc' %] > [% INCLUDE 'doc-head-open.inc' %] >@@ -143,8 +144,9 @@ > <input type="hidden" name="biblionumber" value="[% item.biblionumber | html %]" /> > <input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" /> > <input type="hidden" name="searchid" value="[% searchid | html %]" /> >+ <input type="hidden" name="delete-serial-issues" id="[% item.itemnumber | html %]-delete-serial-issues" value="" /> > </form> >- <a class="delete" data-item="[% item.itemnumber | html %]" href="#">Delete</a> >+ <a class="delete" data-itemnumber="[% item.itemnumber | html %]" data-has-serial-item="[% Item.HasSerialItem(item.itemnumber) | html %]" href="#">Delete</a> > </li> > [% END %] > [% END %] >@@ -373,6 +375,7 @@ > </form> > > [% INCLUDE 'modals/cataloguing_create_av.inc' %] >+ [% INCLUDE 'modals/delete_item_confirmation.inc' %] > > </div> <!-- /#cataloguing_additem_newitem --> > </div> <!-- /.col-sm-10 --> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >index 06fc9137e5..a9e6cf955d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >@@ -134,10 +134,27 @@ $(document).ready(function(){ > > $(document).on('click', '.delete', function(e) { > e.preventDefault(); >- if (confirmDelete(MSG_CONFIRM_DELETE_ITEM)) { >- return $("#" + $(this).data("item") + "-delete-item-form").submit(); >+ var itemnumber = $(this).data('itemnumber'); >+ var hasSerialItem = $(this).data('has-serial-item'); >+ >+ $('#delete-item-itemnumber').val(itemnumber); >+ $('#delete_associated_serial_issues').attr('checked', false); >+ $('#delete-item-modal-btn-submit').data("item", itemnumber); >+ if(!hasSerialItem) { >+ $('.form-group').hide() > } >- }) ; >+ $('#delete-item-modal').modal(); >+ }); >+ $(document).on('click', '#delete-item-modal-btn-submit', function(e) { >+ e.preventDefault(); >+ var itemnumber = $('#delete-item-itemnumber').val(); >+ var deleteSerialIssues = $('#delete_associated_serial_issues').prop('checked') ? true : false; >+ $('#delete-item-modal').modal('hide'); >+ if(deleteSerialIssues) { >+ $('#' + itemnumber + '-delete-serial-issues').val('1'); >+ } >+ return $("#" + $(this).data("item") + "-delete-item-form").submit(); >+ }); > }); > > function CheckTemplateForm(f) { >-- >2.39.3 (Apple Git-146)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37115
:
167847
|
167848
|
168133
|
168134
|
168373
|
168374
|
168495
|
168496
|
168497
|
171208
|
171209
|
171210
|
171938
|
171939
|
171940
|
173256
|
173257
|
173258