| Current Path : /var/www/html/mmishra/ilight/ |
| Current File : /var/www/html/mmishra/ilight/amcalendar.inc |
<h3>AMC Calendar</h3>
<?php
$tbl = "am_calendar";
$id = $_REQUEST["id"];
$jobcode = $_POST["jobcode"];
$description = $_POST["description"];
$datestart = $_POST["datestart"];
$dateclose = $_POST["dateclose"];
$amcamount = $_POST["amcamount"];
if (!$amcamount) $amcamount = 0.00;
$amcagency = $_POST["amcagency"];
$attachment = basename($_FILES['attachment']['name']);
if ($attachment) move_uploaded_file($_FILES['attachment']['tmp_name'], "attachments/$attachment");
else $attachment = '';
$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 jobcode='$jobcode',description='$description',
date_start='$datestart',date_close='$dateclose',
amc_amount=$amcamount,amc_agency='$amcagency',attachment='$attachment',status='$status'
where id=$id");
} else {
mysql_query("insert into $tbl(jobcode,description,date_start,date_close,
amc_amount,amc_agency,attachment,status,dated)
values('$jobcode','$description','$datestart','$dateclose',
$amcamount,'$amcagency','$attachment','$status',now())");
}
}
?>
<center>
<table width='100%' border='1' style='border-collapse: collapse'>
<tr><th>No</th><th colspan='2'>AMC 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>
Start Date<br>
<input type='text' name='datestart' size='20' value=''><br>
Close Date<br>
<input type='text' name='dateclose' size='20' value=''><br>
AMC Amount<br>
<input type='text' name='amcamount' size='20' value='0.00'><br>
AMC Agency<br>
<input type='text' name='amcagency' 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><br>
Attachment<br>
<input type='file' name='attachment' size='20' value=''></td></tr>
<tr><td align='center' colspan='3'><input type='submit' name='submit' value='SAVE'></td>";
} else {
echo "<td colspan='2'><a href='?pg=$pg&id=#new'>Job</a></td>";
}
echo "</tr>";
//existing records
//$rs = mysql_query("select * from $tbl order by jobcode");
$rs = mysql_query("select *,
least(
case when locate('0', jobcode)>0 then locate('0', jobcode) else length(jobcode)+1 end,
case when locate('1', jobcode)>0 then locate('1', jobcode) else length(jobcode)+1 end,
case when locate('2', jobcode)>0 then locate('2', jobcode) else length(jobcode)+1 end,
case when locate('3', jobcode)>0 then locate('3', jobcode) else length(jobcode)+1 end,
case when locate('4', jobcode)>0 then locate('4', jobcode) else length(jobcode)+1 end,
case when locate('5', jobcode)>0 then locate('5', jobcode) else length(jobcode)+1 end,
case when locate('6', jobcode)>0 then locate('6', jobcode) else length(jobcode)+1 end,
case when locate('7', jobcode)>0 then locate('7', jobcode) else length(jobcode)+1 end,
case when locate('8', jobcode)>0 then locate('8', jobcode) else length(jobcode)+1 end,
case when locate('9', jobcode)>0 then locate('9', jobcode) else length(jobcode)+1 end) pos
from $tbl order by left(jobcode, pos-1), mid(jobcode, pos, length(jobcode)-pos+1)+0");
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td><a name='f$i'>$i</a></td>";
if ($o->id == $id) {
echo "<td>Code<br>
<input type='text' name='jobcode' size='20' value='$o->jobcode'><br>
Start Date<br>
<input type='text' name='datestart' size='20' value='$o->date_start'><br>
Close Date<br>
<input type='text' name='dateclose' size='20' value='$o->date_close'><br>
AMC Amount<br>
<input type='text' name='amcamount' size='20' value='$o->amc_amount'><br>
AMC Agency<br>
<input type='text' name='amcagency' size='20' value='$o->amc_agency'><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>
Attachment<br>
<input type='file' name='attachment' size='20' value='$o->attachment'></td></tr>
<tr><td align='center' colspan='3'><input type='submit' name='submit' value='SAVE'></td>";
} else {
echo "<td>Code: <a href='?pg=$pg&id=$o->id#f$i'>$o->jobcode</a>
Start Date: $o->date_start<br>
Close Date: $o->date_close<br>
AMC Amount: $o->amc_amount<br>
AMC Agency: $o->amc_agency<br>
Status: $o->status</td>
</td><td>
Description: $o->description<br>
Attachment: ".($o->attachment ? "<a href='attachment/$o->attachment'>$o->attachment</a>" : '')."</td>";
}
echo "</tr>";
}
?>
</table>
</center>