<?php
/* $Revision: 1.20 $ */
$PageSecurity = 2;
if (empty($_GET['identifier'])) {
			 $identifier=date('U');
		} else {
			$identifier=$_GET['identifier'];
		}
		
include('includes/session.inc');

$title = _('Search ItemCode ');

include('includes/header.inc');


if(isset($_POST['Submit']))
{
if($_POST['itmcode'] !='')
{
$itemcode = $_POST['itmcode'];

$Sql = "Select stockid, maincategoryid, categoryid, description, longdescription, units from stockmaster Where description Like '%$itemcode%' || stockid Like '%$itemcode%'";
$ErrMsg = _('Query Fail !') . '. ' . _('The error says');
$Result = DB_query($Sql,$db,$ErrMsg);
}
}
else
{
$Sql = "SELECT stockid, maincategoryid, categoryid, description, longdescription, units FROM stockmaster";
$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>&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 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>&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"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr bgcolor="#CCCCCC">
        <td width="4%" >&nbsp;</td>
        <td width="42%" >Item Code</td>
        <td width="54%">Item Name </td>
      </tr>
	  <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
	  <?php   
	  
	  $counter = $_REQUEST['rowcount'];
	  $ct = explode("_",$counter);
	  while($myrow =DB_fetch_array($Result))
	  {  
	 // $_SESSION['product_id'] =$myrow['stockid'];
	  ?>
	  <tr>
        <td>&nbsp;</td>
        <td><A HREF="javascript:loadValue('<?=$myrow['stockid'];?>','<?=$myrow['description'];?>','<?php echo $ct[2]; ?>')"><?=$myrow['stockid'];?></A></td>
        <td><?php echo $myrow['description'];?></td>
      </tr>
	  <?php } ?>
	  
	  
     
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
    </table></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>
</table>

</form>
<script>

function loadValue(i,d,ct)
{
	if(ct)
	{
		window.opener.document.getElementById('washing_profile_'+ct).value = i;
		window.opener.document.getElementById('desc_'+ct).value = d;
	}
	else
	{
		window.opener.document.getElementById('washing_profile').value = i;
		window.opener.document.getElementById('desc').value = d;
	}
	window.close();
}
</script>

<?
 
include('includes/footer.inc');
?>
	