From 309f4face90a83ebb3e2d9844656c0e8dfb79374 Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Thu, 7 Feb 2008 18:49:37 +0100 Subject: [PATCH] bugfixing inventory Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Items.pm | 11 +++++++--- .../prog/en/modules/tools/inventory.tmpl | 11 ++++++++++ tools/inventory.pl | 20 ++++++++++++++++--- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index fef96cb90b..049be3fae7 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -913,7 +913,7 @@ offset & size can be used to retrieve only a part of the whole listing (defaut b =cut sub GetItemsForInventory { - my ( $minlocation, $maxlocation,$location, $datelastseen, $branch, $offset, $size ) = @_; + my ( $minlocation, $maxlocation,$location, $itemtype, $datelastseen, $branch, $offset, $size ) = @_; my $dbh = C4::Context->dbh; my $sth; if ($datelastseen) { @@ -921,12 +921,14 @@ sub GetItemsForInventory { my $query = "SELECT itemnumber,barcode,itemcallnumber,title,author,biblio.biblionumber,datelastseen FROM items - LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber + LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber + LEFT JOIN biblioitems on items.biblionumber=biblioitems.biblionumber WHERE itemcallnumber>= ? AND itemcallnumber <=? AND (datelastseen< ? OR datelastseen IS NULL)"; $query.= " AND items.location=".$dbh->quote($location) if $location; $query.= " AND items.homebranch=".$dbh->quote($branch) if $branch; + $query.= " AND biblioitems.itemtype=".$dbh->quote($itemtype) if $itemtype; $query .= " ORDER BY itemcallnumber,title"; $sth = $dbh->prepare($query); $sth->execute( $minlocation, $maxlocation, $datelastseen ); @@ -935,16 +937,19 @@ sub GetItemsForInventory { my $query =" SELECT itemnumber,barcode,itemcallnumber,biblio.biblionumber,title,author,datelastseen FROM items - LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber + LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber + LEFT JOIN biblioitems on items.biblionumber=biblioitems.biblionumber WHERE itemcallnumber>= ? AND itemcallnumber <=?"; $query.= " AND items.location=".$dbh->quote($location) if $location; $query.= " AND items.homebranch=".$dbh->quote($branch) if $branch; + $query.= " AND biblioitems.itemtype=".$dbh->quote($itemtype) if $itemtype; $query .= " ORDER BY itemcallnumber,title"; $sth = $dbh->prepare($query); $sth->execute( $minlocation, $maxlocation ); } my @results; + $size--; while ( my $row = $sth->fetchrow_hashref ) { $offset-- if ($offset); $row->{datelastseen}=format_date($row->{datelastseen}); 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 e6342c78ee..36fc9807c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tmpl @@ -31,6 +31,15 @@ +
  • + + +
  • " /> (items.itemcallnumber)
  • @@ -155,6 +164,7 @@ " /> " /> " /> + @@ -167,6 +177,7 @@ " /> " /> " /> + diff --git a/tools/inventory.pl b/tools/inventory.pl index d10cbdeb29..e74a19242d 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -33,6 +33,7 @@ my $minlocation=$input->param('minlocation') || 'A'; my $maxlocation=$input->param('maxlocation'); $maxlocation=$minlocation.'Z' unless $maxlocation; my $location=$input->param('location'); +my $itemtype=$input->param('itemtype'); my $datelastseen = $input->param('datelastseen'); my $offset = $input->param('offset'); my $markseen = $input->param('markseen'); @@ -62,12 +63,25 @@ for my $branch_hash (keys %$branches) { selected => ($branch_hash eq $branchcode?1:0)}; } + +my $itemtypes = GetItemTypes; +my @itemtypesloop; +foreach my $thisitemtype (sort keys %$itemtypes) { + my $selected = 1 if $thisitemtype eq $itemtype; + my %row =(value => $thisitemtype, + selected => $selected, + description => $itemtypes->{$thisitemtype}->{'description'}, + ); + push @itemtypesloop, \%row; +} +$template->param(itemtypeloop => \@itemtypesloop); + my @authorised_value_list; my $authorisedvalue_categories; my $dbh=C4::Context->dbh; -my $rqauthcategorie=$dbh->prepare("select authorised_value from marc_subfield_structure where frameworkcode=? and kohafield='items.location'"); -my $rq=$dbh->prepare("select frameworkcode from biblio_framework"); +my $rqauthcategorie=$dbh->prepare("SELECT authorised_value FROM marc_subfield_structure WHERE frameworkcode=? AND kohafield='items.location'"); +my $rq=$dbh->prepare("SELECT frameworkcode FROM biblio_framework"); $rq->execute; while (my ($fwkcode)=$rq->fetchrow){ $rqauthcategorie->execute($fwkcode); @@ -140,7 +154,7 @@ if ($uploadbarcodes && length($uploadbarcodes)>0){ } } if ($markseen or $op) { - my $res = GetItemsForInventory($minlocation,$maxlocation,$location,$datelastseen,$branchcode,$offset,$pagesize); + my $res = GetItemsForInventory($minlocation,$maxlocation,$location,$itemtype,$datelastseen,$branchcode,$offset,$pagesize); $template->param(loop =>$res, nextoffset => ($offset+$pagesize), prevoffset => ($offset?$offset-$pagesize:0), -- 2.39.5