From 2e3302a8cea1c37bd2769c528ab6495fa7619bf0 Mon Sep 17 00:00:00 2001 From: Michael Hafen Date: Tue, 24 Feb 2009 12:05:50 -0700 Subject: [PATCH] Add option to inventory tool to ignore copies on loan 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 Signed-off-by: Henri-Damien LAURENT --- C4/Items.pm | 12 ++++++++++-- .../prog/en/modules/tools/inventory.tmpl | 6 ++++++ tools/inventory.pl | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index 81ec0c9af8..86bf024ad2 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1024,11 +1024,11 @@ 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 $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 @@ -1057,7 +1057,15 @@ END_SQL $query.= ' AND biblioitems.itemtype = ? '; 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; + } $query .= ' ORDER BY itemcallnumber, title'; my $sth = $dbh->prepare($query); $sth->execute( @bind_params ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tmpl index 6baa2ab30a..dd55b069e4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tmpl @@ -103,6 +103,12 @@ $(document).ready(function(){ ); +
  • + +
  • + + +
  • " maxlength="5" size="5" /> items
  • diff --git a/tools/inventory.pl b/tools/inventory.pl index a144b17ff9..c9c5a94d05 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -34,6 +34,7 @@ my $maxlocation=$input->param('maxlocation'); $maxlocation=$minlocation.'Z' unless $maxlocation; 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), -- 2.39.5