<?php $PageSecurity = 4;
global  $db;
include('includes/session.inc');
include('includes/function_lib.php');
include('includes/stockcalculation.php');
?>

<link href="css/professional/default.css" rel="stylesheet" type="text/css" />
<form name="form1" action="" method="post">

<table width="100%" border="0" style="border:1px solid #333333;" align="right" cellspacing="0" cellpadding="3">
<tr>
	<td><strong>Item Code/Name</strong></td>
	<td><input name="StockID" type="text" id="StockID" style="width:150px;"   onkeyup="getdata2(this.value);" /></td>
	<td><strong>Main category </strong></td>
	<td><select style="width:150px;" name="CategoryID" id="CategoryID"  onchange="getdata1(this.value);" >
		<option value="0">Select</option>
		<?php
        $item_query="SELECT * FROM stockmaincategory where CompanyId='".$_SESSION['ACGCompanyId']."'";
		$res=DB_query($item_query ,$db);
		while($item_row1=DB_fetch_array($res)){
		$p='';
		if($item_row1['id'] == $_REQUEST['CategoryID'])	
		$p="selected";?>
		 <option value="<?php echo $item_row1['id'];?>"<?php echo $p;?>><?php echo $item_row1['stockmaincategoryname'];?></option>
       <?php }?>
      </select></td>
	 
</tr>

</table>

<br /><br />
<div id="ItemListDiv">
<table width="100%" border="0" style="border:1px solid #333333;" align="right" cellspacing="0" cellpadding="3">
<tr style="height:30px;">
	<td style="border-bottom:1px solid #FF0000;"><strong>Select</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Item Code</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Item Name</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Item Description</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>UOM</strong></td>
	<td style="border-bottom:1px solid #FF0000;"><strong>Stock Bal</strong></td>
</tr>
<?php  

$sql=DB_query("Select id,StockID,item_name,item_desc,mst_unitid,mrp_rate,net_rate from item_master where CompanyId='".$_SESSION['ACGCompanyId']."'",$db); 

$i=0;
if(DB_num_rows($sql)>0)
{
	while($myrow=DB_fetch_array($sql))
	{ 	
		$parameter=$myrow['id'];
		
		$op=openingBalance($function_filter,$myrow['id']);
		//echo "openingBalance"."<br>";
		$in_1=receivedMRN($function_filter,$myrow['id']);
		//echo "receivedMRN"."<br>";
		$out_1=issueSlip($function_filter,$myrow['id']);
		// echo "issueSlip"."<br>";
		$out_2=issueSiteToSite($function_filter,$myrow['id']);		
		// echo "issuesitetosite"."<br>";
		$in_2=receivedSiteToSite($function_filter,$myrow['id']);
		// echo " receivesitetosite"."<br>";
		$out_3=issueMatarialReturn($function_filter,$myrow['id']);
		
		$out_4=Rgpchallan($function_filter,$myrow['id']);
		$out_5=Nrgp($function_filter,$myrow['id']);
		$in_3=receivedReturn($function_filter,$myrow['id']);		 
		//$in_4=return_rejection($function_filter,$myrow['id']);
		$in_4=Rgpreturn($function_filter,$myrow['id']);
		$invalue=($op+$in_1[0]+$in_2+$in_3+$in_4);
		
		$outvalue=($out_1+$out_2+$out_3+$out_4+$out_5);
		$tot=trim($invalue)-trim($outvalue);
		
		
		$total_current=$tot;
?>
<tr bgcolor="#c1c1c1">
	<td><input type="checkbox" name="row_id[<?php echo $i;?>]" id="row_id_<?php echo $i;?>" value="<?php echo $parameter;?>" onclick="getItemsList('<?php echo $parameter;?>','<?php echo $myrow['StockID'];?>','<?php echo  $myrow['item_name'];?>','<?php echo $myrow['item_desc'];?>','<?php echo $myrow['net_rate'];?>','<?php echo $myrow['mrp_rate'];?>',<?php echo $total_current; ?>,'<?php echo $i;?>')"/></td>
	<td><strong><?php echo $myrow['StockID'];?></strong></td>
	<td><?php echo  $myrow['item_name'];?></td>
	<td><?php echo $myrow['item_desc'];?></td>
	<td><?php $unit=$s->getField('unitsofmeasure','unitid',$myrow['unit'],'unitname'); echo $unit;?></td>
	<td><?php echo $total_current; ?></td>
</tr>
	<?php $i++;} }?>
 </table>
 
 </div></form>
<script >



</script>
