Bug 21408: Inventory - Warn of items possibly scanned out of order
authorKyle M Hall <kyle@bywatersolutions.com>
Tue, 25 Sep 2018 13:16:53 +0000 (10:16 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 7 Nov 2018 21:35:18 +0000 (21:35 +0000)
This patch addes the ability to choose to be warned if it's possible
an item was scanned out of order ( i.e. mis-shelved ).

Test Plan:
1) Apply this patch
2) Generate a list of barcodes ordered by callnumber
3) "Misplace" one callnumber by moving it to another area of the list
4) Browse to the inventory tool, choose your barcodes file
5) Check the checkbox for "Check barcodes list for items shelved out of order"
6) Click "submit", note the item has been flagged as possibly out of order

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt
tools/inventory.pl

index a8a6863..0d87de7 100644 (file)
@@ -47,6 +47,7 @@
             <li><label for="setdate">Set inventory date to:</label> <input type="text" id="setdate" name="setdate" value="[% today | $KohaDates %]" class="datepicker" disabled /></li>
             <li><label for="compareinv2barcd">Compare barcodes list to results: </label><input type="checkbox" name="compareinv2barcd" id="compareinv2barcd" disabled /></li>
             <li><label for="dont_checkin">Do not check in items scanned during inventory: </label><input type="checkbox" name="dont_checkin" id="dont_checkin" disabled /></li>
+            <li><label for="out_of_order">Check barcodes list for items shelved out of order: </label><input type="checkbox" name="out_of_order" id="out_of_order" disabled /></li>
           </ol>
         </fieldset>
 
                     Still checked out<br/>
                 [% ELSIF problem.key == 'no_barcode' %]
                     No barcode<br/>
+                [% ELSIF problem.key == 'out_of_order' %]
+                    Item may be shelved out of order<br/>
                 [% END %]
             [% END %]
             </td>
index 2ad1dd8..ac33fbe 100755 (executable)
@@ -52,6 +52,7 @@ my $branch     = $input->param('branch');
 my $op         = $input->param('op');
 my $compareinv2barcd = $input->param('compareinv2barcd');
 my $dont_checkin = $input->param('dont_checkin');
+my $out_of_order = $input->param('out_of_order');
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {   template_name   => "tools/inventory.tt",
@@ -252,7 +253,10 @@ if( @scanned_items ) {
 
 # Report scanned items that are on the wrong place, or have a wrong notforloan
 # status, or are still checked out.
-foreach my $item ( @scanned_items ) {
+for ( my $i = 0; $i < @scanned_items; $i++ ) {
+
+    my $item = $scanned_items[$i];
+
     $item->{notforloancode} = $item->{notforloan}; # save for later use
     my $fc = $item->{'frameworkcode'} || '';
 
@@ -271,6 +275,24 @@ foreach my $item ( @scanned_items ) {
         additemtoresults( $item, $results );
     }
 
+    # Check for items shelved out of order
+    if ($out_of_order) {
+        unless ( $i == 0 ) {
+            my $previous_item = $scanned_items[ $i - 1 ];
+            if ( $previous_item && $item->{cn_sort} lt $previous_item->{cn_sort} ) {
+                $item->{problems}->{out_of_order} = 1;
+                additemtoresults( $item, $results );
+            }
+        }
+        unless ( $i == scalar(@scanned_items) ) {
+            my $next_item = $scanned_items[ $i + 1 ];
+            if ( $next_item && $item->{cn_sort} gt $next_item->{cn_sort} ) {
+                $item->{problems}->{out_of_order} = 1;
+                additemtoresults( $item, $results );
+            }
+        }
+    }
+
     # Report an item that is checked out (unusual!) or wrongly placed
     if( $item->{onloan} ) {
         $item->{problems}->{checkedout} = 1;