| Current Path : /var/www/html/mmishra/istore/ |
| Current File : /var/www/html/mmishra/istore/ststockout.inc |
<h3>Stockbook Out</h3>
<center>
<?php
$tbl = "st_stockout";
$empno = $_REQUEST["emp_no"];
$indentno = $_REQUEST["indent_no"];
$z = 0;
$dated = date("Y-m-d");
$note = "<p>
? set quantity to zero if it is not going to be issued.<br>
Indented items will be listed here till all items are issued.<br>
Issued items are <font size=+1 color='red'>*</font> marked for easy identification and record.<br>
<font color='red'>No stock</font> items will be issued only on receipt of items in the Store inventory.
</p>";
if ($_POST["submit"] == 'SETTLE') {
mysql_query("update indent_items set qty_approve=qty_out where indent_no=$indentno and qty_out<qty_approve");
mysql_query("update indents set status='Issued' where indent_no=$indentno");
} elseif ($_POST["submit"] == 'ISSUE') {
$ids = $_POST["id"];
$items = $_POST["item"];
$qtyouts = $_POST["qty_out"];
$xqtyouts = $_POST["xqty_out"];
$units = $_POST["unit"];
$remark = $_POST["remark"];
$no = $_POST['no'];
if (!$no) $no = 0;
//get category/subcategory of item
foreach ($ids as $id) {
//utilization entry
if (mysql_num_rows(mysql_query("select * from $tbl where id=$id"))) {
mysql_query("update $tbl set qty_out=$qtyouts[$z],unit='$units[$z]',remark='$remark' where id=$id");
//update qty_out if it is changed
if ($xqtyouts[$z] != $qtyouts[$z]) {
//adjust qty in item table
mysql_query("update st_items set qty_out=qty_out-$xqtyouts[$z]+$qtyouts[$z],loginID='$user' where id=$items[$z]");
//adjust qty in indent item table
mysql_query("update indent_items set qty_out=qty_out-$xqtyouts[$z]+$qtyouts[$z] where indent_no=$indentno and item=$items[$z]");
}
} else {
mysql_query("insert into $tbl(indent_no,item,qty_out,unit,remark)
values($indentno,$items[$z],$qtyouts[$z],'$units[$z]','$remark')");
//increase qty in item table
mysql_query("update st_items set qty_out=qty_out+$qtyouts[$z],loginID='$user' where id=$items[$z]");
//adjust qty in indent item table
//mysql_query("update indent_items set qty_out=qty_out+$qtyouts[$z] where indent_no=$indentno and item=$items[$z]");
mysql_query("update indent_items set qty_out=$qtyouts[$z] where indent_no=$indentno and item=$items[$z]");
}
$z++;
}
//send email to indentor
if ($z) {
$rs = mysql_query("select * from employees where emp_no=(select emp_no from indents where indent_no=$indentno)");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$empname = $o->emp_name;
$email = $o->email;
if (!$email) $email = 'istore@iiita.ac.in'; //send email to istore
$sr = mysql_query("select * from indents where indent_no=$indentno");
if (mysql_num_rows($sr)) {
$q = mysql_fetch_object($sr);
$purpose = $q->purpose;
$dateindent = $q->date_indent;
$location = $q->location;
if (!$location) $location = '--';
$account = $q->account;
}
}
$str = "Dear Indentor
<br><br>
With reference to your Indent No. $indentno for the purpose of '$purpose' at location '$location',
following items have been issued in your '$account' account recently from the Central Store.<br>
This 'Material Out Receipt' is for your information and record pl.
<br><br>". issued_indent($indentno). "<br>
In case of any defect/malfunctioning/poor quality, items may kindly be returned to the Central Store within 24 hours for replacement/warranty claim.<br><br>
At the time of nodues certification, you need to settle your personal account for returnable items only.
However, all the non-consumable including fixture items will be handed over to your successor on the day.
<br><br>Thanks,<br><br>";
automailer($email, "Material Out Receipt", $str);
//echo("$email -- Material Out Receipt -- $str");
//automailer('istore@iiita.ac.in', "Material Out Receipt", $str);
}
//mark indent as issued if no pending item is left
$rs = mysql_query("select * from indent_items where indent_no=$indentno and qty_approve != qty_out");
if (!mysql_num_rows($rs)) {
mysql_query("update indents set status='Issued' where indent_no=$indentno");
$indentno = 0;
}
}
//automailer('mmishra@iiita.ac.in', "Material Issued", 'test');
echo "<div align='left'>
Select indentor <select name='emp_no' onchange=\"javascript: document.location.href='?pg=$pg&emp_no='+this.value\">
<option value=''></option>";
$rs = mysql_query("select distinct i.emp_no,e.emp_name,e.designation from indents as i, employees as e where i.emp_no=e.emp_no and i.status='Approved' order by e.emp_name");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->emp_no'";
if ($o->emp_no == $empno) {
echo " selected";
$empname = $o->emp_name;
}
echo ">$o->emp_name</option>";
}
echo "</select>
indent <select name='indent_no' onchange=\"javascript: document.location.href='?pg=$pg&emp_no=$empno&indent_no='+this.value\">
<option value=''></option>";
$rs = mysql_query("select * from indents where emp_no='$empno' and status='Approved' order by indent_no");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->indent_no'";
if ($o->indent_no == $indentno) {
echo " selected";
$dateindent = $o->date_indent;
$purpose = $o->purpose;
$account = $o->account;
$location = $o->location;
$recommendation = $o->recommendation;
$status = $o->status;
}
echo ">$o->indent_no</option>";
}
echo "</select> Only APPROVED indents iof selected indentor are listed here.
</div>";
if ($indentno) {
echo "<table width='90%' border='0' height='50pt' style='border-collapse: collapse'>
<tr><th>Indent No.: $indentno</th><th width='60%'>Indentor: $empname ($account Account)</th><th>Dated: $dateindent</th></tr>
<tr><td>Location: $location</td><td>Purpose: $purpose</td><td>Recommendation: $recommendation</td></tr>
</table>
<table width='90%' border='1' style='border-collapse: collapse'>
<tr><th>No.</th><th>Particulars</th><th>Qty Demand</th><th>Qty Approve</th><th>Qty Out</th><th>Remark (additional information)</th><th>Approx Cost</th><th>Dated</th></tr>";
$pending = 0;
$rs = mysql_query("select * from indent_items where indent_no=$indentno order by id");
while ($o = mysql_fetch_object($rs)) {
$i++;
$id = 0;
$star = '';
$item = $o->item;
$qtydemand = $o->qty_demand;
$qtyapprove = $o->qty_approve;
$qtyout1 = $o->qty_out; //qty out prior to approval to meet the urgency
$qtyout = $qtyapprove - $qtyout1; //remaining qty to issue
$unit = $o->unit;
$remark = $o->remark;
$idate = $dated;
//if already issued, put a star mark
$sr = mysql_query("select * from $tbl where indent_no=$indentno and item=$item");
if (mysql_num_rows($sr)) {
$q = mysql_fetch_object($sr);
$id = $q->id;
//add previous issued qty (at the time of indent receiving)
$qtyout2 = $q->qty_out; //qty out after approval
//qty may be either 0 or less due to short stock
if ($qtyout2 == $qtyapprove) {
$j++;
$idate = $q->dateUpdation;
$star = "<font size='+1' color='red'>*</font>";
}
} else
$qtyout2 = 0;
//list indented items
echo "<tr><td>$i $star $item</td><td>". item_inventory($item). "</td>
<td>". number_format($qtydemand,2). " $unit</td><td>". number_format($qtyapprove,2). " $unit</td><td>";
if ($qtyapprove == $qtyout2) {
echo $qtyout2. " $unit";
} elseif (stock_status($item) > 0.00) {
//$qtyout = $qtyapprove - $qtyout;
echo "<input type='hidden' name='id[]' value='$id'>
<input type='hidden' name='item[]' value='$item'>
<input type='hidden' name='xqty_out[]' value='$qtyout2'>
?<input type='text' name='qty_out[]' value='$qtyout' size='5'>
$unit ".($qtyout1 ? " ($qtyout1 already issued)" : '')."
<input type='hidden' name='unit[]' value='$unit'>";
$ok = 1;
} else {
echo "<font color='red'>No stock</font>";
}
echo "</td><td><input type='text' name='remark' value='$remark' size='50'></td><td>Rs. $o->approx_cost</td><td>$idate</td></tr>";
}
if ($i > $j) {
if ($ok) echo "<tr><th colspan='7'><input type='submit' name='submit' value='ISSUE'></th><th><input type='submit' name='submit' value='SETTLE'></th></tr>";
} else {
mysql_query("update indents set status='Issued' where indent_no=$indentno");
$indentno = 0;
}
echo "</table><input type='hidden' name='no' value='$i'> $note";
}
?>
</center>