<?php $PageSecurity = 2;
include('includes/DefineSuppTransClass.php');
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
include('includes/session.inc');

include('includes/function_lib.php');
include('includes/fun-HRClass.php');
//echo $_GET['issueno'];
 //echo $_GET['q'];
 if($_GET['issueno']=='1')
 {
 	?>
 	<table width="100%" border="0" cellspacing="1" cellpadding="5" align="center">
  <tr>
    <th><strong>Item Code</strong></th>
     <th><strong>Issue Qty </strong></th>
   	<th><strong>Received Qty </strong></th>
  </tr>
<?php
 	$i=0;
	//echo "SELECT * FROM issueqty where issue_id='".$_GET['q']."' and status_Receive=0";
	$sql_query=DB_query("SELECT * FROM issueqty where issue_id='".$_GET['q']."' ", $db);
	while($row=DB_fetch_array($sql_query))
	{
	$itemcode=$s->getField('item_master','id',$row['mst_itemid'],'StockID');
	$unitdata=DB_query("select * from unitsofmeasure where unitid='".$row['uom']."'",$db);	
	$unitelement=DB_fetch_array($unitdata); 
	$issuid=$row['issue_id'];
	$i++;
	$pending_qty=$row['pending_qty'];
	if($pending_qty=='')
	{
	$pending_qty=$row['issueqty'];	
	}
	$date1=$s->getField('addissue','id',$_GET['q'],'issuedate');
	$stock_summary=DB_query("select * from stock_summary where site='".$_REQUEST['site']."'
		                 and store='".$_REQUEST['store']."' and item='".$row['mst_itemid']."'
						  and  date='".$date1."'",$db);
		$rowdata=DB_fetch_array($stock_summary);
		if($rowdata['closing_rate']=='')
		{
		  $get_previous_closing="Select * from stock_summary where site='".$_REQUEST['site']."' and store='".$_REQUEST['store']."' and item='".$row['mst_itemid']."' and date <'".$date1."' ORDER BY DATE DESC LIMIT 0,1";
						$previous_closing_result=DB_query($get_previous_closing,$db);
						$previous_closing_row=DB_fetch_array($previous_closing_result);
			               $outward_rate=$previous_closing_row['closing_rate'];
									
		
		}
		else
		{
		 $inward_rate=$rowdata['closing_rate'];
		}
		if($inward_rate=='')
		 $inward_rate=0;	
	
	
	?>
		<tr>
			<td ><?php echo $itemcode; ?>			
			<input type="hidden" name="itemid[]" id="itemid" value="<?php echo $row['mst_itemid']; ?>" /></td>			
			<input type="hidden" name="rate[]" id="rate" value="<?php echo $inward_rate; ?>" />			
			<td><?php 	echo $issueqty= $row['issueqty'];?>
			<input type="hidden" name="issueqty[]" id="issueqty_<?php echo $i; ?>" value="<?php echo $row['issueqty']; ?>" />
			</td>					
			<input type="hidden" name="pending_qty[]" id="pending_qty_<?php echo $i; ?>"  value="<?php echo $pending_qty; ?>"/>		
			<td ><input type="text" name="receiveqty[]" id="receiveqty_<?php echo $i; ?>" value="<?php echo $receiveqty;?>"    
			      onchange="chkbalance(<?php echo $i; ?>)"  /></td>			
		</tr>
		<input type="hidden" name="count" id="count" value="<?php echo $i;?>" />
	<input type="hidden" name="issue_id_check[]" value="<?php  echo $row['id']; ?>" />
<?php	} ?>
<input type="hidden" name="issue_id_data" value="<?php  echo $issuid; ?>" />
</table>

<?php  } ?>


