| Current Path : /var/www/html/mmishra/istore/staff/ |
| Current File : /var/www/html/mmishra/istore/staff/materialout.inc |
<h2 align='left'>Material Out</h2>
<?php
$tbl = 'indents';
$indent_no = $_REQUEST["indent_no"];
if ($_REQUEST['iss'] == 1) {
mysql_query("update $tbl set status='Issued' where indent_no=$indent_no");
$indent_no = 0;
}
if ($_POST["submit"] == 'ISSUED') {
$item_id = $_POST['item_id'];
$item_no = $_POST['item_no'];
$approved_qty = $_POST['approved_qty'];
//previouslyt issued qty
$pissued_qty = $_POST['pissued_qty'];
//currently issued qty
$issued_qty = $_POST['issued_qty'];
$status = 'Approved';
for ($k=0; $k < count($item_id); $k++) {
mysql_query("update indent_items set issued_qty=$issued_qty[$k],
date_updation=now(),login_id='$user' where item_id=$item_id[$k]");
//update stockbook
mysql_query("update stockbook set issued_qty=issued_qty-$pissued_qty[$k]+$issued_qty[$k],total_qty=total_qty+$pissued_qty[$k]-$issued_qty[$k],
date_updation=now(),login_id='$user' where item_no=$item_no[$k]");
//compute balance stock
mysql_query("update stockbook set balance_qty=total_qty-issued_qty where item_no=$item_no[$k]");
//status of indent will be 'approved' if it is partial issue of items
if ($issued_qty[$k] == $approved_qty[$k]) {
$status = ($k >= 1 && $status == 'Approved' ? 'Approved' : 'Issued');
}
}
mysql_query("update $tbl set status='$status',date_updation=now(),login_id='$user' where indent_no=$indent_no");
$indent_no = 0;
}
echo "<table width='95%' border='1' style='border-collapse: collapse'>
<tr><th>Sr</th><th>Indent No</th><th>Dated</th><th>Fund Head</th><th>Purpose</th><th>Indentor</th><th>Recommendation</th><th>Status</th></tr>";
$rs = mysql_query("select * from $tbl where status='Approved' order by indent_no");
/* fetch values */
while ($o = mysql_fetch_object($rs)) {
$i++;
echo "<tr><td>$i</td>";
if ($indent_no == $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='staff/?pg=$pg&indent_no=$o->indent_no'>$o->indent_no</a></td>";
}
echo "<td>$o->indent_date</td>
<td>$o->fund_head</td>
<td>$o->purpose</td>
<td>".employee_detail($o->indentor)."</td>
<td>$o->recommendation</td>
<td>$o->status</td></tr>";
if ($indent_no == $o->indent_no) {
echo "<tr><td colspan='8' align='center'>
<b align='left'>Items</b>
<table width='90%' border='1' style='border-collapse: collapse'>
<tr><th>Sr</th><th>Particulars</th><th>Demanded Qty</th><th>Approved Qty</th><th>Issued Qty</th><th>Approx Cost</th></tr>";
$sr = mysql_query("select * from indent_items where indent_no=$indent_no order by item_id");
/* fetch values */
while ($q = mysql_fetch_object($sr)) {
$j++;
echo "<tr><td>$j <input type='hidden' name='item_id[]' value='$q->item_id'></td>
<td>".item_detail($q->item_no)."<input type='hidden' name='item_no[]' value='$q->item_no'></td>
<td>$q->demanded_qty<input type='hidden' name='pissued_qty[]' value='$q->issued_qty'></td>
<td>$q->approved_qty <input type='hidden' name='approved_qty[]' value='$q->approved_qty'></td>";
$issued_qty = ($q->issued_qty == 0 ? $q->approved_qty : $q->issued_qty);
$rd = ($q->approved_qty == 0 ? 'readonly' : '');
echo "<td><input type='text' name='issued_qty[]' value='$issued_qty' size='5' $rd onkeyup=\"checkno(this,0,".$q->approved_qty.")\"></td>
<td>$q->approx_cost</td></tr>";
}
echo "</table>
<input type='submit' name='submit' value='ISSUED'></td></tr>";
}
}
echo "</table>";
?>