From 78e144a9a0899a92b4650e5b2cecceb0ea0330e5 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 27 Oct 2022 16:13:31 +0000 Subject: [PATCH] Bug 32019: Add option to mark items returned via batch modification Ther are options that allow avoiding marking an issue returned when se tot lost. Libraries do this to tie a lost item to a patron clearly. Eventually, after the patron has paid, or after some time, the library may wish to delete the item. When doing so, they do not wish to check the item in and affect any statuses or fines. This is also true for withdrawn items It would be helpful to have a way to mark issues returned in bulk, when they have not been marked returned in the past To test: 1 - Apply patches 2 - Restart all 3 - Set 'MarkLostItemsAsReturned' system preferences to 'None' 4 - Check out some items that have replacement fees set 5 - Mark them lost 6 - Check out more items, mark them withdrawn 7 - Set system preference 'BlockReturnOfWithdrawnItems' to block 8 - Enter item barcodes into batch modification 9 - Leave 'Mark items returned as blank 10 - Verify nothing was checked in 11 - Repeat but set 'Mark items as returned' to 'No' 12 - Verify nothing was checked in 13 - Repeat, but set 'Mark items as returned' to 'Yes' 14 - Verify items are returned 15 - Verify no fines have been adjusted 16 - Verify withdrawn items are sitll withdrawn 17 - Verify you can now delete the items Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- Koha/BackgroundJob/BatchUpdateItem.pm | 3 +++ Koha/Items.pm | 26 +++++++++++++++++-- .../prog/en/modules/tools/batchMod-edit.tt | 16 ++++++++++++ tools/batchMod.pl | 6 +++++ 4 files changed, 49 insertions(+), 2 deletions(-) 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 { -- 2.39.5