From 5d4991d6a591c5bb513501ac285dd87d67508743 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Thu, 18 Jul 2024 15:05:58 +0200 Subject: [PATCH] Bug 18657: Add the possibility to add lost items to the report Currently the tool reports: Incorrect not-for-loan values Wrong place Checked out We should have: Optional display of items w/o problems Display of missing/lost items now marked found TEST PLAN 1 - Mark an item as lost 2 - Go to tools->inventory 3 - Fill in the barcode list with the barcode of the item, notice there is one checkbox in "Additional options" 4 - Submit -> there should be no result 5 - Apply patches and redo 1,2&3 6 - Notice there are now 3 checkboxes in "Additional options" 7 - Click on "Add lost items to the report" 8 - Submit -> there is now one line in the report with problem "Item was lost and is now marked as found" 9 - Go to tools->inventory 10 - Click on "Add lost items to the report" 11 - Submit -> there is no line in the report 12 - Go to tools->inventory 13 - Click on "Add items without problem to the report" 11 - Submit -> there is now line in the report with an empty problem --- .../prog/en/modules/tools/inventory.tt | 6 ++++++ tools/inventory.pl | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt index 60c4c8e..79665ed 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -252,6 +252,10 @@ +
  • + + +
  • @@ -368,6 +372,8 @@ No barcode
    [% ELSIF problem.key == 'out_of_order' %] Item may be shelved out of order
    + [% ELSIF problem.key == 'lost' %] + Item was lost and is now marked as found
    [% END %] [% END %] diff --git a/tools/inventory.pl b/tools/inventory.pl index e38d7c4..19aa5dc 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -123,6 +123,11 @@ for my $authvfield (@$statuses) { } } +my $report_lost_items; +if ( defined $input->param('ReportLostItems') && $input->param('ReportLostItems') eq 'on' ) { + $report_lost_items = "1"; +} + # if there's a list of not for loans types selected use it rather than # the full set. @notforloans = @{$staton->{'items.notforloan'}} if defined $staton->{'items.notforloan'} and scalar @{$staton->{'items.notforloan'}} > 0; @@ -162,6 +167,7 @@ my $results = {}; my @scanned_items; my @errorloop; my $moddatecount = 0; +my @lost_items; if ( $op eq 'cud-inventory' && ( ( $uploadbarcodes && length($uploadbarcodes) > 0 ) || ( $barcodelist && length($barcodelist) > 0 ) ) ) { @@ -225,6 +231,9 @@ if ( $op eq 'cud-inventory' next; } # Modify date last seen for scanned items, remove lost status + if ( $item->unblessed->{itemlost} ) { + push @lost_items, $barcode; + } $item->set({ itemlost => 0, datelastseen => $date_dt })->store; my $item_unblessed = $item->unblessed; $moddatecount++; @@ -291,7 +300,6 @@ if( @scanned_items ) { $rightplacelist = { map { $_->{barcode} ? ( $_->{barcode}, $_ ) : (); } @$rightplacelist }; - } # Report scanned items that are on the wrong place, or have a wrong notforloan @@ -335,6 +343,12 @@ for ( my $i = 0; $i < @scanned_items; $i++ ) { $item->{problems}->{wrongplace} = 1; additemtoresults( $item, $results ); } + + # Report a lost item if asked + if ( @lost_items && ( scalar grep { $_ eq $item->{barcode} } @lost_items ) && $report_lost_items ) { + $item->{problems}->{lost} = 1; + additemtoresults( $item, $results ); + } } # Compare barcodes with inventory list, report no_barcode and not_scanned. @@ -418,6 +432,8 @@ if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){ $errstr .= "checked out,"; } elsif( $key eq 'out_of_order' ) { $errstr .= "shelved out of order,"; + } elsif ( $key eq 'lost' ) { + $errstr .= "item was lost"; } } $errstr =~ s/,$//; -- 2.43.0