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/indententry.inc.bak

<h2 align='left'>Indent Entry</h2>

<?php

$tbl = 'indents';
$indent_no = $_REQUEST["indent_no"];

if ($_POST["submit"] == 'SAVE') {
	$indent_head = $_POST['indent_head'];
	$indent_date = $_POST['indent_date'];
	//$indent_date = date_create($_POST['indent_date']);
	//$indent_date = date_format($indent_date,"Y-m-d");
	$purpose = $_POST['purpose'];
	$indentor = $_POST['emp_no'];
	$recommendation = $_POST['recommendation'];
	
	$rs = mysql_query("select * from $tbl where indent_no=$indent_no");
	if (mysql_num_rows($rs)) {
		mysql_query("update $tbl set indent_head='$indent_head',indent_date='$indent_date',purpose='$purpose',
		indentor='$indentor',recommendation='$recommendation',date_updation=now() where indent_no=$indent_no");
	} else {
		mysql_query("insert into $tbl(indent_no,indent_head,indent_date,purpose,indentor,recommendation,date_creation,login_id)
		values($indent_no,'$indent_head','$indent_date','$purpose','$indentor','$recommendation',now(),'$user')");
	}

	$item_no = $_POST['item_no'];
	$demanded_qty = $_POST['demanded_qty'];
	$approx_cost = $_POST['approx_cost'];
	
	mysql_query("delete from indent_items where indent_no=$indent_no");
	for ($i=0; $i < count($item_name); $i++) {
		if ($item_name[$i]) {
			mysql_query("insert into indent_items(indent_no,item_no,demanded_qty,approx_cost,date_creation,date_updation,login_id)
			values($indent_no,'$item_no[$i]',$qty_demanded[$i],$approx_cost[$i],now(),now(),'$user')");
		}
	}
	
}

$item_id = array('');
$item_name = array('');
$demanded_qty = array('');
$approx_cost = array('');

$dept_code = array('');
$dept_name = array('');

$employees = array('');

if ($indent_no) {
	$rs = mysql_query("select * from $tbl where indent_no=$indent_no");
	/* fetch values */
	while ($o = mysql_fetch_object($rs)) {
		$indent_head = $o->indent_head;
		$indent_date = $o->indent_date;
		$purpose = $o->purpose;
		$indentor = $o->indentor;
		$recommendation = $o->recommendation;
		$status = $o->status;
	}


	$rs = mysql_query("select * from indent_items where indent_no=$indent_no");
	/* fetch values */
	while ($o = mysql_fetch_object($rs)) {
		array_push($item_id, $o->item_id);
		array_push($item_no, $o->item_no);
		array_push($demanded_qty, $o->demanded_qty);
		array_push($approx_cost, $o->approx_cost);
	}
} else {
	$rs = mysql_query("select * from $tbl order by indent_no desc limit 0,1");
	/* fetch values */
	if (mysql_num_rows($rs)) {
		$o = mysql_fetch_object($rs);
		$indent_no = $o->indent_no + 1;
	} else 
		$indent_no = 1;
}

/*
$rs = mysql_query("select * from departments order by dept_code");
while ($o = mysql_fetch_object($rs)) {
	array_push($dept_code, $o->dept_code);
	array_push($dept_name, $o->dept_name);
}
*/

echo "<table width='95%' border='1' style='border-collapse: collapse'><tr><td align='center'>
Indent No. <input type='text' name='indent_no' size='10' value='$indent_no'>
<input type='submit' name='submit' value='FIND'><br><br>
Fund Head <select name='indent_head'>";

foreach ($heads as $h) {
	echo "<option value='$h'";
	if ($h == $indent_head) echo " selected";
	echo ">$h</option>";
}

if (!$indent_date) $indent_date = date("Y-m-d");
echo "</select>
Indent Date <input type='text' name='indent_date' size='13' value='$indent_date' id='datepicker'>
<br>Purpose <input type='text' name='purpose' size='70' value='$purpose'>
<br>Indentor ".employee_list($indentor);

echo "Recommendation <input type='text' name='recommendation' size='30' value='$recommendation'>
</td></tr></table>
<br>";
		
//item list

echo "<table width='95%' border='1' style='border-collapse: collapse'>
<tr><th>Sr</th><th>Particulars</th><th>Qty</th><th>Approx Cost</th></tr>
";

$j = count($item_name); //(!count($item_name) ? count($item_name) : 5);
for ($i=0; $i < $j; $i++) {
	echo "<tr><td>". (!$i ? 'new' : $i) ."</td>
	<td>".item_list($item_no[$i])."</td>
	<td><input type='text' name='demanded_qty[]' size='5' value='".$demanded_qty[$i]."'></td>
	<td><input type='text' name='approx_cost[]' size='10' value='".$approx_cost[$i]."'</td>
	";
}

echo "</table>";

if ($status == 'Approved') echo "Status: $status";
 
echo "<input type='submit' name='submit' value='SAVE'>";
	
?>