| Current Path : /var/www/html/mmishra/iws8/html/pcstore/report/ |
| Current File : /var/www/html/mmishra/iws8/html/pcstore/report/consumption_project.php |
<?php
include "report_header.inc";
$mode = $_REQUEST["mode"];
$date1 = $_REQUEST["date1"];
$date2 = $_REQUEST["date2"];
if ($date1 == "") $date1 = (date("Y") - 1) . "-04-01";
if ($date2 == "") $date2 = date("Y") . "-03-31";
echo "<center><b class='reptitle'>$ttl Report</b><p><br>
Date <input type='text' name='date1' value='$date1' size='10'>
To <input type='text' name='date2' value='$date2' size='10'>
<input type='submit' name='submit' value='SHOW'><input type='hidden' name='mode' value='$mode'>
<div align='left'><b>Parts used in $no Products</b>
(<a href='report/list_computer_fur.php?mode=$mode&date1=$date1&date2=$date2'>List Inclosed</a>)</div>
<table width='100%' border='1' id='gray_box' cellspacing='0' cellpadding='5' bordercolordark='white' bordercolor='black' frame='box'>
<tr><th>No.</th><th>Item</th><th>Description</th><th>Quantity</th><th nowrap>Cost in Rs.</th></tr>";
$sql2 = "select im.category_code, im.description, count(pm.parts_code) as qty, sum(im.unit_price) as cost 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 pc.used_for=";
$sql1="select im.category_code,im.description,im.model_make,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 order by im.category_code, pi.issue_date";
$rs1 = mysql_query($sql1, $con);
if(!$rs1) echo sql_error();
while ($o = mysql_fetch_object($rs1)){
$i++; $j++;
$parts_code = $o->parts_code;
$issue_date = $o->issue_date;
$destination = $o->destination;
$issue_for = $o->issue_for;
$user_code = $o->user_code;
$customer = customer($user_code, $con);
$remark = $o->remark;
$description = $o->description;
$model_make = $o->model_make;
if ($category_code != $o->category_code){
$category_code = $o->category_code;
$category = category($category_code, $con);
echo "<tr><td colspan='8'><font color='red' size='+1' >Parts Category: $category</font></td></tr>";
$i=1;
}
if ($i % 2) echo "<tr id='row1'>"; else echo "<tr id='row2'>";
echo "<td>$i</td><td><a href='query/search_parts.php?parts_code=$parts_code'>$parts_code</a></td><td>$description</td><td>$model_make</td><td align='center' nowrap>$issue_date</td><td>$destination ($issue_for)</td><td>$customer</td><td>$remark</td></tr>";
}
echo "</table>";
echo "<font color='red' size='+1'>Total: $j</font>";
//=======
$sql1 = "select distinct pc_code as qty from product_configuration where used_for=";
$sql2 = "select im.category_code, im.description, count(pm.parts_code) as qty, sum(im.unit_price) as cost 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 pc.used_for=";
switch ($mode){
case "fab":
$ttl = "Fabrication";
$sql1 .= "'fabrication'";
$sql2 .= "'fabrication'";
break;
case "upg":
$ttl = "Upgradation";
$sql1 .= "'upgradation'";
$sql2 .= "'upgradation'";
break;
case "rep":
$ttl = "Replacement";
$sql1 .= "'replacement'";
$sql2 .= "'replacement'";
break;
}
if ($date1 <> $date2 and $date1 < $date2) $sql1 .= " and issue_date>='$date1' and issue_date<='$date2'";
$rs1 = mysql_query($sql1, $con);
$no = mysql_num_rows($rs1);
if ($date1 <> $date2 and $date1 < $date2) $sql2 .= " and issue_date>='$date1' and issue_date<='$date2'";
$sql2 .= " group by im.category_code";
$rs2 = mysql_query($sql2, $con);
echo "<center><b class='reptitle'>$ttl Report</b><p><br>
Date <input type='text' name='date1' value='$date1' size='10'>
To <input type='text' name='date2' value='$date2' size='10'>
<input type='submit' name='submit' value='SHOW'><input type='hidden' name='mode' value='$mode'>
<div align='left'><b>Parts used in $no Products</b>
(<a href='report/list_computer_fur.php?mode=$mode&date1=$date1&date2=$date2'>List Inclosed</a>)</div>
<table width='100%' border='1' id='gray_box' cellspacing='0' cellpadding='5' bordercolordark='white' bordercolor='black' frame='box'>
<tr><th>No.</th><th>Item</th><th>Description</th><th>Quantity</th><th nowrap>Cost in Rs.</th></tr>";
while ($qd2 = mysql_fetch_array($rs2)){
$i++;
$category_code1 = $qd2["category_code"];
$category = category($category_code1, $con);
$description = $qd2["description"];
$qty = $qd2["qty"];
$cost = $qd2["cost"];
$tqty += $qty;
$tcost += $cost;
echo "<tr><td>$i</td><td>$category</td><td>$description</td><td align='center'>$qty</td><td align='right'>$cost</td></tr>";
}
$tcost = number_format($tcost, 2);
echo "</table>
<div align='right'><b>Total $tqty Items Worth Rs. $tcost</b></div>
<p><p><input type='submit' name='submit' value='PRINT' onclick=\"window.print()\" />";
include "report_footer.inc";
?>