=over 4
-$itemlist = GetItemsForInventory($minlocation,$maxlocation,$datelastseen,$offset,$size)
+$itemlist = GetItemsForInventory($minlocation, $maxlocation, $location, $itemtype $datelastseen, $branch, $offset, $size);
=back
Retrieve a list of title/authors/barcode/callnumber, for biblio inventory.
-The sub returns a list of hashes, containing itemnumber, author, title, barcode & item callnumber.
-It is ordered by callnumber,title.
+The sub returns a reference to a list of hashes, each containing
+itemnumber, author, title, barcode, item callnumber, and date last
+seen. It is ordered by callnumber then title.
-The minlocation & maxlocation parameters are used to specify a range of item callnumbers
+The required minlocation & maxlocation parameters are used to specify a range of item callnumbers
the datelastseen can be used to specify that you want to see items not seen since a past date only.
offset & size can be used to retrieve only a part of the whole listing (defaut behaviour)
sub GetItemsForInventory {
my ( $minlocation, $maxlocation,$location, $itemtype, $datelastseen, $branch, $offset, $size ) = @_;
my $dbh = C4::Context->dbh;
- my $sth;
+
+ my $query = <<'END_SQL';
+SELECT 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
+WHERE itemcallnumber >= ?
+ AND itemcallnumber <= ?
+END_SQL
+ my @bind_params = ( $minlocation, $maxlocation );
+
if ($datelastseen) {
- $datelastseen=format_date_in_iso($datelastseen);
- my $query =
- "SELECT 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
- 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 );
+ $datelastseen = format_date_in_iso($datelastseen);
+ $query .= ' AND (datelastseen < ? OR datelastseen IS NULL) ';
+ push @bind_params, $datelastseen;
}
- else {
- my $query ="
- SELECT itemnumber,barcode,itemcallnumber,biblio.biblionumber,title,author,datelastseen
- FROM items
- 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 );
+
+ if ( $location ) {
+ $query.= ' AND items.location = ? ';
+ push @bind_params, $location;
+ }
+
+ if ( $branch ) {
+ $query.= ' AND items.homebranch = ? ';
+ push @bind_params, $branch;
}
+
+ if ( $itemtype ) {
+ $query.= ' AND biblioitems.itemtype = ? ';
+ push @bind_params, $itemtype;
+ }
+
+ $query .= ' ORDER BY itemcallnumber, title';
+ my $sth = $dbh->prepare($query);
+ $sth->execute( @bind_params );
+
my @results;
$size--;
while ( my $row = $sth->fetchrow_hashref ) {
my ($lib) = $sthnflstatus->fetchrow;
$data->{notforloanvalue} = $lib;
}
+ $data->{itypenotforloan} = $data->{notforloan} if (C4::Context->preference('item-level_itypes'));
# my stack procedures
my $stackstatus = $dbh->prepare(
ccode = ?,
itype = ?,
materials = ?,
- uri = ?,
+ uri = ?,
enumchron = ?,
- more_subfields_xml = ?
+ more_subfields_xml = ?,
+ copynumber = ?
";
my $sth = $dbh->prepare($query);
$sth->execute(
$item->{'materials'},
$item->{'uri'},
$item->{'enumchron'},
- $item->{'more_subfields_xml'},
+ $item->{'more_subfields_xml'},
+ $item->{'copynumber'},
);
my $itemnumber = $dbh->{'mysql_insertid'};
if ( defined $sth->errstr ) {