From 8b460f65ec2567d443893b5cd3a4875f6b188cac Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Fri, 9 Jun 2023 12:31:23 +0200 Subject: [PATCH] Bug 13870: Add columns in batch delete mode --- .../prog/en/includes/html_helpers.inc | 19 +++++++++++++++ tools/batchMod.pl | 24 ++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) 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 f0d695bc9c..e0aa25408c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc @@ -258,6 +258,8 @@ [% END %] Title Holds + Linked order + Linked subscription [% FOREACH item_header IN headers %] [% IF item_header.column_name %] @@ -272,6 +274,9 @@ [% 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 %] [% item.index + 1 | html %] @@ -342,6 +347,20 @@ [% END %] + + [% IF linked_order.ordernumber %] + [% linked_order.ordernumber | html %] + [% ELSE %] + None + [% END %] + + + [% IF linked_subscription %] + Subscription details + [% ELSE %] + None + [% END %] + [% FOREACH header IN headers %] [% SET attribute = header.attribute %] [% IF header.attribute AND date_fields.grep('^' _ attribute _ '$').size %] diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 6c252ff849..e0bd493cf9 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 "action" ) { @@ -238,6 +242,19 @@ if ($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 ); @@ -289,9 +306,10 @@ if ($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="action" } # -- End action="show" -- 2.25.1