| Current Path : /var/www/html/mmishra/iws8/html/ilight/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/stbills.inc |
<h3>Bill/Challan Receipt</h3>
<?php
$tbl = "st_bills";
$id = $_REQUEST["id"];
$billno = $_POST["bill_no"];
$billdate = $_POST['bill_date'];
$supplier = $_POST["supplier"];
$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 bill_no='$billno',bill_date='$billdate',supplier=$supplier,dated=now()
where id=$id");
} else {
mysql_query("insert into $tbl(bill_no,bill_date,supplier,dated)
values('$billno','$billdate',$supplier,now())");
}
}
if ($_POST["submit"] == 'DELETE') {
mysql_query("delete from $tbl where id=$id");
}
?>
<center>
<table width='80%' border='1' style='border-collapse:collapse'>
<tr><th>No</th><th>Bill/Challan No.</th><th>Bill/Challan Date</th><th>Supplier / Firm</th><th>Dated</th></tr>
<?php
if (!$id) {
echo "<tr><td>+</td>
<td><input type='text' name='bill_no' size='10' value=''></td>
<td><input type='text' name='bill_date' size='10' value='$dated'></td>
<td>".supplier_list($supplier)."</td><td>$dated</td></tr>
<tr><th colspan='5'><input type='submit' name='submit' value='SAVE'></th></tr>";
} else {
echo "<tr><td>+</td>
<td colspan='4'><a href='?pg=$pg&id='>Bill/Challan</a></td></tr>";
}
$rs = mysql_query("select * from $tbl order by id");
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td><a href='?pg=$pg&id=$o->id'>$i</a></td>";
if ($id == $o->id) {
echo "<td><input type='text' name='bill_no' size='10' value='$o->bill_no'></td>
<td><input type='text' name='bill_date' size='10' value='$o->bill_date'></td>
<td>".supplier_list($o->supplier)."</td><td>$o->dated <input type='hidden' name='id' value='$o->id'></td></tr>
<tr><th colspan='4'><input type='submit' name='submit' value='SAVE'></th>
<th><input type='submit' name='submit' value='DELETE'></th></tr>";
} else {
echo "<td>$o->bill_no</td><td>$o->bill_date</td><td>".supplier_detail($o->supplier)."</td><td>$o->dated</td></tr>";
}
echo "</tr>";
}
?>
</table>
</center>