From 54881cdd086ce6c5cc6ae488187f44e0ae88ad46 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Tue, 14 Jul 2015 15:02:42 +0100
Subject: [PATCH] [PASSED QA] Bug 10005: Inventory - Add an option to not check
 in items

The inventory tools automatically check in items, this patch adds it as
an option.

Test plan:
1/ Check an item out, fill a file with its barcode, and use this file in
the inventory tools.
2/ Check the new checkbox and confirm that the item is not checked in
3/ Repeat again and don't check it, the behavior should be the same as before
this patch.

Signed-off-by: Jason Robb <jrobb@sekls.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Added a missing </li>.
Patch works as expected.
---
 .../intranet-tmpl/prog/en/modules/tools/inventory.tt  |  4 ++++
 tools/inventory.pl                                    | 19 +++++++++++--------
 2 files changed, 15 insertions(+), 8 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..5143b3c 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(){
             <label for="compareinv2barcd">Compare barcodes list to results: </label>
             <input type="checkbox" name="compareinv2barcd" id="compareinv2barcd" />
         </li>
+        <li>
+            <label for="dont_checkin">Do not check in items scanned during inventory: </label>
+            <input type="checkbox" name="dont_checkin" id="dont_checkin" />
+        </li>
         </ol>
   </fieldset>
             <input type="hidden" name="op" value="do_it" />
diff --git a/tools/inventory.pl b/tools/inventory.pl
index a4bf639..2192dbd 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 $dont_checkin = $input->param('dont_checkin');
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {   template_name   => "tools/inventory.tt",
@@ -209,14 +210,16 @@ if ( $uploadbarcodes && length($uploadbarcodes) > 0 ) {
                 ModItem( { datelastseen => $date }, undef, $item->{'itemnumber'} );
                 push @scanned_items, $item;
                 $count++;
-                $qonloan->execute($barcode);
-                if ($qonloan->rows){
-                    my $data = $qonloan->fetchrow_hashref;
-                    my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch});
-                    if ($doreturn){
-                        push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_RET'=>1}
-                    } else {
-                        push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_NOT_RET'=>1}
+                unless ( $dont_checkin ) {
+                    $qonloan->execute($barcode);
+                    if ($qonloan->rows){
+                        my $data = $qonloan->fetchrow_hashref;
+                        my ($doreturn, $messages, $iteminformation, $borrower) =AddReturn($barcode, $data->{homebranch});
+                        if ($doreturn){
+                            push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_RET'=>1}
+                        } else {
+                            push @errorloop, {'barcode'=>$barcode,'ERR_ONLOAN_NOT_RET'=>1}
+                        }
                     }
                 }
             } else {
-- 
1.9.1