| Current Path : /var/www/html/mmishra/iws8/html/ilight/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/ellicensee.inc |
<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';
$datealloted = $_POST["datealloted"];
$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='$datealloted',sharing='$sharing',external='$external',dated=now()
where id=$id");
} else {
mysql_query("insert into $tbl(flatno,fullname,designation,email,category,datealloted,sharing,external,dated)
values('$flatno','$fullname','$designation','$email','$category','$dated','$sharing','$external',now())");
}
} else if ($_POST["submit"] == 'DELETE') {
mysql_query("delete from $tbl where id=$id");
}
echo "<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'> ] </font><input type='hidden' name='external' value='$external'>
<table width='90%'><tr><th>Select Licensee Group ";
//get categories for report
$rs = mysql_query("select distinct category from el_licensee where external='$external'");
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='FILTER'></th></tr></table>";
?>
<table width='100%' border='1' style='border-collapse: collapse'>
<tr><th>No</th><th>SiteNo</th><th>Licensee</th><th>Group</th><th>Dated</th></tr>
<tr valign='top'><td><a name='new'>New</a></td>
<?php
$sr = mysql_query("select flatno,
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 el_flats where flatno not in (select flatno from el_licensee)
order by left(flatno, pos-1), mid(flatno, pos, length(flatno)-pos+1)+0");
if (!$id) {
echo "<th><select name='flatno'>";
while ($q = mysql_fetch_object($sr)) {
echo "<option value='$q->flatno'>$q->flatno</option>";
}
echo "</select></th>
<td nowrap><input type='text' name='fullname' size='30' value='Name'>
(<input type='text' name='designation' size='30' value='Designation'>)
<input type='text' name='email' size='30' value='Email'>
[ <input type='checkbox' name='sharing' value='Yes'>Sharing ? ]</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='datealloted' size='10' value='$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='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'".($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><select name='flatno'>
<option value='$o->flatno'>$o->flatno</option>";
while ($q = mysql_fetch_object($sr)) {
echo "<option value='$q->flatno'".($q->flatno == $o->flatno ? ' selected' : '').">$q->flatno</option>";
}
echo "<option value='None'>None</option></select></th>
<td nowrap><input type='text' name='fullname' size='30' value='$o->fullname'>
(<input type='text' name='designation' size='30' value='$o->designation'>)
<input type='text' name='email' size='30' value='$o->email'>
[ <input type='checkbox' name='sharing' value='Yes'".($o->sharing == 'Yes' ? ' checked' : '').">Sharing ? ]</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='datealloted' size='10' value='$o->datealloted'> <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>$o->fullname ($o->designation) $o->email ".($o->sharing == 'Yes' ? "[ <font color='red'>Sharing: $o->sharing</font> ]" : '')."</td>
<td>$o->category</td><td>$o->datealloted</td>";
}
echo "</tr>";
}
?>
</table>
</center>