sub GetItemsForInventory {
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 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
-WHERE itemcallnumber >= ?
- AND itemcallnumber <= ?
END_SQL
- my @bind_params = ( $minlocation, $maxlocation );
+
+ if ($minlocation) {
+ push @where_strings, 'itemcallnumber >= ?';
+ push @bind_params, $minlocation;
+ }
+
+ if ($maxlocation) {
+ push @where_strings, 'itemcallnumber <= ?';
+ push @bind_params, $maxlocation;
+ }
if ($datelastseen) {
$datelastseen = format_date_in_iso($datelastseen);
- $query .= ' AND (datelastseen < ? OR datelastseen IS NULL) ';
+ push @where_strings, '(datelastseen < ? OR datelastseen IS NULL)';
push @bind_params, $datelastseen;
}
if ( $location ) {
- $query.= ' AND items.location = ? ';
+ push @where_strings, 'items.location = ?';
push @bind_params, $location;
}
if ( $branch ) {
- $query.= ' AND items.homebranch = ? ';
+ push @where_strings, 'items.homebranch = ?';
push @bind_params, $branch;
}
if ( $itemtype ) {
- $query.= ' AND biblioitems.itemtype = ? ';
+ push @where_strings, 'biblioitems.itemtype = ?';
push @bind_params, $itemtype;
}
if ( $ignoreissued) {
use C4::Branch; # GetBranches
my $input = new CGI;
-my $minlocation=$input->param('minlocation') || 'A';
+my $minlocation=$input->param('minlocation') || '';
my $maxlocation=$input->param('maxlocation');
-$maxlocation=$minlocation.'Z' unless $maxlocation;
+$maxlocation=$minlocation.'Z' unless ( $maxlocation || ! $minlocation );
my $location=$input->param('location');
my $itemtype=$input->param('itemtype');
my $ignoreissued=$input->param('ignoreissued');