| Current Path : /var/www/html/mmishra/indem/mailscript/mcell/public_html/query/ |
| Current File : /var/www/html/mmishra/indem/mailscript/mcell/public_html/query/what_where.php |
<?php
include "../page_header.inc";
echo "<b>Whats Where ?</b><br>";
$submit = $_REQUEST["submit"];
$category_code = $_REQUEST["category_code"];
echo "Select <select name='category_code'><option value=''>Parts Category</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> ";
echo "<input type='submit' name='submit' value='SHOW LIST'><p>";
echo "<table width='100%'>";
echo "<tr bgcolor='gray'><td colspan='9'><font color='white' size='+1'>Issued to Customer</font></td></tr>";
echo "<tr><th>No.</th><th>Model/Make</th><th nowrap>Parts Code</th><th nowrap>Price</th><th nowrap>Receive Date</th><th nowrap>Issue Date</th><th>Customer</th><th>Purpose</th><th>Remark</th></tr>";
if ($category_code != ""){
$sql = "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 im.category_code=$category_code";
$rs = mysql_query($sql, $con);
if(!$rs) echo sql_error();
$qd = mysql_fetch_array($rs);
$obal = $qd["obal"];
echo "<b>Opening Balance: " . $obal . "</b><br>";
$sql = "select im.supplier_code, im.model_make, im.unit_price, im.receive_date, pm.parts_code, pi.issue_date, pi.destination, pi.issue_for, pi.user_code, pi.remark 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";
$sql .= " order by im.supplier_code, im.receive_date, pi.issue_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='9'><font color='red'>Supplier: $supplier</font></td></tr>";
}
$model_make = $qd["model_make"];
$unit_price = $qd["unit_price"];
$receive_date = $qd["receive_date"];
$parts_code = $qd["parts_code"];
$issue_date = $qd["issue_date"];
$destination = $qd["destination"];
$user_code = $qd["user_code"];
$user = customer($user_code, $con);
$issue_for = $qd["issue_for"];
$remark = $qd["remark"];
if ($i % 2) echo "<tr id='row1'>"; else echo "<tr id='row2'>";
echo "<td>$i</td><td>$model_make</td><td><a href='query/search_parts.php?parts_code=$parts_code'>$parts_code</a></td><td>$unit_price</td><td align='center'>$receive_date</td><td align='center'>$issue_date</td><td>$user</td><td>$destination ($issue_for)</td><td>$remark</td></tr>";
}
echo "<tr bgcolor='gray'><td colspan='9'><font color='white' size='+1'>Used in Products</font></td></tr>";
echo "<tr><th>No.</th><th>Model/Make</th><th nowrap>Parts Code</th><th nowrap>Price</th><th align='center'nowrap>Receive Date</th><th align='center'nowrap>Issue Date</th><th>Product Code</th><th>Purpose</th><th>Remark</th></tr>";
$sql="select im.supplier_code,im.model_make,im.unit_price,im.receive_date,pm.parts_code,pc.issue_date,pc.used_for,pc.pc_code, pm.remark from $parts_receipt im, $parts_master pm, $product_configuration pc where im.row_id=pm.item_code and pm.row_id=pc.parts_code and im.category_code=$category_code";
$sql .= " order by im.supplier_code, im.receive_date, pc.issue_date";
$rs=mysql_query($sql, $con);
if(!$rs) echo sql_error();
while ($qd = mysql_fetch_array($rs)){
$j++;
if ($supplier_code != $qd["supplier_code"]){
$supplier_code = $qd["supplier_code"];
$supplier = supplier($supplier_code, $con);
echo "<tr><td colspan='9'><font size='+1' color='red'>Supplier: $supplier</font></td></tr>";
}
$model_make = $qd["model_make"];
$unit_price = $qd["unit_price"];
$receive_date = $qd["receive_date"];
$parts_code = $qd["parts_code"];
$issue_date = $qd["issue_date"];
$issue_for = $qd["used_for"];
$pc_code = $qd["pc_code"];
$computer = product($pc_code, $con);
$remark = $qd["remark"];
if ($j % 2) echo "<tr id='row1'>"; else echo "<tr id='row2'>";
echo "<td>$j</td><td>$model_make</td><td><a href='query/search_parts.php?parts_code=$parts_code'>$parts_code</a></td><td>$unit_price</td><td align='center'>$receive_date</td><td align='center'>$issue_date</td><td><a href='/report/form_computer_issue.php?pc_code=$pc_code'>$computer</a></td><td>$issue_for</td><td>$remark</td></tr>";
}
//show closing balance
$sql="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('new','old')";
$rs=mysql_query($sql, $con);
if(!$rs) echo sql_error();
$qd = mysql_fetch_array($rs);
$cbal = $qd["cbal"];
}
echo "</table>";
echo "<b>Closing Balance: " . $cbal . "</b><br>";
include "../page_footer.inc";
?>