| Current Path : /var/www/html/mmishra/iws8/html/ilight/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/amjobs.inc |
<h3>Job Description</h3>
<?php
$tbl = "am_jobs";
$id = $_REQUEST["id"];
$jobcode = $_POST["jobcode"];
$description = $_POST["description"];
$approxcost = $_POST["approxcost"];
if (!$approxcost) $approxcost = 0.00;
$location = $_POST["location"];
$incharge = $_POST["incharge"];
$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',approx_cost=$approxcost,
location='$location',incharge='$incharge',status='$status'
where id=$id");
} else {
mysql_query("insert into $tbl(job_code,description,approx_cost,location,incharge,status,dated)
values('$jobcode','$description',$approxcost,'$location','$incharge','$status',now())");
}
}
?>
<center>
<table width='90%' border='1' style='border-collapse: collapse'>
<tr><th>Sr</th><th colspan='2'>Job Description</th></tr>
<?php
echo "<tr><td><a name='new'>New</a></td>";
if (!$id) {
echo "
<td>Code<br>
<input type='text' name='jobcode' size='20' value=''><br>
Approx Cost<br>
<input type='text' name='approxcost' size='20' value='0.00'><br>
Location<br>
<input type='text' name='location' size='20' value=''><br>
Incharge<br>
<input type='text' name='incharge' size='20' value=''><br>
Status<br>
<select name='status'>";
foreach ($statuss as $s) {
echo "<option value='$s'";
if ($s == $status) echo " selected";
echo ">$s</option>";
}
echo "</select><input type='hidden' name='id' value='0'>
</td><td>
Description<br>
<textarea name='description' rows='5' cols='40'></textarea></td></tr>
<tr><th colspan='3'><input type='submit' name='submit' value='SAVE'></th>";
} else {
echo "<td colspan='2'><a href='?pg=$pg&id=#new'>Job</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>Code<br>
<input type='text' name='jobcode' size='20' value='$o->job_code'><br>
Approx Cost<br>
<input type='text' name='approxcost' size='20' value='$o->approx_cost'><br>
Location<br>
<input type='text' name='location' size='20' value='$o->location'><br>
Incharge<br>
<input type='text' name='incharge' size='20' value='$o->incharge'><br>
Status<br>
<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>Description<br>
<textarea name='description' rows='5' cols='40'>$o->description</textarea><br>
<tr><th colspan='3'><input type='submit' name='submit' value='SAVE'></th>";
} else {
echo "<td>Code: $o->job_code<br>
Approx Cost: $o->approx_cost<br>
Location: $o->location<br>
Incharge: $o->incharge<br>
Status: $o->status
</td><td>
Description: $o->description<br>
<b>Attachments:<ol>";
$sr = mysql_query("select * from am_annexures where job_code='$o->job_code' order by description");
while ($q = mysql_fetch_object($sr)) {
echo "<li><a href='attachments/$q->file_name'>$q->description</a></li>";
}
echo "</ol></td>";
}
echo "</tr>";
}
?>
</table>
</center>