From aed867e4e12104c919328b4b2ed64fc0648f91a5 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 4 Jul 2024 10:21:03 +0000 Subject: [PATCH] Bug 37115: Batch delete linked serials Test plan: - Add a new subscription to a serial record (with the option 'create an item record' selected) - Receive several issues and create the linked items - Return to the bibliographic record - Select several items - Click to 'Delete selected items' - Tick the box 'delete serial issues linked to items' and confirm - The items should be deleted correctly - Back to subscription : the issues linked to items should no longer exist --- Koha/BackgroundJob/BatchDeleteItem.pm | 17 ++++++----- .../prog/en/modules/tools/batchMod-del.tt | 19 +++++++++---- tools/batchMod.pl | 28 ++++++++++--------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/Koha/BackgroundJob/BatchDeleteItem.pm b/Koha/BackgroundJob/BatchDeleteItem.pm index 474450e57b..eacb33589a 100644 --- a/Koha/BackgroundJob/BatchDeleteItem.pm +++ b/Koha/BackgroundJob/BatchDeleteItem.pm @@ -81,8 +81,9 @@ sub process { $self->start; - my @record_ids = @{ $args->{record_ids} }; - my $delete_biblios = $args->{delete_biblios}; + my @record_ids = @{ $args->{record_ids} }; + my $delete_biblios = $args->{delete_biblios}; + my $delete_serial_issues = $args->{delete_serial_issues}; my $report = { total_records => scalar @record_ids, @@ -104,7 +105,7 @@ sub process { my $item = Koha::Items->find($record_id) || next; - my $return = $item->safe_delete({ skip_record_index => 1, skip_holds_queue => 1 }); + my $return = $item->safe_delete({ skip_record_index => 1, skip_holds_queue => 1, delete_serial_issues => $delete_serial_issues }); unless ( $return ) { # FIXME Do we need to rollback the whole transaction if a deletion failed? @@ -221,15 +222,17 @@ sub enqueue { # TODO Raise exception instead return unless exists $args->{record_ids}; - my @record_ids = @{ $args->{record_ids} }; - my $delete_biblios = $args->{delete_biblios} || 0; + my @record_ids = @{ $args->{record_ids} }; + my $delete_biblios = $args->{delete_biblios} || 0; + my $delete_serial_issues = $args->{delete_serial_issues} || 0; $self->SUPER::enqueue( { job_size => scalar @record_ids, job_args => { - record_ids => \@record_ids, - delete_biblios => $delete_biblios, + record_ids => \@record_ids, + delete_biblios => $delete_biblios, + delete_serial_issues => $delete_serial_issues, }, job_queue => 'long_tasks', } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt index ffa1addbb9..5064338100 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt @@ -167,12 +167,21 @@ [% IF ( itemresults ) %]
- -

This will delete [% IF ( too_many_items_display ) %]all the[% ELSE %]the selected[% END %] items.

- - + +

This will delete [% IF ( too_many_items_display ) %]all the[% ELSE %]the selected[% END %] items.

+ +
+
+ + +
+
+ + +
+
-
+
[% IF too_many_items_display %] [% ELSE %] diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 1b43231857..e6dc6ded99 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -41,18 +41,19 @@ use Koha::BackgroundJob::BatchUpdateItem; use Koha::UI::Form::Builder::Item; use Koha::UI::Table::Builder::Items; -my $input = CGI->new; -my $dbh = C4::Context->dbh; -my $error = $input->param('error'); -my @itemnumbers = $input->multi_param('itemnumber'); -my $biblionumber = $input->param('biblionumber'); -my $op = $input->param('op'); -my $del = $input->param('del'); -my $del_records = $input->param('del_records'); -my $src = $input->param('src'); -my $use_default_values = $input->param('use_default_values'); +my $input = CGI->new; +my $dbh = C4::Context->dbh; +my $error = $input->param('error'); +my @itemnumbers = $input->multi_param('itemnumber'); +my $biblionumber = $input->param('biblionumber'); +my $op = $input->param('op'); +my $del = $input->param('del'); +my $del_records = $input->param('del_records'); +my $del_serial_issues = $input->param('del_serial_issues'); +my $src = $input->param('src'); +my $use_default_values = $input->param('use_default_values'); my $exclude_from_local_holds_priority = $input->param('exclude_from_local_holds_priority'); -my $mark_items_returned = $input->param('mark_items_returned'); +my $mark_items_returned = $input->param('mark_items_returned'); my $template_name; my $template_flag; @@ -91,8 +92,9 @@ if ( $op eq "cud-action" ) { if ($del) { try { my $params = { - record_ids => \@itemnumbers, - delete_biblios => $del_records, + record_ids => \@itemnumbers, + delete_biblios => $del_records, + delete_serial_issues => $del_serial_issues, }; my $job_id = Koha::BackgroundJob::BatchDeleteItem->new->enqueue($params); -- 2.39.3 (Apple Git-146)