<? include('includes/main.php'); ?>
<? //invitemlstdist.php
echo texttitle('Item List - Physical');
echo '<form action="invitemlstphys.php" method="post" name="mainform"><table>';
if ($order) {
if ($maxid) {
for ($counter=0; $maxid>=$counter; $counter++) {
if (isset($$counter)) if ($conn->Execute("update itemlocation set itemlocation.onhandqty=".sqlprep($$counter)." where itemlocation.id=".sqlprep($counter)) === false) echo "<b>Error updating item.</b><br>\n";
};
};
echo '<input type="hidden" name="order" value="'.$order.'">';
echo '<input type="hidden" name="location" value="'.$location.'">';
$recordSet = &$conn->Execute('select max(itemlocation.id) from itemlocation');
if (!$recordSet->EOF) echo '<input type="hidden" name="maxid" value="'.$recordSet->fields[0].'">';
if ($location) $locationstr=' and inventorylocation.id='.sqlprep($location);
if ($order=="lci") {
$recordSet = &$conn->Execute('select itemlocation.id, company.companyname, itemcategory.name, item.itemcode, item.description, itemlocation.onhandqty, unitname.unitname from item,inventorylocation,itemcategory,company,unitname,itemlocation where itemlocation.itemid=item.id and itemcategory.id=item.categoryid and item.stockunitnameid=unitname.id and item.companyid='.sqlprep($active_company).' and itemlocation.inventorylocationid=inventorylocation.id and company.id=inventorylocation.companyid'.$locationstr.' order by company.companyname, itemcategory.name, item.itemcode');
if ($recordSet->EOF) die(texterror('No matching items found.'));
echo '<table border="1"><tr><th>Location</th><th>Category</th><th>Item Code</th><th>Item Name</th><th>Qty on hand</th><th>Stock Units</th></tr>';
while (!$recordSet->EOF) {
echo '<tr><td><b>'.$recordSet->fields[1].'</b></td><td>'.$recordSet->fields[2].'</td><td>'.$recordSet->fields[3].'</td><td>'.$recordSet->fields[4].'</td><td><input type="text" name="'.$recordSet->fields[0].'" onchange="validatenum(this)" size="10" maxlength="10" value="'.$recordSet->fields[5].'"'.INC_TEXTBOX.'></td><td>'.$recordSet->fields[6].'</td></tr>';
$recordSet->MoveNext();
};
echo '</table>';
} elseif ($order=="li") {
$recordSet = &$conn->Execute('select item.id, company.companyname, item.itemcode, item.description, itemcategory.name, itemlocation.onhandqty, unitname.unitname from item,inventorylocation,itemcategory,company,unitname,itemlocation where itemlocation.itemid=item.id and itemcategory.id=item.categoryid and item.stockunitnameid=unitname.id and item.companyid='.sqlprep($active_company).' and itemlocation.inventorylocationid=inventorylocation.id and company.id=inventorylocation.companyid'.$locationstr.' order by company.companyname, item.itemcode');
if ($recordSet->EOF) die(texterror('No matching items found.'));
echo '<table border="1"><tr><th>Location</th><th>Item Code</th><th>Item Name</th><th>Category</th><th>Qty on hand</th><th>Stock Units</th></tr>';
while (!$recordSet->EOF) {
echo '<tr><td><b>'.$recordSet->fields[1].'</b></td><td>'.$recordSet->fields[2].'</td><td>'.$recordSet->fields[3].'</td><td>'.$recordSet->fields[4].'</td><td><input type="text" name="'.$recordSet->fields[0].'" onchange="validatenum(this)" size="10" maxlength="10" value="'.$recordSet->fields[5].'"'.INC_TEXTBOX.'></td><td>'.$recordSet->fields[6].'</td></tr>';
$recordSet->MoveNext();
};
echo '</table>';
} elseif ($order=="cil") {
$recordSet = &$conn->Execute('select item.id, itemcategory.name, item.itemcode, item.description, company.companyname, itemlocation.onhandqty, unitname.unitname from item,inventorylocation,itemcategory,company,unitname,itemlocation where itemlocation.itemid=item.id and itemcategory.id=item.categoryid and item.stockunitnameid=unitname.id and item.companyid='.sqlprep($active_company).' and itemlocation.inventorylocationid=inventorylocation.id and company.id=inventorylocation.companyid'.$locationstr.' order by itemcategory.name, item.itemcode, company.companyname');
if ($recordSet->EOF) die(texterror('No matching items found.'));
echo '<table border="1"><tr><th>Category</th><th>Item Code</th><th>Item Name</th><th>Location</th><th>Qty on hand</th><th>Stock Units</th></tr>';
while (!$recordSet->EOF) {
echo '<tr><td><b>'.$recordSet->fields[1].'</b></td><td>'.$recordSet->fields[2].'</td><td>'.$recordSet->fields[3].'</td><td>'.$recordSet->fields[4].'</td><td><input type="text" name="'.$recordSet->fields[0].'" onchange="validatenum(this)" size="10" maxlength="10" value="'.$recordSet->fields[5].'"'.INC_TEXTBOX.'></td><td>'.$recordSet->fields[6].'</td></tr>';
$recordSet->MoveNext();
};
echo '</table>';
} elseif ($order=="il") {
$recordSet = &$conn->Execute('select item.id, item.itemcode, item.description, company.companyname, itemcategory.name, itemlocation.onhandqty, unitname.unitname from item,inventorylocation,itemcategory,company,unitname,itemlocation where itemlocation.itemid=item.id and itemcategory.id=item.categoryid and item.stockunitnameid=unitname.id and item.companyid='.sqlprep($active_company).' and itemlocation.inventorylocationid=inventorylocation.id and company.id=inventorylocation.companyid'.$locationstr.' order by item.itemcode, company.companyname');
if ($recordSet->EOF) die(texterror('No matching items found.'));
echo '<table border="1"><tr><th>Item Code</th><th>Item Name</th><th>Location</th><th>Category</th><th>Qty on hand</th><th>Stock Units</th></tr>';
while (!$recordSet->EOF) {
echo '<tr><td><b>'.$recordSet->fields[1].'</b></td><td>'.$recordSet->fields[2].'</td><td>'.$recordSet->fields[3].'</td><td>'.$recordSet->fields[4].'</td><td><input type="text" name="'.$recordSet->fields[0].'" onchange="validatenum(this)" size="10" maxlength="10" value="'.$recordSet->fields[5].'"'.INC_TEXTBOX.'></td><td>'.$recordSet->fields[6].'</td></tr>';
$recordSet->MoveNext();
};
echo '</table>';
};
echo '<br><input type="submit" value="Submit">';
} else {
$recordSet = &$conn->Execute('select count(*) from inventorylocation,company where company.id=inventorylocation.companyid and inventorylocation.gencompanyid='.sqlprep($active_company));
if (!$recordSet->EOF) if ($recordSet->fields[0]>1) {
echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Location:</td><td><select name="location"'.INC_TEXTBOX.'><option value="0">All';
$recordSet = &$conn->Execute('select inventorylocation.id,company.companyname from inventorylocation,company where company.id=inventorylocation.companyid and inventorylocation.gencompanyid='.sqlprep($active_company).' order by company.companyname');
while (!$recordSet->EOF) {
echo '<option value="'.$recordSet->fields[0].'">'.$recordSet->fields[1]."\n";
$recordSet->MoveNext();
};
echo '</select></td></tr>';
};
echo '<tr><td align="'.TABLE_LEFT_SIDE_ALIGN.'">Sort By:</td><td><select name="order"'.INC_TEXTBOX.'>';
echo '<option value="lci">Location, Category, Item Code';
echo '<option value="li">Location, Item Code';
echo '<option value="cil">Category, Item Code, Location';
echo '<option value="il">Item Code, Location';
echo '</select></td></tr>';
echo '</table><input type="submit" value="Create Report / Enter Counts"></form>';
};
?>
<? include('includes/footer.php'); ?>