Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/irp/pcstore/report/
Upload File :
Current File : /var/www/html/mmishra/irp/pcstore/report/consumption.php

<?php
include "report_header.inc";
echo "</center><b>Anual Consumption</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 "Parts Category <select name='category_code'>";
$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 

 Issue 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'> <a href='report/procurement.php?category_code=$category_code'>Procurement</a><p>";

echo "<table border='1' width='100%'>";
echo "<tr bgcolor='gray'><td colspan='8'><font color='white' size='+1'>Issued to Customers</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>User</th><th>Purpose</th><th>Remark</th></tr>";
echo "<tr><th>No.</th><th>Model/Make</th><th nowrap>Parts Code</th><th nowrap>Receive Date</th><th nowrap>Issue Date</th><th>User</th><th>Purpose</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 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>";

  $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 and pi.issue_date>='$date1' and pi.issue_date<='$date2' 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='8'><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"];
    $customer=customer($user_code, $con);
    $issue_for=$qd["issue_for"];
    $remark=$qd["remark"];
    echo "<tr><td>$i</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 align='center'>$issue_date</td><td>$customer</td><td>$destination ($issue_for)</td><td>$remark</td></tr>";
  }
  echo "<tr bgcolor='gray'><td colspan='8'><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 align='center'nowrap>Receive Date</th><th align='center'nowrap>Issue Date</th><th>PC Code</th><th>Purpose</th><th>Remark</th></tr>";
  $sql="select pm.row_id,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 and pc.issue_date>='$date1' and pc.issue_date<='$date2' 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)){
    $i++;
    $rid = $qd["row_id"];
    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>";
    }
    $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"];
    $product=product($pc_code, $con);
    
    if ($product == " ()"){
      $product = "xx";
      $sql1="update parts_master set status='old' where row_id=$rid";
      mysql_query($sql1, $con);
      $sql1="delete from product_configuration where parts_code=$rid";
      mysql_query($sql1, $con);
    }
    $remark=$qd["remark"];
    echo "<tr><td>$i</td><td>$model_make</td><td><a href='query/search_parts.php?parts_code=$parts_code'>$parts_code ($rid)</a></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'>$product</a></td><td>$issue_for</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'";
  $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";
?>