Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/irp/istore/staff/
Upload File :
Current File : /var/www/html/mmishra/irp/istore/staff/materialin.inc

<h2 align='left'>Material In</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'];
	$issued_qty = $_POST['issued_qty'];
	//previously returned qty
	$preturned_qty = $_POST['preturned_qty'];
	//currently returned qty
	$returned_qty = $_POST['returned_qty'];
	for ($k=0; $k < count($item_id); $k++) {
		mysql_query("update indent_items set returned_qty=$returned_qty[$k],
		date_updation=now(),login_id='$user' where item_id=$item_id[$k]");
		//update stockbook
		mysql_query("update stockbook set total_qty=total_qty+$returned_qty[$k]-$preturned_qty[$k],issued_qty=issued_qty+$preturned_qty[$k]-$returned_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 ($returned_qty[$k] == $issued_qty[$k]) {
			$status = ($k >= 1 && $status == 'Issued' ? 'Issued' : 'Returned');
		}
	}
	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='Issued' 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>Returned 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</td>
			<td>$q->approved_qty</td>
			<td>$q->issued_qty</td>";
			$returned_qty = ($q->returned_qty == 0 ? $q->issued_qty : $q->returned_qty);
			$ro = ($q>issued_qty == $q->returned_qty ? 'readonly' : '');
			echo "<td><input type='text' name='returned_qty[]' value='$returned_qty' size='5' $ro onkeyup=\"checkno(this,0,".$q->issued_qty.")\"></td>
			<td>$q->approx_cost</td></tr>";
		}
		echo "</table>
		<input type='submit' name='submit' value='RETURNED'></td></tr>";
	}
}
echo "</table>";
?>