| Current Path : /var/www/html/mmishra/istore/ |
| Current File : /var/www/html/mmishra/istore/stsubcategory.inc |
<h3>Item Description</h3>
<?php
$tbl = "st_subcategory";
$id = $_REQUEST["id"];
$code = $_POST["code"];
$itemtype = $_POST["item_type"];
$description = $_POST["description"];
$category = $_REQUEST["category"];
$qtysafe = $_REQUEST["qty_safe"];
$dated = date("Y-m-d");
if ($_POST["submit"] == 'SAVE') {
if (mysql_num_rows(mysql_query("select * from $tbl where id=$id"))) {
mysql_query("update $tbl set code='$code',item_type='$itemtype',description='$description',category=$category,qty_safe=$qtysafe,loginID='$user'
where id=$id");
} else {
mysql_query("insert into $tbl(code,item_type,description,category,qty_safe,loginID)
values('$code','$itemtype','$description',$category,$qtysafe,'$user')");
}
} else if ($_POST["submit"] == 'DELETE') {
mysql_query("delete from $tbl where id=$id");
}
echo "Select category <select name='category' onchange=\"javascript: document.location.href='?pg=$pg&category='+this.value\">
<option value=''></option>";
$rs = mysql_query("select id,code from st_category order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $category) echo " selected";
echo ">$o->code</option>";
}
echo "</select>
<br><br><center>";
if ($category) {
echo "<table width='80%' border='1' style='border-collapse: collapse'>
<tr><th>No</th><th>Code</th><th>A/c Nature</th><th>Description</th><th>Safe Qty</th><th>Dated</th></tr>";
echo "<tr><td><a name='new'>+</a></td>";
if (!$id) {
echo "<td><input type='text' name='code' size='30' value=''></td>
<td><select name='item_type'>";
foreach ($itemtypes as $itp) {
echo "<option value='$itp'".($itp == $itemtype ? ' selected' : '').">$itp</option>";
}
echo "</select></td>
<td><input type='text' name='description' size='50' value=''></td>
<td><input type='text' name='qty_safe' size='5' value='0'></td>
<td>$dated<input type='hidden' name='id' value='0'></td></tr>
<tr><th colspan='5'><input type='submit' name='submit' value='SAVE'></th>";
} else {
echo "<td colspan='5'><a href='?pg=$pg&category=$category&id=#new'>Item</a></td>";
}
echo "</tr>";
//existing records
$rs = mysql_query("select * from $tbl where category=$category order by id");
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td><a name='$i' href='?pg=$pg&category=$category&id=$o->id#$i'>$i</a></td>";
if ($o->id == $id) {
echo "<td><input type='text' name='code' size='30' value='$o->code'></td>
<td><select name='item_type'>";
foreach ($itemtypes as $itp) {
echo "<option value='$itp'".($itp == $o->item_type ? ' selected' : '').">$itp</option>";
}
echo "</select></td>
<td><input type='text' name='description' size='50' value='$o->description'></td>
<td><input type='text' name='qty_safe' size='5' value='$o->qty_safe'></td>
<td>$dated<input type='hidden' name='id' value='$o->id'></td></tr>
<tr><th colspan='5'><input type='submit' name='submit' value='SAVE'></th>
<th><input type='submit' name='submit' value='DELETE'></th>";
} else {
echo "<th>$o->code</th><td>$o->item_type</td><td>$o->description</td><td>$o->qty_safe</td><td>$o->dateCreation</td>";
}
echo "</tr>";
}
echo "</table>";
}
?>
</center>