| Current Path : /var/www/html/mmishra/ilight/ |
| Current File : /var/www/html/mmishra/ilight/elsubsidy.inc |
<h3>Admissibility</h3>
<center>
<?php
$tbl = "el_subsidy";
$id = $_REQUEST["id"];
$category = $_POST["category"];
$userfees = $_POST["userfees"];
$subsidymode = $_POST["subsidymode"];
$subsidy = $_POST["subsidy"];
$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 category='$category',userfees=$userfees,subsidymode='$subsidymode',subsidy=$subsidy,dated=now()
where id=$id");
} else {
mysql_query("insert into $tbl(category,userfees,subsidymode,subsidy,dated)
values('$category',$userfees,'$subsidymode',$subsidy,now())");
}
} else if ($_POST["submit"] == 'SAVE') {
mysql_query("delete from $tbl where id='$id");
}
echo "
<table width='70%' border='1' style='border-collapse: collapse'>
<tr><th>No</th><th>Group</th><th>User Fees (Rs.)</th><th>Admissibility Mode</th><th>Admissibility</th><th>Dated</td></tr>";
echo "<tr><td><a name='new'>New</a></td>";
if (!$id) {
echo "<td><select name='category'>";
foreach(get_enum_values('el_subsidy', 'category') as $c) {
echo "<option value='$c'>$c</option>";
}
echo "</select></td>
<td><input type='text' name='userfees' size='10' value='0.00'></td>
<td><select name='subsidymode'>";
foreach(get_enum_values('el_subsidy', 'subsidymode') as $c) {
echo "<option value='$c'>$c</option>";
}
echo "</select></td>
<td><input type='text' name='subsidy' size='10' value='0.00'></td>
<input type='hidden' name='id' value='0'></td><td>$dated</td></tr>
<tr><th colspan='6'><input type='submit' name='submit' value='SAVE'></th>";
} else {
echo "<td colspan='4'><a href='?pg=$pg&id=#new'>Admissibility</a></td>";
}
echo "</tr>";
//existing records
$rs = mysql_query("select * from $tbl order by category");
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td><a href='?pg=$pg&id=$o->id#s$i' name='s$i'>$i</a></td>";
if ($o->id == $id) {
echo "
<td><select name='category'>";
foreach(get_enum_values('el_subsidy', 'category') as $c) {
echo "<option value='$c'";
if ($c == $o->category) echo " selected";
echo ">$c</option>";
}
echo "</select></td>
<td><input type='text' name='userfees' size='10' value='$o->userfees'></td>
<td><select name='subsidymode'>";
foreach(get_enum_values('el_subsidy', 'subsidymode') as $c) {
echo "<option value='$c'".($o->subsidymode == $c ? ' selected' : '').">$c</option>";
}
echo "</select></td>
<td><input type='text' name='subsidy' size='10' value='$o->subsidy'></td>
<td><input type='hidden' name='id' value='$o->id'>$dated</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->category</th><td>$o->userfees</td><td>$o->subsidymode</td><td>$o->subsidy</td><td>$o->dated</td>";
}
echo "</tr>";
}
?>
</table>
</center>