Location: PHPKode > projects > EzyBiz > ezybiz/invitemlstphys.php
<? include('includes/main.php'); ?>
<? //invitemlstdist.php
templatetop('Item List - Physical');
//$conn->debug = true;
echo '<form action="invitemlstphys.php" method="post" name="mainform">
<table border="1">';
if (isset($_POST["maxid"]))
{
	foreach ($_POST["item"] AS $itemid => $value)
	{
			$query = "UPDATE itemlocation SET itemlocation.onhandqty=".sqlprep($_POST[$value])." WHERE itemlocation.id=".sqlprep($value)."";
			$conn->Execute($query)or $errors->raiseError(101,$query,mysql_error(),__LINE__,__FILE__);
	}
}

if ($_POST["order"])
{  //  After the user select an item warehouse and 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 ($_POST["location"])
	{
		$locationstr = ' and inventorylocation.id='.sqlprep($_POST["location"]);
	}

	if ($_POST["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($_SESSION["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(texterrorend('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>
		';
		$counter = 0;
		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="hidden" name="item['.$counter.']" value="'.$recordSet->fields[0].'">
					<input type="text" name="'.$recordSet->fields[0].'" size="10" maxlength="10" value="'.$recordSet->fields[5].'">
				</td>
				<td>'.$recordSet->fields[6].'</td>
			</tr>
			';
			$counter++;
			$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($_SESSION["active_company"]).' and itemlocation.inventorylocationid=inventorylocation.id and
		company.id=inventorylocation.companyid'.$locationstr.' order by company.companyname, item.itemcode');

		if ($recordSet->EOF)
		{
			die(texterrorend('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].'" size="10" maxlength="10" value="'.$recordSet->fields[5].'">
				</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($_SESSION["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(texterrorend('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].'" size="10" maxlength="10" value="'.$recordSet->fields[5].'">
				</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($_SESSION["active_company"]).' and itemlocation.inventorylocationid=inventorylocation.id and
		company.id=inventorylocation.companyid'.$locationstr.' order by item.itemcode, company.companyname'
		);

		if ($recordSet->EOF)
		{
			die(texterrorend('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].'" size="10" maxlength="10" value="'.$recordSet->fields[5].'">
				</td>
				<td>'.$recordSet->fields[6].'</td>
			</tr>
			';
			$recordSet->MoveNext();
		};
		echo '
		</table>
		';
	}
	echo '
	<br>
	<input type="submit" value="Submit">
	';
}
else
{ // This code section displayed a drop down box for selecting the item warehouse and order.
	$recordSet =
	&$conn->Execute(
		'select count(*) from inventorylocation,company where company.id=inventorylocation.companyid and
		company.cancel=0 and inventorylocation.gencompanyid='.sqlprep($_SESSION["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
						company.cancel=0 and inventorylocation.gencompanyid='.sqlprep($_SESSION["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.'>
					<option value="lci">Location, Category, Item Code
					<option value="li">Location, Item Code
					<option value="cil">Category, Item Code, Location
					<option value="il">Item Code, Location
				</select>
			</td>
		</tr>
		</table>
		<input type="submit" value="Create Report / Enter Counts">
		</form>
		';
	templatebottom();
};
?>
<? include('includes/footer.php'); ?>
Return current item: EzyBiz