bugfixing inventory

Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Paul POULAIN 2008-02-07 18:49:37 +01:00 committed by Joshua Ferraro
parent db0428c8c0
commit 309f4face9
3 changed files with 36 additions and 6 deletions

View File

@ -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});

View File

@ -31,6 +31,15 @@
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<label for="itemtype">Item type</label>
<select name="itemtype">
<option value="">Any</option>
<!-- TMPL_LOOP name="itemtypeloop" -->
<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="description" --></option>
<!-- /TMPL_LOOP -->
</select>
</li>
<li>
<label for="minlocation">Item location between: </label>
<input type="text" name="minlocation" id="minlocation" value="<!-- TMPL_VAR NAME="minlocation" -->" /> (items.itemcallnumber) </li>
@ -155,6 +164,7 @@
<input type="hidden" name="datelastseen" value="<!-- TMPL_VAR NAME="datelastseen" -->" />
<input type="hidden" name="pagesize" value="<!-- TMPL_VAR NAME="pagesize" -->" />
<input type="hidden" name="offset" value="<!-- TMPL_VAR NAME="prevoffset" -->" />
<input type="hidden" name="op" value="do_it" />
<input type="submit" value="&lt;&lt;" class="button" />
</form>
<!-- /TMPL_IF -->
@ -167,6 +177,7 @@
<input type="hidden" name="datelastseen" value="<!-- TMPL_VAR NAME="datelastseen" -->" />
<input type="hidden" name="pagesize" value="<!-- TMPL_VAR NAME="pagesize" -->" />
<input type="hidden" name="offset" value="<!-- TMPL_VAR NAME="nextoffset" -->" />
<input type="hidden" name="op" value="do_it" />
<input type="submit" value="&gt;&gt;" class="button" />
</form>
<!-- /TMPL_IF -->

View File

@ -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),