| Current Path : /var/www/html/mmishra/ilight/ |
| Current File : /var/www/html/mmishra/ilight/amannexures.inc |
<h3>Job Annexure</h3>
<?php
$tbl = "am_annexures";
$id = $_REQUEST["id"];
$jobcode = $_POST["jobcode"];
$description = $_POST["description"];
$filename = basename($_FILES['filename']['name']);
if ($filename)
move_uploaded_file($_FILES['filename']['tmp_name'], "attchments/$filename");
else
$file_name = '';
$status = $_POST["status"];
$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 job_code='$jobcode',description='$description',file_name='$filename',status='$status'
where id=$id");
} else {
mysql_query("insert into $tbl(job_code,description,file_name,status,dated)
values('$jobcode','$description','$filename','$status',now())");
echo("insert into $tbl(job_code,description,file_name,status,dated)
values('$jobcode','$description','$filename','$status',now())");
}
}
?>
<center>
<table width='80%' border='1' style='border-collapse: collapse'>
<tr><th>Sr</th><th>Jobode</th><th>Description</th><th>FileName</th><th>Status</th><td align='center'>Action</td></tr>
<?php
echo "<tr><td><a name='new'>New</a></td>";
if (!$id) {
echo "
<td><input type='text' name='jobcode' size='20' value=''></td>
<td><input type='text' name='description' size='50' value=''></td>
<td><input type='file' name='filename' size='20' value=''></td>
<td><select name='status'>";
foreach ($statuss as $s) {
echo "<option value='$s'";
if ($s == $status) echo " selected";
echo ">$s</option>";
}
echo "</select></td>
<td><input type='submit' name='submit' value='SAVE'></td>";
} else {
echo "<td colspan='5'><a href='?pg=$pg&id=#new'>Annexure</a></td>";
}
echo "</tr>";
//existing records
$rs = mysql_query("select *,
least(
case when locate('0', job_code)>0 then locate('0', job_code) else length(job_code)+1 end,
case when locate('1', job_code)>0 then locate('1', job_code) else length(job_code)+1 end,
case when locate('2', job_code)>0 then locate('2', job_code) else length(job_code)+1 end,
case when locate('3', job_code)>0 then locate('3', job_code) else length(job_code)+1 end,
case when locate('4', job_code)>0 then locate('4', job_code) else length(job_code)+1 end,
case when locate('5', job_code)>0 then locate('5', job_code) else length(job_code)+1 end,
case when locate('6', job_code)>0 then locate('6', job_code) else length(job_code)+1 end,
case when locate('7', job_code)>0 then locate('7', job_code) else length(job_code)+1 end,
case when locate('8', job_code)>0 then locate('8', job_code) else length(job_code)+1 end,
case when locate('9', job_code)>0 then locate('9', job_code) else length(job_code)+1 end) pos
from $tbl order by left(job_code, pos-1), mid(job_code, pos, length(job_code)-pos+1)+0");
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td><a name='$i' href='?pg=$pg&id=$o->id#$i'>$i</a></td>";
if ($o->id == $id) {
echo "<td><input type='text' name='jobcode' size='20' value='$o->job_code'></td>
<td><input type='text' name='description' size='50' value='$o->description''></td>
<td><input type='file' name='filename' size='20' value='$o->file_name'> $o->file_name</td>
<td><select name='status'>";
foreach ($statuss as $s) {
echo "<option value='$s'";
if ($s == $o->status) echo " selected";
echo ">$s</option>";
}
echo "</select><input type='hidden' name='id' value='$o->id'></td>
<td><input type='submit' name='submit' value='SAVE'> <a href='?pg=$pg&del=1&id=$o->id'>x</a></td>";
} else {
echo "<td>$o->job_code</td>
<td>$o->description</td>
<td><a href='attachments/$o->file_name'>$o->file_name</a></td>
<td>$o->status</td>";
}
echo "</tr>";
}
?>
</table>
</center>