| Current Path : /var/www/html/mmishra/irp/istore/ |
| Current File : /var/www/html/mmishra/irp/istore/inindents.inc.bak |
<h2 align='left'>Indent Entry</h2>
<?php
$tbl = 'indents';
$indent_no = $_REQUEST["indent_no"];
$item_id = $_REQUEST["item_id"];
$fund_head = $_REQUEST['fund_head'];
$status = 'Pending';
if ($_POST["submit"] == 'SAVE') {
$indent_date = $_POST['indent_date'];
//$indent_date = date_create($_POST['indent_date']);
//$indent_date = date_format($indent_date,"Y-m-d");
$purpose = $_POST['dept_no'].$_POST['project_no'].$_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 fund_head='$fund_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,fund_head,indent_date,purpose,indentor,recommendation,date_creation,login_id)
values($indent_no,'$fund_head','$indent_date','$purpose','$indentor','$recommendation',now(),'$user')");
}
$item_no = $_POST['item_no'];
$demanded_qty = $_POST['demanded_qty'];
$issued_qty = $_POST['issued_qty'];
$approx_cost = $_POST['approx_cost'];
$rs = mysql_query("select * from indent_items where item_id=$item_id");
if (mysql_num_rows($rs)) {
mysql_query("update indent_items(item_no=$item_no,demanded_qty=$demanded_qty,issued_qty=$issued_qty,approx_cost=$approx_cost,
date_updation=now(),login_id='$user' where item_id=$item_id");
} else {
mysql_query("insert into indent_items(indent_no,item_no,demanded_qty,issued_qty,approx_cost,date_creation,date_updation,login_id)
values($indent_no,$item_no,$demanded_qty,$issued_qty,$approx_cost,now(),now(),'$user')");
}
}
if ($indent_no) {
$rs = mysql_query("select * from $tbl where indent_no=$indent_no");
/* fetch values */
while ($o = mysql_fetch_object($rs)) {
$fund_head = $o->fund_head;
$indent_date = $o->indent_date;
$purpose = $o->purpose;
$indentor = $o->indentor;
$recommendation = $o->recommendation;
$status = $o->status;
}
} 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;
}
echo "<center>
<table width='90%' 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
<b><font size='+1'>[</font>
";
if (!$fund_head) $fund_head='Institute';
foreach ($heads as $h) {
$i++;
echo "<input type='radio' name='fund_head' value='$h'";
echo " onchange=\"javascript: document.location.href='?pg=$pg&fund_head='+this.value\"";
echo ($fund_head == $h ? ' checked' : ''). '>';
echo ($fund_head == $h ? "<font color='red'>$h</font>" : $h);
}
echo "<font size='+1'> ]</font></b>
<table><tr>";
if ($fund_head == 'Department') echo "<td>Department</td><td>".department_list($dept_no);
else if ($fund_head == 'Project') echo "<td>Project</td><td>".project_list($dept_no);
else echo "<td>Purpose</td><td><input type='text' name='purpose' size='60' value='$purpose'>";
echo "</td>";
if (!$indent_date) $indent_date = date("Y-m-d");
echo "<td width='10%'>Indent Date</td><td><input type='text' name='indent_date' size='13' value='$indent_date' id='datepicker'></td>
</tr><tr>
<td>Location</td><td><input type='text' name='purpose' size='60' value='$purpose'></td>
</tr><tr>
<td width='10%'>Indentor</td><td width='60%'>".employee_list($indentor)."</td>
<td>Recommendation</td><td><input type='text' name='recommendation' size='30' value='$recommendation'></td>
</tr></table>
</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 Demanded</th><th>Qty Issued</th><th>Approx Cost</th></tr>";
if ($status == 'Pending') {
echo "<tr>";
if (!$item_id) {
echo "<td>New</td>
<td>".item_list(0)."<br><input type='text' name='item_name' size='25' value=''></td>
<td><input type='text' name='demanded_qty' size='5' value=''></td>
<td><input type='text' name='issued_qty' size='5' value=''></td>
<td><input type='text' name='approx_cost' size='10' value=''></td>";
} else {
echo "<td colspan='4'><a href='staff/?pg=$pg&indent_id='>+</a></td>";
}
echo "</tr>";
}
$sr = mysql_query("select * from indent_items where indent_no=$indent_no order by item_id");
while ($q = mysql_fetch_object($sr)) {
$j++;
echo "<tr><td>$j</td>";
if ($item_id == $q->item_id) {
echo "<td>";
/*
echo "<select name='category' onchange=\"javascript: document.location.href='?pg=$pg&category='+this.value\">
<option value=''></option>";
$rs = mysql_query("select id,title from st_category order by title");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $category) echo " selected";
echo ">$o->title</option>";
}
echo "</select>
<select name='subcategory' onchange=\"javascript: document.location.href='?pg=$pg&category=$category&subcategory='+this.value\">
<option value=''></option>";
$rs = mysql_query("select id,title from st_subcategory where category=$category order by title");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $subcategory) echo " selected";
echo ">$o->title</option>";
}
echo "</select>";
*/
echo item_list($q->item_no)."</td>
<td><input type='text' name='demanded_qty' size='5' value='$q->demanded_qty'></td>
<td><input type='text' name='issued_qty' size='5' value='$q->issued_qty'></td>
<td><input type='text' name='approx_cost' size='10' value='$q->approx_cost'></td>";
} else {
echo "<td>".item_detail($q->item_no)."</td>
<td>$q->demanded_qty</td>
<td>$q->issued_qty</td>
<td>$q->approx_cost</td>";
}
echo "</tr>";
}
echo "</table>";
if ($status == 'Approved') echo "Status: $status";
else echo "<input type='submit' name='submit' value='SAVE'>
</center>";
?>