Add option to inventory tool to ignore copies on loan
authorMichael Hafen <mdhafen@tech.washk12.org>
Tue, 24 Feb 2009 19:05:50 +0000 (12:05 -0700)
committerGalen Charlton <galen.charlton@liblime.com>
Wed, 25 Feb 2009 22:32:30 +0000 (16:32 -0600)
This adds an option to the inventory tool causing it to ignore copies
currently on loan.  This is good if you want to do inventory, but don't
want to update the date-last-seen on items currently on loan.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
C4/Items.pm
koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tmpl
tools/inventory.pl

index 457c91f..dcac099 100644 (file)
@@ -976,12 +976,12 @@ offset & size can be used to retrieve only a part of the whole listing (defaut b
 =cut
 
 sub GetItemsForInventory {
-    my ( $minlocation, $maxlocation,$location, $itemtype, $datelastseen, $branch, $offset, $size ) = @_;
+    my ( $minlocation, $maxlocation,$location, $itemtype, $ignoreissued, $datelastseen, $branch, $offset, $size ) = @_;
     my $dbh = C4::Context->dbh;
     my ( @bind_params, @where_strings );
 
     my $query = <<'END_SQL';
-SELECT itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, datelastseen
+SELECT items.itemnumber, barcode, itemcallnumber, title, author, biblio.biblionumber, datelastseen
 FROM items
   LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber
   LEFT JOIN biblioitems on items.biblionumber = biblioitems.biblionumber
@@ -1018,6 +1018,11 @@ END_SQL
         push @bind_params, $itemtype;
     }
 
+    if ( $ignoreissued) {
+        $query .= "LEFT JOIN issues ON items.itemnumber = issues.itemnumber ";
+        push @where_strings, 'issues.date_due IS NULL';
+    }
+
     if ( @where_strings ) {
         $query .= 'WHERE ';
         $query .= join ' AND ', @where_strings;
index 534482e..0e6183b 100644 (file)
@@ -103,6 +103,12 @@ $(document).ready(function(){
             );
             </script>
         </li>
+        <li><label for="ignoreissued">Skip copies on loan: </label>
+            <!-- TMPL_IF NAME="ignoreissued" -->
+            <input type="checkbox" id="ignoreissued" name="ignoreissued" checked="checked" /></li>
+            <!-- TMPL_ELSE -->
+            <input type="checkbox" id="ignoreissued" name="ignoreissued" /></li>
+            <!-- /TMPL_IF -->
         <li><label for="pagesize">Show: </label>
             <input type="text" id="pagesize" name="pagesize" value="<!-- TMPL_VAR NAME="pagesize" -->" maxlength="5" size="5" /> items</li>
           <li><label for="offset">Beginning at offset: </label>
index 16aa6b0..4fa9c94 100755 (executable)
@@ -34,6 +34,7 @@ my $maxlocation=$input->param('maxlocation');
 $maxlocation=$minlocation.'Z' unless ( $maxlocation || ! $minlocation );
 my $location=$input->param('location');
 my $itemtype=$input->param('itemtype');
+my $ignoreissued=$input->param('ignoreissued');
 my $datelastseen = $input->param('datelastseen');
 my $offset = $input->param('offset');
 my $markseen = $input->param('markseen');
@@ -105,6 +106,7 @@ $template->param(branchloop => \@branch_loop,
                 minlocation => $minlocation,
                 maxlocation => $maxlocation,
                 location=>$location,
+                ignoreissued=>$ignoreissued,
                 branchcode=>$branchcode,      
                 offset => $offset,
                 pagesize => $pagesize,
@@ -154,7 +156,7 @@ if ($uploadbarcodes && length($uploadbarcodes)>0){
         }
     }
     if ($markseen or $op) {
-        my $res = GetItemsForInventory($minlocation,$maxlocation,$location,$itemtype,$datelastseen,$branchcode,$offset,$pagesize);
+        my $res = GetItemsForInventory($minlocation,$maxlocation,$location,$itemtype,$ignoreissued,$datelastseen,$branchcode,$offset,$pagesize);
         $template->param(loop =>$res,
                         nextoffset => ($offset+$pagesize),
                         prevoffset => ($offset?$offset-$pagesize:0),