Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/ilight/
Upload File :
Current File : /var/www/html/mmishra/ilight/:w

<h3>Current Licensee</h3>
<center>

<?php
$tbl = "el_licensee";

$id = $_REQUEST["id"];
$flatno = $_POST["flatno"];
$fullname = $_POST["fullname"];
$designation = $_POST["designation"];
$email = $_POST["email"];
$category = $_POST["category"];
$cat = $_REQUEST["cat"];
$sharing = $_POST["sharing"];
$external = $_REQUEST["external"];
if (!$external) $external = 'No';
$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 flatno='$flatno',fullname='$fullname',designation='$designation',
		email='$email',category='$category',datealloted='$dated',sharing='$sharing',external='$external',subsidy=$subsidy,dated=now() 
		where id=$id");
	} else {
                mysql_query("insert into $tbl(flatno,fullname,designation,email,category,datealloted,sharing,external,subsidy,dated) 
		values('$flatno','$fullname','$designation','$email','$category','$dated','$sharing','$external',$subsidy,now())");
	}
} else if ($_POST["submit"] == 'DELETE') {
        mysql_query("delete from $tbl where id=$id"); 
}
echo "<table width='100%'>
<tr><td width='25%'>
<font size='+1'>[ </font>";
if ($external == 'Yes') {
        echo "<a href='?pg=$pg&external=No'>Internal</a> | <font color='red' size='+1'>External</font>";
} else {
        echo "<font color='red' size='+1'>Internal</font> | <a href='?pg=$pg&external=Yes'>External</a>";
}
echo "<font size='+1'> ] <input type='hidden' name='external' value='$external'>
</td><th>
<b>Category</b> ";
//get categories for report
$rs = mysql_query("select * from el_subsidy where category<>'Common'");
while ($o = mysql_fetch_object($rs)) {
        echo "<input type='radio' name='cat' value='$o->category'";
        if ($cat == $o->category) echo " checked><font size='+1'>$o->category</font>";
        else echo ">$o->category";
}
echo " <input type='submit' name='submit' value='OK'>
</th><td width='25%' align='right'>
<font size='+1'>[ </font><a href='?pg=$pg&external=$external'>Refresh</a> <font size='+1'>]</font>
</td></tr>
</table>

<table width='80%' border='1' style='border-collapse: collapse'>
<tr><th>No</th><th>SiteNo</th><th>Licensee</th><th>Category</th><th>Subsidy</th></tr>
<tr valign='top'><td><a name='new'>New</a></td>";

if (!$id) {
        echo "<th><input type='text' name='flatno' size='10' value=''></th>
        <td nowrap>Name <input type='text' name='fullname' size='30' value=''><br>
        Desig <input type='text' name='designation' size='30' value=''><br>
        Email <input type='text' name='email' size='30' value=''></td>
        <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='subsidy' size='10' value='0.00'><br>
	<input type='checkbox' name='sharing' value='Yes'>Sharing ?
        <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='4'><a href='?pg=$pg&cat=$cat&external=$external&id=#new'>Licensee</a></td>";
}
echo "</tr>";

//existing records
$rs = mysql_query("select *,
    	least(
      	case when locate('0', flatno)>0 then locate('0', flatno) else length(flatno)+1 end,
      	case when locate('1', flatno)>0 then locate('1', flatno) else length(flatno)+1 end,
      	case when locate('2', flatno)>0 then locate('2', flatno) else length(flatno)+1 end,
      	case when locate('3', flatno)>0 then locate('3', flatno) else length(flatno)+1 end,
      	case when locate('4', flatno)>0 then locate('4', flatno) else length(flatno)+1 end,
      	case when locate('5', flatno)>0 then locate('5', flatno) else length(flatno)+1 end,
      	case when locate('6', flatno)>0 then locate('6', flatno) else length(flatno)+1 end,
      	case when locate('7', flatno)>0 then locate('7', flatno) else length(flatno)+1 end,
      	case when locate('8', flatno)>0 then locate('8', flatno) else length(flatno)+1 end,
      	case when locate('9', flatno)>0 then locate('9', flatno) else length(flatno)+1 end) pos
  	from $tbl where external='$external' and category<>'Common'".($cat ? " and category='$cat'" : '')." 
  	order by left(flatno, pos-1), mid(flatno, pos, length(flatno)-pos+1)+0");

while ($o = mysql_fetch_object($rs)) {
	$i++;
	echo "<tr valign='top'><td><a name='$i' href='?pg=$pg&cat=$cat&external=$external&id=$o->id#$i'>$i</a></td>";
	if ($o->id == $id) {
		echo "
		<th><input type='text' name='flatno' size='10' value='$o->flatno'></th>
		<td nowrap>Name <input type='text' name='fullname' size='30' value='$o->fullname'><br>
		Desig <input type='text' name='designation' size='30' value='$o->designation'><br>
		Email <input type='text' name='email' size='30' value='$o->email'></td>
		<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='subsidy' size='10' value='$o->subsidy'><br>
		<input type='checkbox' name='sharing' value='Yes'".($o->sharing == 'Yes' ? ' checked' : '').">Sharing ?
		<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>";
	} else {
		echo "<th>$o->flatno</th><td nowrap>Name $o->fullname<br>Desig $o->designation<br>Email $o->email</td>
		<td>$o->category</td><td>$o->subsidy<br".($o->sharing == 'Yes' ? "<font color='red'>Sharing: $o->sharing</font>" : '')."</td>";
		$subsidy = 0;
	}
	echo "</tr>";
}
echo "</table>
</center>";
?>