diff --git a/Koha/BackgroundJob/BatchUpdateItem.pm b/Koha/BackgroundJob/BatchUpdateItem.pm index 82d27ec34f..224e6e8673 100644 --- a/Koha/BackgroundJob/BatchUpdateItem.pm +++ b/Koha/BackgroundJob/BatchUpdateItem.pm @@ -98,6 +98,8 @@ sub process { my $new_values = $args->{new_values}; my $exclude_from_local_holds_priority = $args->{exclude_from_local_holds_priority}; + my $mark_items_returned = + $args->{mark_items_returned}; my $report = { total_records => scalar @record_ids, @@ -113,6 +115,7 @@ sub process { new_values => $new_values, exclude_from_local_holds_priority => $exclude_from_local_holds_priority, + mark_items_returned => $mark_items_returned, callback => sub { my ($progress) = @_; $self->progress($progress)->store; diff --git a/Koha/Items.pm b/Koha/Items.pm index 5e9e808eee..7a6bfdfb2b 100644 --- a/Koha/Items.pm +++ b/Koha/Items.pm @@ -227,6 +227,10 @@ Allows to modify existing subfield's values using a regular expression Set the passed boolean value to items.exclude_from_local_holds_priority +=item mark_items_returned + +Move issues on these items to the old issues table, do not mark items found or adjust statuses or fines + =item callback Callback function to call after an item has been modified @@ -241,6 +245,7 @@ sub batch_update { my $regex_mod = $params->{regex_mod} || {}; my $new_values = $params->{new_values} || {}; my $exclude_from_local_holds_priority = $params->{exclude_from_local_holds_priority}; + my $mark_items_returned = $params->{mark_items_returned}; my $callback = $params->{callback}; my (@modified_itemnumbers, $modified_fields); @@ -250,6 +255,7 @@ sub batch_update { try {$schema->txn_do(sub { my $modified_holds_priority = 0; + my $item_returned = 0; if ( defined $exclude_from_local_holds_priority ) { if(!defined $item->exclude_from_local_holds_priority || $item->exclude_from_local_holds_priority != $exclude_from_local_holds_priority) { $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority)->store; @@ -336,9 +342,25 @@ sub batch_update { ) if $item->itemlost and not $itemlost_pre; } + if ( $mark_items_returned ){ + my $issue = $item->checkout; + if( $issue ){ + $item_returned = 1; + C4::Circulation::MarkIssueReturned( + $issue->borrowernumber, + $item->itemnumber, + undef, + $issue->patron->privacy, + { + skip_record_index => 1, + skip_holds_queue => 1, + } + ); + } + } - push @modified_itemnumbers, $item->itemnumber if $modified || $modified_holds_priority; - $modified_fields += $modified + $modified_holds_priority; + push @modified_itemnumbers, $item->itemnumber if $modified || $modified_holds_priority || $item_returned; + $modified_fields += $modified + $modified_holds_priority + $item_returned; })} catch { warn $_ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt index 0b5299a7e9..6fb72079c3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt @@ -195,6 +195,22 @@ +
+ Options +
    +
  1. +
    +

    This option allows returning items to remove them from patron accounts
    Items are not marked found nor do statuses prevent this return. This feature is intended to allow removal and deletion of items without affecting fines or other statuses


    + + +
    +
  2. +
+
diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 27830f505c..6c252ff849 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -52,6 +52,7 @@ my $del_records = $input->param('del_records'); 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 $template_name; my $template_flag; @@ -171,6 +172,11 @@ if ( $op eq "action" ) { ) ? $exclude_from_local_holds_priority : undef, + mark_items_returned => ( + defined $mark_items_returned + && $mark_items_returned ne "" + ) + ? $mark_items_returned : undef, }; try {