<?php ob_start();
$PageSecurity = 4;
$PageName = 'Add Items';
include('includes/DefinePOClass.php');
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/DefineSuppTransClass.php');
include('includes/header.inc');
include('includes/function_lib.php');
$Sql = "SELECT StockID,item_name,unit FROM item_master where CategoryID='FG'";
$Result = DB_query($Sql,$db,$ErrMsg);
?>

<link rel="stylesheet" href="css/jquery.ui.all.css">
<script src="js/jquery-1.5.1.js"> </script>
<script src="ui/jquery.ui.core.js"> </script>
<script src="ui/jquery.ui.widget.js"></script>



<h2 align="center">ADD ITEMS</h2><br /><br />


<div align="center">
<div style="overflow:auto; width:600px; height:300px">
<form  action="" method="post">
<table width="100%" border="0" cellspacing="3" cellpadding="2" align="center">
  <tr>
        <th><strong>Item Code</strong></th>
        <th><strong>Item Name </strong></th>
		<th><strong>Unit</strong></th>
		<th><strong>Stock Balance</strong></th>
      </tr>
  <?php   
	  $counter = $_REQUEST['rowcount'];
	  $ct = explode("_",$counter);
	  while($myrow =DB_fetch_array($Result))
	  {  
		$make_sql=DB_query("Select manufacturer from product_manufacture where id='".$myrow['make']."'",$db);
		$make_row=DB_fetch_array($make_sql);
		
		$color_sql=DB_query("Select color from product_color where id='".$myrow['color']."'",$db);
		$color_row=DB_fetch_array($color_sql);
		
		$grade_sql=DB_query("Select grade from product_grade where id='".$myrow['grade']."'",$db);
		$grade_row=DB_fetch_array($grade_sql);
		
		$u_sql=DB_query("Select unitname from unitsofmeasure where unitid='".$myrow['unit']."'",$db);
		$u_row=DB_fetch_array($u_sql);
		
		$stock=DB_query("Select stockbalance from stock_maintenance where itemcode='".$myrow['StockID']."'",$db);
		$stock_row=DB_fetch_array($stock);
	  ?>
	  <tr bgcolor="#FFFFFF">
      <td><a href="javascript:loadValue('<?php echo $myrow['StockID'];?>,<?php echo $myrow['item_name'];?>,<?php echo $u_row['unitname']?>','<?php echo $ct[2];?>')"><?php echo $myrow['StockID'];?></a></td>
        <td><?php echo $myrow['item_name'];?></td>
		<td><?php echo $u_row['unitname'];?></td>
		<td><?php echo $stock_row['stockbalance'];?></td>
      </tr>
	  <?php } ?>
<input type="hidden" name="row_count" id="row_count" value="<?php echo $i;?>">
</table></form>
</div></div>

<script>
function loadValue(str,ct)
{
	var spl = str.split(",");
	var code = spl[0];
	var name = spl[1];
	var uomname = spl[2];
	
	if(ct)
	{
		window.opener.document.getElementById('itemCode_'+ct).value = code;
		window.opener.document.getElementById('itemName_'+ct).value = name;
		window.opener.document.getElementById('unit_'+ct).value = uomname;
	}
	else
	{
		window.opener.document.getElementById('itemCode').value = code;
		window.opener.document.getElementById('itemName').value = name;
		window.opener.document.getElementById('unit').value = uomname;
	}
	window.close();
}
</script>
