From 97695031f06c81c09fe4537366600191777968a1 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 23 Sep 2021 13:58:50 +0100 Subject: [PATCH] Bug 28854: Record and display who lost the item This patch records the bundle issue from which an item is marked as lost so that we may use that to infer who lost the item (for later charges and display). Test plan 0) Apply all patches up to this point 1) Checkout a bundle to a user 2) Checkin the bundle and do not scan one of the barcodes at confirmation * Note that the item not scanned is marked as lost 3) Navigate to the biblio for the lost item and note that the patron who lost the item is displayed 4) Checkin the lost item * The item should be marked as found and the items_lost_issue table should no longer contain a link to the issue https://bugs.koha-community.org/show_bug.cgi?id=24454 --- Koha/Item.pm | 22 ++++++++++++++++++- circ/returns.pl | 2 ++ .../prog/en/modules/catalogue/detail.tt | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index e7ca0397220..0facde83c6c 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -411,6 +411,23 @@ sub last_checkout { return Koha::Old::Checkout->_new_from_dbic( $checkout_rs ); } +=head3 loss_checkout + + my $loss_checkout = $item->loss_checkout; + +Return the old checkout from which this item was marked as lost + +=cut + +sub loss_checkout { + my ( $self ) = @_; + my $items_lost_issue_rs = $self->_result->items_lost_issue; + return unless $items_lost_issue_rs; + my $issue_rs = $items_lost_issue_rs->issue; + return unless $issue_rs; + return Koha::Old::Checkout->_new_from_dbic( $issue_rs ); +} + =head3 holds my $holds = $item->holds(); @@ -972,7 +989,10 @@ Internal function, not exported, called only by Koha::Item->store. sub _set_found_trigger { my ( $self, $pre_mod_item ) = @_; - ## If item was lost, it has now been found, reverse any list item charges if necessary. + # If item was lost, it has now been found + $self->_result->items_lost_issue->delete; + + # Reverse any lost item charges if necessary. my $no_refund_after_days = C4::Context->preference('NoRefundOnLostReturnedItemsAge'); if ($no_refund_after_days) { diff --git a/circ/returns.pl b/circ/returns.pl index 1e45c50ae59..8720a96ae64 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -383,6 +383,8 @@ if ($barcode) { for my $missing_item ( keys %{$expected_items} ) { my $bundle_item = $expected_items->{$missing_item}; $bundle_item->itemlost($BundleLostValue)->store(); + $bundle_item->_result->update_or_create_related( + 'items_lost_issue', { issue_id => $checkout->issue_id } ); push @missing_items, $bundle_item; } $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 5c556335d5c..bf192103e8b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -455,6 +455,9 @@ Note that permanent location is a code, and location may be an authval. [% ELSE %] Unavailable (lost or missing) [% END %] + [% IF ( item.itemlost == Koha.Preference('BundleLostValue') AND item.loss_checkout ) %] + Lost by [% INCLUDE 'patron-title.inc' patron=item.loss_checkout.patron hide_patron_infos_if_needed=1 %] + [% END %] [% END %] [% IF ( item.withdrawn ) %] -- 2.20.1