From 636015282f8d322678803813486242c0a3b18506 Mon Sep 17 00:00:00 2001 From: Blou Date: Tue, 28 Feb 2017 16:57:28 -0500 Subject: [PATCH] Bug 16834 inventory.pl's Set Inventory Date to is ignored When entering a value in "Set Inventory date to" at the top of the UI, this value is ignored and the items are always updated with today. This is (in part) caused by ModDateLastSeen not allowing to set current day. This patch: - Makes relevant the date entered at the top (Set Inventory date to). - Makes relevant the date entered at the bottow (Inventory date). - Doesn't brake most functionalities. - Doesn't fix any of the many other bugs and issues with this broken tool. - remove a warning that was flooding the logs on every call. - Just makes the UI intuitive for common usage regarding dates. TEST: 1) find a barcode in your db, write it in a text file - set item.datelastseen to some date in the past 2) go to tools/inventory 3) Browse to select the file from 1) 4) Select a date (top) before today, and after the datelastseen entered. 5) Click submit. 6) Validate: - Datelastseen specified at the top is the one you entered. - Date Last Seen in the table is the old from the DB - item.datelastseen is now today 7) Apply the patch. Validate: - item.datelastseen is now the date you entered. --- tools/inventory.pl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/inventory.pl b/tools/inventory.pl index 990855f..8fc9517 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -46,7 +46,7 @@ $maxlocation=$minlocation.'Z' unless ( $maxlocation || ! $minlocation ); my $location=$input->param('location') || ''; my $itemtype=$input->param('itemtype'); # FIXME note, template does not currently supply this my $ignoreissued=$input->param('ignoreissued'); -my $datelastseen = $input->param('datelastseen'); +my $datelastseen = $input->param('datelastseen') || $input->param('setdate'); my $markseen = $input->param('markseen'); my $branchcode = $input->param('branchcode') || ''; my $branch = $input->param('branch'); @@ -277,10 +277,9 @@ if ( $markseen or $op ) { } # If "compare barcodes list to results" has been checked, we want to alert for missing items +my $dls = output_pref( { dt => dt_from_string( $datelastseen ), dateformat => 'iso' } ); if ( $compareinv2barcd ) { # set "missing" flags for all items with a datelastseen (dls) before the chosen datelastseen (cdls) - my $dls = output_pref( { dt => dt_from_string( $datelastseen ), - dateformat => 'iso' } ); foreach my $item ( @$inventorylist ) { my $cdls = output_pref( { dt => dt_from_string( $item->{datelastseen} ), dateformat => 'iso' } ); @@ -298,7 +297,6 @@ if ( $compareinv2barcd ) { # note this list is always displayed, whatever the librarian has chosen for comparison my $moddatecount = 0; foreach my $item ( @scanned_items ) { - # Saving notforloan code before it's replaced by it's authorised value for later comparison $item->{notforloancode} = $item->{notforloan}; @@ -323,13 +321,13 @@ foreach my $item ( @scanned_items ) { $item->{problem} = 'changestatus'; push @items_with_problems, { %$item }; } - if (none { $item->{barcode} eq $_->{barcode} && !$_->{'onloan'} } @$wrongplacelist) { + if (none { $_->{barcode} && $item->{barcode} eq $_->{barcode} && !$_->{'onloan'} } @$wrongplacelist) { $item->{problem} = 'wrongplace'; push @items_with_problems, { %$item }; } # Modify date last seen for scanned items - ModDateLastSeen($item->{'itemnumber'}); + ModItem({ itemlost => 0, datelastseen => $dls }, undef, $item->{'itemnumber'}); $moddatecount++; } -- 2.1.0