Bugzilla – Attachment 176858 Details for
Bug 13870
Add warnings about subscriptions and orders when deleting items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13870: Add warn about linked order or/and subscription on batch item table
Bug-13870-Add-warn-about-linked-order-orand-subscr.patch (text/plain), 10.94 KB, created by
Thibaud Guillot (thibaud_g)
on 2025-01-21 12:43:50 UTC
(
hide
)
Description:
Bug 13870: Add warn about linked order or/and subscription on batch item table
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2025-01-21 12:43:50 UTC
Size:
10.94 KB
patch
obsolete
>From 62f397002bb74fe4c4e9126a238e644fbfd3507e Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Fri, 9 Jun 2023 12:31:23 +0200 >Subject: [PATCH] Bug 13870: Add warn about linked order or/and subscription on > batch item table > >When you try to manage/delete/edit items I added an info about linked >order or/and linked subscription. > >Test plan : > >1) Apply this patch >2) Restart_all >3) Be sure to have item with order or can concern by a subscription >4) On biblio record page click on Edit -> Manage items >5) See the yellow triangle next to the 'delete' action in 'actions' >dropdown menu (with subscription id or ordernumber hover the symbol) >6) When you edit or delete items (batch mode) you can see two new >columns about orders and subscriptions linked. > >Sponsored by: BibLibre >--- > cataloguing/additem.pl | 15 +++++++++++ > .../prog/en/includes/html_helpers.inc | 19 +++++++++++++ > .../prog/en/modules/cataloguing/additem.tt | 10 +++++-- > tools/batchMod.pl | 27 +++++++++++++++---- > 4 files changed, 64 insertions(+), 7 deletions(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 3d361ec1e63..e68ad7d15d8 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -32,6 +32,7 @@ use C4::Context; > use C4::Members; > use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers ); > use C4::Search qw( enabled_staff_search_views ); >+use C4::Acquisition qw( GetOrderFromItemnumber ); > use Koha::Biblios; > use Koha::Item::Templates; > use Koha::ItemTypes; >@@ -42,6 +43,8 @@ use Koha::Patrons; > use Koha::SearchEngine::Indexer; > use Koha::UI::Form::Builder::Item; > use Koha::Result::Boolean; >+use Koha::Serial::Items; >+use Koha::Subscriptions; > > use Encode qw( encode_utf8 ); > use List::MoreUtils qw( any uniq ); >@@ -680,9 +683,20 @@ if ($op) { > # now, build existiing item list > > my @items; >+my %warning_messages; > for my $item ( $biblio->items->as_list, $biblio->host_items->as_list ) { > my $i = $item->columns_to_str; > $i->{nomod} = 1 unless $patron->can_edit_items_from( $item->homebranch ); >+ my $i_order = GetOrderFromItemnumber( $i->{itemnumber} ); >+ my $i_serialid = Koha::Serial::Items->find( { itemnumber => $i->{itemnumber} }, { prefetch => 'serialid' } ); >+ if ($i_order) { >+ $warning_messages{ $i->{itemnumber} } = >+ sprintf( 'There is an order (ordernumber %s) on this item', $i_order->{ordernumber} ); >+ } >+ if ($i_serialid) { >+ $warning_messages{ $i->{itemnumber} } = 'A subscription is linked to this item'; >+ } >+ $i->{nomod} = 1 unless $patron->can_edit_items_from( $item->homebranch ); > push @items, $i; > } > >@@ -807,6 +821,7 @@ $template->param( > barcode => $current_item->{barcode}, > op => $nextop, > popup => scalar $input->param('popup') ? 1 : 0, >+ warning_messages => \%warning_messages, > C4::Search::enabled_staff_search_views, > ); > $template->{'VARS'}->{'searchid'} = $searchid; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >index 50d618f3929..69d351c342a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -262,6 +262,8 @@ > [% END %] > <th class="anti-the">Title</th> > <th class="holds_count" title="Item holds / Total holds">Holds</th> >+ <th class="linked_order" title="Linked order">Linked order</th> >+ <th class="linked_subscription" title="Linked subscription">Linked subscription</th> > [% FOREACH item_header IN headers %] > [% IF item_header.column_name %] > <th data-colname="[% item_header.column_name | html %]"> >@@ -276,6 +278,9 @@ > <tbody> > [% FOREACH item IN items %] > [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %] >+ [% SET current_itemnumber = item.itemnumber %] >+ [% SET linked_order = linked_orders_subscriptions.$current_itemnumber %] >+ [% SET linked_subscription = linked_orders_subscriptions.$current_itemnumber.subscription %] > > <tr> > <td>[% item.index + 1 | html %]</td> >@@ -346,6 +351,20 @@ > [% END %] > </a> > </td> >+ <td class="linked_order"> >+ [% IF linked_order.ordernumber %] >+ <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% linked_order.basket | uri %]" title="See basket details">[% linked_order.ordernumber | html %]<a> >+ [% ELSE %] >+ None >+ [% END %] >+ </td> >+ <td class="linked_subscription"> >+ [% IF linked_subscription %] >+ <a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% linked_subscription | uri %]" title="Subscription id [% linked_subscription | html %]">Subscription details<a> >+ [% ELSE %] >+ None >+ [% END %] >+ </td> > [% FOREACH header IN headers %] > [% SET attribute = header.attribute %] > [% IF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %] >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 a41569fe99e..e3f700470a3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -115,7 +115,9 @@ > <tbody> > [% FOREACH item IN items %] > [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %] >- [% IF item.itemnumber == itemnumber%] >+ [% SET current_itemnumber = item.itemnumber %] >+ [% SET warn_message = warning_messages.$current_itemnumber %] >+ [% IF item.itemnumber == itemnumber %] > [% UNLESS can_be_edited %] > <tr id="row[% item.itemnumber | html %]" class="active"> > [% ELSE %] >@@ -157,7 +159,11 @@ > <input type="hidden" name="itemnumber" value="[% item.itemnumber | html %]" /> > <input type="hidden" name="searchid" value="[% searchid | html %]" /> > </form> >- <a class="dropdown-item delete" data-item="[% item.itemnumber | html %]" href="#">Delete</a> >+ <a class="dropdown-item delete" data-item="[% item.itemnumber | html %]" href="/cgi-bin/koha/cataloguing/additem.pl?op=delitem&biblionumber=[% item.biblionumber | html %]&itemnumber=[% item.itemnumber | html %]&searchid=[% searchid | html %]" onclick="return confirm_deletion();">Delete >+ [% IF warn_message %] >+ <i class="fa fa-warning warn" Title="[% warn_message | html %]"></i> >+ [% END %] >+ </a> > </li> > [% END %] > [% END %] >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index d6367b48a15..411847b3367 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -26,6 +26,7 @@ use C4::Auth qw( get_template_and_user haspermission ); > use C4::Output qw( output_html_with_http_headers ); > use C4::Circulation qw( barcodedecode ); > use C4::Context; >+use C4::Acquisition qw( GetOrderFromItemnumber ); > use MARC::File::XML; > use List::MoreUtils qw( uniq ); > use Encode qw( encode_utf8 ); >@@ -40,6 +41,8 @@ use Koha::BackgroundJob::BatchDeleteItem; > use Koha::BackgroundJob::BatchUpdateItem; > use Koha::UI::Form::Builder::Item; > use Koha::UI::Table::Builder::Items; >+use Koha::Serial::Items; >+use Koha::Serials; > > my $input = CGI->new; > my $dbh = C4::Context->dbh; >@@ -85,6 +88,7 @@ my $nextop=""; > my $display_items; > > my @messages; >+my %linked_orders_subscriptions; > > if ( $op eq "cud-action" ) { > >@@ -94,8 +98,7 @@ if ( $op eq "cud-action" ) { > record_ids => \@itemnumbers, > delete_biblios => $del_records, > }; >- my $job_id = >- Koha::BackgroundJob::BatchDeleteItem->new->enqueue($params); >+ my $job_id = Koha::BackgroundJob::BatchDeleteItem->new->enqueue($params); > $nextop = 'enqueued'; > $template->param( job_id => $job_id, ); > } >@@ -239,6 +242,19 @@ if ($op eq "cud-show" || $op eq "show"){ > if (defined $biblionumber && !@itemnumbers){ > my $biblio = Koha::Biblios->find($biblionumber); > @itemnumbers = $biblio ? $biblio->items->get_column('itemnumber') : (); >+ foreach my $itemnumber (@itemnumbers) { >+ $linked_orders_subscriptions{$itemnumber} = []; >+ my $order = GetOrderFromItemnumber($itemnumber); >+ my $serial_id = Koha::Serial::Items->search( { itemnumber => $itemnumber } )->get_column('serialid'); >+ if ($order) { >+ $linked_orders_subscriptions{$itemnumber} = >+ { ordernumber => $order->{ordernumber}, basket => $order->{basketno} }; >+ } >+ if ($serial_id) { >+ my $subscription_id = Koha::Serials->search( { serialid => $serial_id } )->get_column('subscriptionid'); >+ $linked_orders_subscriptions{$itemnumber} = { subscription => $subscription_id }; >+ } >+ } > } > if ( my $list = $input->param('barcodelist') ) { > my @barcodelist = grep /\S/, ( split /[$split_chars]/, $list ); >@@ -291,9 +307,10 @@ if ($op eq "cud-show" || $op eq "show"){ > > # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. > $template->param( >- subfields => $subfields, >- notfoundbarcodes => \@notfoundbarcodes, >- notfounditemnumbers => \@notfounditemnumbers >+ subfields => $subfields, >+ notfoundbarcodes => \@notfoundbarcodes, >+ notfounditemnumbers => \@notfounditemnumbers, >+ linked_orders_subscriptions => \%linked_orders_subscriptions, > ); > $nextop="cud-action"; > $template->param( show => 1 ); >-- >2.39.5
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 13870
:
147641
|
152235
|
152236
|
155576
|
175440
|
176858
|
179579
|
179580
|
179581
|
179834
|
180952
|
183442
|
183556