| Current Path : /var/www/html/mmishra/iws8/html/mcell/report/ |
| Current File : /var/www/html/mmishra/iws8/html/mcell/report/procurement.php |
<?php
include "report_header.inc";
echo "</center><b>Anual Procurement</b><br>";
$submit=$_REQUEST["submit"];
$category_code=$_REQUEST["category_code"];
$date1=$_REQUEST["date1"];
$date2=$_REQUEST["date2"];
if ($date1 == "") $date1 = (date("Y") - 1) . "-04-01";
if ($date2 == "") $date2 = date("Y") . "-03-31";
echo "Item <select name='category_code'><option value=''>Item</option>";
$sql="select row_id,name,stock_quantity from parts_category order by name";
$rs=mysql_query($sql, $con);
while ($q = mysql_fetch_array($rs)){
$row_id1=$q["row_id"];
$name=$q["name"];
$qty=$q["stock_quantity"];
echo "<option value='$row_id1'";
if ($category_code == $row_id1) echo " selected";
echo ">$name</option>";
}
echo "</select> and ";
echo " period <input type='text' name='date1' value='$date1' size='10'> to <input type='text' name='date2' value='$date2' size='10'> ";
echo "<input type='submit' name='submit' value='SHOW'> <a href='report/consumption.php?category_code=$category_code'>Consumption</a><p>";
echo "<table border='1' width='100%'>";
echo "<tr><th>No.</th><th>Description</th><th>Model/Make</th><th nowrap>Parts Code</th><th nowrap>Receive Date</th><th>Remark</th></tr>";
if ($category_code != ""){
$sql1 = "select count(pm.parts_code) obal from parts_receipt im, parts_master pm where im.row_id=pm.item_code and pm.status in ('old','new') and im.category_code=$category_code and im.receive_date<'$date1'";
$rs = mysql_query($sql1, $con);
if(!$rs) echo sql_error();
$qd = mysql_fetch_array($rs);
$obal = $qd["obal"];
$sql1 = "select count(pm.parts_code) obal from parts_receipt im, parts_master pm, parts_issued pi where im.row_id=pm.item_code and pm.row_id=pi.parts_code and pm.status in ('issued','scrap') and im.category_code=$category_code";
if ($date1) $sql1 .= " and im.receive_date<'$date1' and pi.issue_date>'$date1'";
$rs = mysql_query($sql1, $con);
if(!$rs) echo sql_error();
$qd = mysql_fetch_array($rs);
$obal += $qd["obal"];
echo "<b>Opening Balance: " . $obal . "</b><br>";
//show current procurements
$sql = "select im.supplier_code,im.description,im.model_make,im.unit_price,im.receive_date,pm.parts_code,im.remark from parts_receipt im, parts_master pm where im.row_id=pm.item_code and im.category_code=$category_code";
if ($date1) $sql .= " and im.receive_date>='$date1'";
if ($date2) $sql .= " and im.receive_date<='$date2'";
$sql .= " order by im.supplier_code, im.receive_date";
$rs = mysql_query($sql, $con);
if(!$rs) echo sql_error();
while ($qd = mysql_fetch_array($rs)){
$i++;
if ($supplier_code != $qd["supplier_code"]){
$supplier_code = $qd["supplier_code"];
$supplier = supplier($supplier_code, $con);
echo "<tr><td colspan='8'><font color='red'>Supplier: $supplier</font></td></tr>";
}
$description = $qd["description"];
$model_make = $qd["model_make"];
$unit_price = $qd["unit_price"];
$receive_date = $qd["receive_date"];
$parts_code = $qd["parts_code"];
$remark = $qd["remark"];
echo "<tr><td>$i</td><td>$description</td><td>$model_make</td><td><a href='query/search_parts.php?parts_code=$parts_code'>$parts_code</a></td><td align='center'>$receive_date</td><td>$remark</td></tr>";
}
//show closing balance
$sql1 = "select count(pm.parts_code) cbal from parts_receipt im, parts_master pm where im.row_id=pm.item_code and im.category_code=$category_code and pm.status in('old','new') and im.receive_date<'$date2'";
//if ($date1) $sql1 .= " and (pi.issue_date is NULL or pi.issue_date>'$date2')";
$rs = mysql_query($sql1, $con);
if(!$rs) echo sql_error();
$qd = mysql_fetch_array($rs);
$cbal = $qd["cbal"];
$sql1 = "select count(pm.parts_code) cbal from parts_receipt im, parts_master pm, parts_issued pi where im.row_id=pm.item_code and pm.row_id=pi.parts_code and im.category_code=$category_code and pm.status in('issued','scrap') and im.receive_date<='$date2' and pi.issue_date>'$date2'";
$rs = mysql_query($sql1, $con);
if(!$rs) echo sql_error();
$qd = mysql_fetch_array($rs);
$cbal += $qd["cbal"];
}
echo "</table>";
echo "<b>Closing Balance: " . $cbal . "</b><br>";
include "report_footer.inc";
?>