From 430047e8c874d70f522751e32a81f9e0e5b62ed4 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 16 Dec 2013 09:38:55 -0500 Subject: [PATCH] Bug 11405 [1] - Warn of items possibly scanned out of order 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 --- .../prog/en/modules/tools/inventory.tt | 6 +++ tools/inventory.pl | 39 +++++++++++++++----- 2 files changed, 36 insertions(+), 9 deletions(-) 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 fdac5fa..29db8e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt @@ -214,6 +214,10 @@ $(document).ready(function(){ +
  • + + +
  • @@ -293,6 +297,8 @@ $(document).ready(function(){

    Change item status

    [% ELSIF result.problem == 'not_scanned' %]

    Item should have been scanned

    + [% ELSIF result.problem == 'out_of_order' %] +

    Item may be shelved out of order

    [% END %] diff --git a/tools/inventory.pl b/tools/inventory.pl index a4bf639..a1fae52 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -52,6 +52,7 @@ my $branchcode = $input->param('branchcode') || ''; my $branch = $input->param('branch'); my $op = $input->param('op'); my $compareinv2barcd = $input->param('compareinv2barcd'); +my $out_of_order = $input->param('out_of_order'); my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { template_name => "tools/inventory.tt", @@ -294,7 +295,26 @@ if ( $compareinv2barcd ) { # insert "wrongplace" to all scanned items that are not supposed to be in this range # note this list is always displayed, whatever the librarian has chosen for comparison my $moddatecount = 0; -foreach my $item ( @scanned_items ) { +for ( my $i = 0; $i < @scanned_items; $i++ ) { + my $item = $scanned_items[$i]; + + # 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->{problem} = 'out_of_order'; + push( @items_with_problems, {%$item} ); + } + } + unless ( $i == scalar(@scanned_items) ) { + my $next_item = $scanned_items[ $i + 1 ]; + if ( $next_item && $item->{cn_sort} gt $next_item->{cn_sort} ) { + $item->{problem} = 'out_of_order'; + push( @items_with_problems, {%$item} ); + } + } + } # Saving notforloan code before it's replaced by it's authorised value for later comparison $item->{notforloancode} = $item->{notforloan}; @@ -316,9 +336,11 @@ foreach my $item ( @scanned_items ) { next if $item->{onloan}; # skip checked out items # If we have scanned items with a non-matching notforloan value - if (none { $item->{'notforloancode'} eq $_ } @notforloans) { - $item->{problem} = 'changestatus'; - push @items_with_problems, { %$item }; + if ( $item->{notforloancode} ) { + if ( none { $item->{'notforloancode'} eq $_ } @notforloans ) { + $item->{problem} = 'changestatus'; + push @items_with_problems, {%$item}; + } } if (none { $item->{barcode} eq $_->{barcode} && !$_->{'onloan'} } @$wrongplacelist) { $item->{problem} = 'wrongplace'; @@ -349,11 +371,10 @@ for my $item ( @items_with_problems ) { # If a barcode file is given, we want to show problems, else all items my @results; -@results = $uploadbarcodes - ? @items_with_problems - : $op - ? @$inventorylist - : (); +@results = + $uploadbarcodes ? @items_with_problems + : $op ? @$inventorylist + : undef; $template->param( moddatecount => $moddatecount, -- 1.7.2.5