From e3766ec73c5f38a25eedd99cdc88f69b245d92e0 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 --- 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 4a3dd5a7ea..b6c877d5ca 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -414,6 +414,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(); @@ -1087,7 +1104,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 6d66d4d09a..4f09923f0d 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 5a42352f38..a1960ba2d2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -451,6 +451,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