<?php
$PageSecurity = 2;
include('includes/session.inc');
$title = _('Search ItemCode ');
include('includes/header.inc');
if(isset($_POST['Submit']))
{
if($_POST['itmcode'] !='')
{
$itemcode = $_POST['itmcode'];

$Sql = "Select StockID,item_name,item_desc, unit ,make, color, grade from item_master Where description Like '%$itemcode%' || stockid Like '%$itemcode%'";
$ErrMsg = _('Query Fail !') . '. ' . _('The error says');
$Result = DB_query($Sql,$db,$ErrMsg);
}
}
else
{
$Sql = "SELECT * FROM item_master";
$ErrMsg = _('Query Fail!') . '. ' . _('The error says');
$Result = DB_query($Sql,$db,$ErrMsg);
}
?>
<form action="" method="post">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><div align="center"><b><?php echo $title; ?></b></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="24%">&nbsp;</td>
    <td width="11%">Item Name </td>
    <td width="19%"><input name="itmcode" type="text" id="itmcode" /></td>
    <td width="46%"><input type="submit" name="Submit" value="Search " /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4"><div style="overflow:auto; width:650px; height:300px">
      <table width="100%" border="0" cellspacing="3" cellpadding="3">
        <tr bgcolor="#CCCCCC">
          <td><strong>Item Code</strong></td>
          <td><strong>Item Name </strong></td>
          <td><strong>ITEM DESCRIPTION</strong></td>
          <td><strong>ITEM NO.</strong></td>
          <td><strong>FLEXO/OFFSET</strong></td>
          <td><strong>UNIT </strong></td>
          <td><strong>WIDTH</strong></td>
          <td><strong>LENGTH</strong></td>
          <td><strong>OD</strong></td>
          <td><strong>SERIAL NO.</strong></td>
          <td><strong>ORIGINAL/LOCAL</strong></td>
          <td><strong>TYPE</strong></td>
          <td><strong>SHADE</strong></td>
          <td><strong>RUNNING METER/ROLL</strong></td>
          <td><strong>VOLUME</strong></td>
          <td><strong>TEETH</strong></td>
          <td><strong>BCM</strong></td>
          <td><strong>UPS</strong></td>
          <td><strong>QUALITY</strong></td>
        </tr>
        <?php   
	  $counter = $_REQUEST['rowcount'];
	  $ct = explode("_",$counter);
	  $k=1;
	  while($myrow =DB_fetch_array($Result))
	  {  
	 
	 if($k%2==0)
		{$bg="#CCCCCC";}
		else
		$bg="#C8BECB";
	  $ct=1;
	 ?>
        <tr bgcolor="<?php echo $bg;?>">
          <td><?php   
				$rs1=DB_query("select * from product_manufacture where id = '".$myrow['make']."' ", $db); 
				$myrow1 =DB_fetch_array($rs1);
				$makename=$myrow1['manufacturer'];
				
				$rs2=DB_query("select * from product_color where id = '".$myrow['color']."' ", $db); 
				$myrow2 =DB_fetch_array($rs2);
				$colorname=$myrow2['color'];
				
				$rs3=DB_query("select * from product_grade where id = '".$myrow['grade']."' ", $db); 
				$myrow3 =DB_fetch_array($rs3);
				$gradename=$myrow3['grade'];
				
				$rs4=DB_query("select * from unitsofmeasure where unitid = '".$myrow['unit']."' ", $db); 
				$myrow4 =DB_fetch_array($rs4);
				$unitname=$myrow4['unitname'];
				?>
            <a href="javascript:loadValue('<?php echo $myrow['StockID'].",".$myrow['item_name'].",".$myrow['make'].",".$makename.",".$myrow['color'].",".$colorname.",".$myrow['grade'].",".$gradename.",".$myrow['unit'].",".$unitname;?>',<?php echo $_REQUEST['rowcount']?>)"><?php echo $myrow['StockID'];?></a></td>
          <td><?php echo $myrow['item_name'];?></td>
          <td><?php echo $myrow['item_desc'];?></td>
          <td><?php echo $myrow['item_no'];?></td>
          <td><?php echo $myrow['flexo_offset'];?></td>
          <td><?php echo $myrow['unit'];?></td>
          <td><?php echo $myrow['width'];?></td>
          <td><?php echo $myrow['length'];?></td>
          <td><?php echo $myrow['od'];?></td>
          <td><?php echo $myrow['serial_no'];?></td>
          <td><?php echo $myrow['orig_local'];?></td>
          <td><?php echo $myrow['type_name'];?></td>
          <td><?php echo $myrow['shade'];?></td>
          <td><?php echo $myrow['running_roll'];?></td>
          <td><?php echo $myrow['volume'];?></td>
          <td><?php echo $myrow['teeth'];?></td>
          <td><?php echo $myrow['bcm'];?></td>
          <td><?php echo $myrow['ups'];?></td>
          <td><?php echo $myrow['quality'];?></td>
        </tr>
        <?php $k++; } ?>
      </table>
    </div></td>
  </tr>
</table>

</form>
<script>

function loadValue(i,j)
{
 
	var name1;
	var name2;
	var spl = i.split(",");
	name1 = spl[0];
	name2 = spl[1];
	make = spl[2];
	makename = spl[3];
	color = spl[4];
	colorname = spl[5];
	grade = spl[6];
	gradename = spl[7];	
	uom = spl[8];
	uomname = spl[9];
	
	window.opener.document.getElementById('washing_profile_'+j).value = name1;
	window.opener.document.getElementById('desc_'+j).value = name2;
	window.opener.document.getElementById('hidmake_'+j).value = makename;
	window.opener.document.getElementById('make_'+j).value = make;
	
	window.opener.document.getElementById('color_'+j).value = color;
	window.opener.document.getElementById('hidcolor_'+j).value = colorname;
	
	window.opener.document.getElementById('gread_'+j).value = grade;
	window.opener.document.getElementById('hidgread_'+j).value = gradename;
	
	window.opener.document.getElementById('hiduom_'+j).value = uom;
	window.opener.document.getElementById('uom_'+j).value = uomname;
	
 	window.close();
	
	//window.opener.document.getElementById('StockID').value = i;
	//window.close();
}
</script>
<?
 
include('includes/footer.inc');
?>