| Current Path : /var/www/html/mmishra/irp/istore/ |
| Current File : /var/www/html/mmishra/irp/istore/inapproval.inc |
<h2 align='left'>Indent Approval</h2>
<?php
$tbl = 'indents';
$indentno = $_REQUEST["indent_no"];
$status = $_REQUEST["status"];
if ($status == 'cancel') mysql_query("update $tbl set status='Cancelled' where indent_no=$indentno");
if ($_POST["submit"] == 'APPROVE') {
$id = $_POST['id'];
$qty_approve = $_POST['qty_approve'];
for ($k=0; $k < count($id); $k++) {
mysql_query("update indent_items set qty_approve=$qty_approve[$k],dated=now() where id=$id[$k]");
}
mysql_query("update $tbl set status='Approved',dated=now() where indent_no=$indentno");
$rs = mysql_query("select email from employees where emp_no=(select employee from indents where indent_no=$indentno)");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$emp_name = $o->emp_name;
$email = $o->email;
//$email = 'mmishra@iiita.ac.in';
}
$str = "Dear Indentor
<br><br>
Your indent (reference No. $indentno) with following details has been approved. Available items may be collected from the store.
<br><br>
".indent_detail($indentno);
if ($email) automailer($email, "Indent Approval", $str);
$indentno = 0;
}
echo "<center>
<table width='90%' border='1' style='border-collapse: collapse'>
<tr><th>No.</th><th>Indent No.</th><th>Dated</th><th>Employee</th><th>Recommendation</th><th>Status</th></tr>";
$rs = mysql_query("select * from $tbl where status='Pending' order by indent_no");
/* fetch values */
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td>$i</td>";
if ($indentno == $o->indent_no) {
echo "<td><b style='color: red'>$o->indent_no</b> <input type='hidden' name='indent_no' value='$o->indent_no'></td>";
} else {
echo "<td><a href='?pg=$pg&indent_no=$o->indent_no'>$o->indent_no</a></td>";
}
$status = $o->status;
echo "<td>$o->indent_date</td><td>".employee_detail($o->employee)."</td><td>$o->recommendation</td><td>$status ";
if ($status == 'Pending') echo "[ <a href='?pg=$pg&status=cancel&indent_no=$o->indent_no'>Cancel</a> ]";
echo "</td></tr>";
if ($indentno == $o->indent_no) {
echo "<tr><td colspan='7' align='center'>
<font color='red' size=+1>Particulars</font>
<table width='90%' border='1' style='border-collapse: collapse'>
<tr><th>No.</th><th>Indent Items</th><th>Qty Demand</th><th>Qty Out</th><th>Qty Approve</th><th>Approx Cost</th></tr>";
$sr = mysql_query("select * from indent_items where indent_no=$indentno order by item");
/* fetch values */
while ($q = mysql_fetch_object($sr)) {
$j++;
echo "<tr><td>$j <input type='hidden' name='item[]' value='$q->item'></td>
<td>".item_detail($q->item)."</td><td>$q->qty_demand</td><td>$q->qty_out</td>";
$qty_approve = ($q->qty_approve == 0 && $status == 'Pending' ? $q->qty_demand : $q->qty_approve);
echo "<td><input type='text' name='qty_approve[]' value='$qty_approve' size='5'></td>
<td>$q->approx_cost <input type='hidden' name='id[]' value='$q->id'></td></tr>";
}
echo "</table>
<input type='submit' name='submit' value='APPROVE'></td></tr>";
}
}
echo "</table>";
?>
</center>