Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/iws8/html/mcell/backup/
Upload File :
Current File : /var/www/html/mmishra/iws8/html/mcell/backup/consumed_item.php

<?php
//show page head
include "page_header.inc";
$submit = $_POST["submit"];
$start_pos = $_REQUEST["start_pos"];
$page_size = $_REQUEST["page_size"];

if ($start_pos == "") $start_pos = 0;
if ($page_size == "") $page_size = 20;

switch ($submit){
case "NEXT":
  $start_pos = $start_pos + $page_size;
  break;
case "PREVIOUS":
  $start_pos = $start_pos - $page_size;
  break;
case "FIND":
  $serial_no = strtoupper($_REQUEST["serial_no"]);
  $start_pos = 0;
  break;
default:
  $start_pos = 0;
  break;
}

$sql1 = "select issued_to, count(serial_no) qty, sum(unit_price) cost from stock_master";
if ($serial_no > '') $sql1 .= " where serial_no like '$serial_no%'";
$sql1 .= " group by issued_to having issued_to > ''";
$sql2 = $sql1;
$sql1 .= " order by issued_to limit $start_pos, $page_size";

$result1 = mysql_query($sql1, $link_id);
$result2 = mysql_query($sql2, $link_id);
if(!$result1) echo sql_error();
$query_data2 = mysql_fetch_row($result2);
$total_records = mysql_num_rows($result2);

echo "<b>Consumed Status:</b> (";
if (!$total_records)
  echo "None record found)<p>";
else{
  echo $total_records . " records found) ";
  echo "<b>Filter</b> by Serial No. <input type='text' name='serial_no' value='$serial_no' size='10'>";
  echo "<input type='submit' name='submit' value='FIND'>";

  //show table data
  echo "<table><tr><th>No.</th><th>Issued To</th><th>Qty</th><th>Cost</th><th>Details</th></tr>";
  $i = $start_pos;
  while ($qd1 = mysql_fetch_array($result1)){
    $i++;
    $issued_to = $qd1["issued_to"];
    $qty = $qd1["qty"];
    $cost = $qd1["cost"];
    echo "<tr valign='top' id='row";
    if ($i % 2) echo "1"; else echo "2";
    echo "'><td>$i</td><td>$issued_to</td><td>$qty</td><td>$cost</td><td>";
    echo "<table width='100%'><tr><th>Serial No.</th><th>Category</th><th>Price</th><th>Remark</th></tr>";
    $sql2 = "select serial_no, category_code, unit_price, remark from stock_master where issued_to='$issued_to' order by category_code";
    $result2 = mysql_query($sql2, $link_id);
    while ($qd2 = mysql_fetch_array($result2)){
      $j++;
      $s_no = $qd2["serial_no"];
      $category_code = $qd2["category_code"];
      $unit_price = $qd2["unit_price"];
      $remark = $qd2["remark"];
      echo "<tr valign='top' id='row";
      if ($j % 2) echo "1"; else echo "2";
      if (stristr($s_no, $serial_no)) echo "'><td><b>$s_no</b></td>";
      else echo "'><td>$s_no</td>";
      echo "<td>$category_code</td><td>$unit_price</td><td>$remark</td></tr>";
    }
    echo "</table></td></tr>";
  }
  echo "</table>";
  //echo table_data($sql1, $link_id, $start_pos, $db);
  echo "<div align='right'>Display <input type='text' name='page_size' value='$page_size' size='2'> records per page ";
  echo "<input type='hidden' name='start_pos' value='$start_pos'>";
  if ($start_pos >= $page_size){
    echo "<input type='submit' name='submit' value='PREVIOUS'> ";
  }
  $start_pos = $start_pos + $page_size;
  if ($start_pos < $total_records) echo "<input type='submit' name='submit' value='NEXT'>";
  echo "</div>";
}
include "page_footer.inc";
?>