| Current Path : /var/www/html/mmishra/istore/ |
| Current File : /var/www/html/mmishra/istore/mm.inc |
<h3>Stockbook</h3>
<center>
<?php
$category = $_REQUEST['category'];
$subcategory = $_REQUEST['subcategory'];
/*
echo "<div>Select category <select name='category' onchange=\"javascript: document.location.href='?pg=$pg&category='+this.value\">
<option value=''>Category</option>";
$rs = mysql_query("select * from st_category order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $category) echo " selected";
echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
}
echo "</select>
Subcategory <select name='subcategory' onchange=\"javascript: document.location.href='?pg=$pg&category=$category&subcategory='+this.value\">
<option value=''>Subcategory</option>";
$rs = mysql_query("select * from st_subcategory where category=$category order by code");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $subcategory) echo " selected";
echo ">$o->code ($o->qty_in/$o->qty_out)</option>";
}
echo "</select>
</div>";
$rs = mysql_query("select id,code,date(dateCreation) as dated from st_items where category=$category and subcategory=$subcategory order by code");
while ($o = mysql_fetch_object($rs)) {
$j=0;
$i++;
$item = $o->id;
$dated = $o->dated;
//opening stock
$sr = mysql_query("select sum(qty_in) as qty1 from st_stockin where item=$item and dateUpdation>'$dated'");
if (mysql_num_rows($sr)) {
$q = mysql_fetch_object($sr);
$qty1 = $q->qty1;
}
echo "<div align='left'><b>$i ".item_detail($item)." </b> >> Opening stock on $dated: [ $qty1 ]</div>
<table width='90%' border='1' style='border-collapse: collapse'>";
//stock in
$sr = mysql_query("SELECT item,'+' as mm,date(dateCreation) as dated,qty_in as qty from st_stockin where item=$item union select item,'-' as mm,date(dateCreation) as dated,qty_out as qty FROM st_stockout where item=$item order by item,dated");
while ($q = mysql_fetch_object($sr)) {
$j++;
echo "<tr><td>$j</td><td>$q->dated [$q->mm]</td><td>$q->qty</td></tr>";
}
echo "</table>";
}
$rs = mysql_query("select * from st_category order by code");
while ($o = mysql_fetch_object($rs)) {
$sr = mysql_query("select * from st_subcategory where category=$o->id order by code");
while ($q = mysql_fetch_object($sr)) {
$in1 += $q->qty_in;
$out1 += $q->qty_out;
//echo "<h4>$q->code [ In: $q->qty_in ][ $q->qty_out ]</h4>";
$rr = mysql_query("select * from st_items where subcategory=$q->id order by code");
while ($r = mysql_fetch_object($rr)) {
$in2 += $r->qty_in;
$out2 += $r->qty_out;
//echo "<h5>$r->code [ In: $r->qty_in ][ $r->qty_out ]</h4>";
}
echo "<h5>------Item In: $in2 <> Out: $out2</h5>";
}
echo "<h4>----Sub In: $in1 <> Out: $out1</h4>";
echo "<h3>--Cat [ In: $o->qty_in ][ $o->qty_out ]</h3>";
}
$rs = mysql_query("select item,sum(qty_in) as qi from st_stockin group by item");
while ($o = mysql_fetch_object($rs)) {
$item = $o->item;
$qi = $o->qi;
$sr = mysql_query("select * from st_items where id=$item");
$q = mysql_fetch_object($sr);
$in = $q->qty_in;
$sr = mysql_query("select item,sum(qty_out) as qo from st_stockout where item=$item");
$q = mysql_fetch_object($sr);
$qo = $q->qo;
$sr = mysql_query("select * from st_items where id=$item");
$q = mysql_fetch_object($sr);
$out = $q->qty_out;
echo item_detail($o->item) ." [ $qi / $qo ][ $in / $out ]<br>";
//if ($qi<$qo) $qi=$qo;
mysql_query("update st_items set qty_in=$qi,qty_out=$qo where id=$item");
}
*/
$rs = mysql_query("select item,sum(qty_in) as qi from st_stockin group by item");
while ($o = mysql_fetch_object($rs)) {
$item = $o->item;
$qi = $o->qi;
$sr = mysql_query("select * from st_items where id=$item");
$q = mysql_fetch_object($sr);
$in = $q->qty_in;
$sr = mysql_query("select item,sum(qty_out) as qo from st_stockout where item=$item");
$q = mysql_fetch_object($sr);
$qo = $q->qo;
$sr = mysql_query("select * from st_items where id=$item");
$q = mysql_fetch_object($sr);
$out = $q->qty_out;
//echo item_detail($o->item) ." [ $qi / $qo ][ $in / $out ]<br>";
//if ($qi<$qo) $qi=$qo;
mysql_query("update st_items set stock=$qi-$qo,qty_in=$qi,qty_out=$qo where id=$item");
}
/*
$rs = mysql_query("select * from indents where status='Approved' and date(date_indent)>'2017-10-01'");
while ($o = mysql_fetch_object($rs)) {
$email = employee_email($o->emp_no);
//$email = 'mmishra@iiita.ac.in';
$mm = available_items($o->indent_no);
if ($mm && $email && stock_available($o->indent_no)) {
$str = "Dear Indentor
<br><br>
With reference to your indent No. $o->indent_no some items marked with <font size='+1' color='red'>*</font> are available readily in the stock.
Kindly collect them during 12 - 1 PM (Cleaning items) and 3 - 4 PM (Stationary & Crockery items) at your suitable convenience.
Remaining items, if any, may take some time as they are subject to purchase processing. Please note, <font size='+1' color='green'>*</font> marked items are already issued.
<br><br>$mm<br><br>
Thanks,<br><br>";
echo ($email. "--Indent Approval--<br>" .$str);
//automailer('istore@iiita.ac.in', "Indent Approval", $str);
}
}
*/
?>
</center>