| Current Path : /var/www/html/mmishra/istore/ |
| Current File : /var/www/html/mmishra/istore/ststockbook.inc |
<h3>Stockbook</h3>
<center>
<?php
$tbl = 'st_items';
$y = date("Y");
$cfyear = $y + 1 . "-03-31";
$pfyear = $y . "-03-31";
$fyear = $y . "-04-01 to " . ($y + 1) . "-03-31";
?>
<table border='1' width='98%'>
<tr><th rowspan='2'>No.</th><th rowspan='2'>Particulars</th><th colspan='5'>Stock status during <?php echo $fyear; ?></th></tr>
<tr><th>Opening</th><th>In</th><th>Total</th><th>Out</th><th>Closing</th></tr>
<?php
$rs = mysql_query("select i.*,c.code as cat,s.code as subcat from $tbl as i,st_category as c, st_subcategory as s where i.category=c.id and i.subcategory=s.id order by cat,subcat,i.code");
while ($o = mysql_fetch_object($rs)) {
$item = $o->id;
//total received qty in the previous financial year
$sr = mysql_query("select item,sum(qty_in) as qin from st_stockin where item=$item and date(dateUpdation)<='$pfyear' group by item");
if (mysql_num_rows($sr)) {
$q = mysql_fetch_object($sr);
$stockIn = $q->qin;
} else
$stockIn = 0.00;
//total used qty in the previous financial year
$sr = mysql_query("select item,sum(qty_out) as qout from st_stockout where item=$item and date(dateUpdation)<='$pfyear' group by item");
if (mysql_num_rows($sr)) {
$q = mysql_fetch_object($sr);
$stockOut = $q->qout;
} else
$stockOut = 0.00;
$stockOpen = number_format($stockIn - $stockOut, 2);
//received stock
$sr = mysql_query("select item,sum(qty_in) as qin from st_stockin where date(dateUpdation)>'$pfyear' and date(dateUpdation)<'$cfyear' and item=$item group by item");
if (mysql_num_rows($sr)) {
$q = mysql_fetch_object($sr);
$stockIn = $q->qin;
} else
$stockIn = 0.00;
$stockIn = number_format($stockIn, 2);
//total stock
$stockTotal = number_format($stockOpen + $stockIn, 2);
$stockTotal = $stockOpen + $stockIn;
//utilised stock
$sr = mysql_query("select item,sum(qty_out) as qout from st_stockout where date(dateUpdation)>'$pfyear' and date(dateUpdation)<'$cfyear' and item=$item group by item");
if (mysql_num_rows($sr)) {
$q = mysql_fetch_object($sr);
$stockOut = $q->qout;
} else
$stockOut = 0.00;
$stockOut = number_format($stockOut, 2);
//closing stock
$stockClose = number_format($stockTotal - $stockOut, 2);
if ($stockTotal && $stockOut) {
$i++;
echo "<tr><td><a name='$i'></a>$i</td><td>$o->cat -> $o->subcat -> $o->code</td>
<td align='right'>$stockOpen</td><td align='right'>$stockIn</td><td align='right'>$stockTotal</td>
<td align='right'>$stockOut</td><td align='right'>$stockClose</td></tr>";
}
}
?>
</table>
</center>