<?php $PageSecurity = 11;
include('includes/session.inc');
include('includes/function_lib.php');
include('includes/SQL_CommonFunctions.inc');
global $db;
$gid=$_REQUEST['grnid'];
$storid=$_REQUEST['storid'];

$data9='';
$data10='';

$i=1;
$sqlQty = "SELECT * From log_dispatchqty Where dis_id='".$gid."' group by mst_itemid";

$Qty_result = DB_query($sqlQty, $db);
while($row2=DB_fetch_array($Qty_result))
{
	$itemcode=$s->getField('item_master','id',$row2['mst_itemid'],'StockID'); 
	$itemname=$s->getField('item_master','id',$row2['mst_itemid'],'item_name');
	$part_no=$s->getField('item_master','id',$row2['mst_itemid'],'part_no'); 
	$unitid=$s->getField('item_master','id',$row2['mst_itemid'],'mst_unitid');
	$unitname=$s->getField('unitsofmeasure','unitid',$unitid,'unitname'); 

	$sqlQty1 = "SELECT dispatchqty From log_dispatchqty Where dis_id='".$gid."' and mst_itemid='".$row2['mst_itemid']."'";
	$Qty_result1 = DB_query($sqlQty1, $db);
	$row3=DB_fetch_array($Qty_result1);
	if(DB_num_rows($Qty_result1)==0){$row3['disqty']=0;}
	
	$sqlQty11 = "SELECT SUM(transferqty) AS tfqty From log_srnqty Where dis_id='".$gid."' and mst_itemid='".$row2['mst_itemid']."'";
	$Qty_result11 = DB_query($sqlQty11, $db);
	$row11=DB_fetch_array($Qty_result11);
	if(DB_num_rows($Qty_result11)==0){$row11['tfqty']=0;}
	
	
	$pendingqty=$row3['dispatchqty']-$row11['tfqty'];

$data9.='<tr class="row1">';
$data9.='<td class="tabledata">'.$i.'</td>';
$data9.='<td class="tabledata"><input type="hidden" id="mstitemid_'.$i.'" name="mst_itemid[]" value="'.$row2['mst_itemid'].'"/></td>';
$data9.='<td class="tabledata"><input type="text" name="" id="itemcode_'.$i.'" value="'.$itemcode.'" readonly="true"/></td>';
$data9.='<td class="tabledata"><input type="text" name="item_name[]" id="itemname_'.$i.'" value="'.$itemname.'" readonly="true"/></td>';
$data9.='<td class="tabledata"><input type="text" name="part_no[]" id="part_no_'.$i.'" value="'.$part_no.'" readonly="true"/></td>';
$data9.='<td class="tabledata"><input type="text" name="uom[]" id="uom_'.$i.'" value="'.$unitname.'" readonly="true"/></td>';
	$data9.='<td class="tabledata"><input name="reciveqty[]" type="text" id="reciveqty_'.$i.'" value="'.$row3['dispatchqty'].'" readonly="true"/></td>';
$data9.='<td class="tabledata"><input name="pendingqty[]" type="text" id="pendingqty_'.$i.'" value="'.$pendingqty.'" readonly="true"/></td>';
$data9.='<td class="tabledata"><input name="dispatchqty[]" type="text" id="dispatchqty_'.$i.'" value="" onkeyup="checkqty('.$i.',this.value)"/></td>';
$data9.='</tr>';
$i++; }
$data9.='<input type="hidden" name="" value="'.$i.'" id="edit_cnt" />';

  

$j=0;
$sqlQtybox = "SELECT * From log_addmrnbox Where dis_id='".$gid."' AND package_no NOT IN (SELECT package_no From log_srnbox)";
$Qty_resultbox = DB_query($sqlQtybox, $db);
while($row2box=DB_fetch_array($Qty_resultbox))
{
$k=$j+1;
$data10.='<tr>';
$data10.='<td class="tabledata"><input name="disboxid['.$j.']" type="checkbox" id="disboxid_'.$k.'" value="1" /></td>';
$data10.='<td class="tabledata">'.$k.'<input type="hidden" name="box_id['.$j.']" id="box_id_'.$j.'" value="'.$row2box['id'].'"/></td>';
$data10.='<td class="tabledata"><input type="text" name="package_no['.$j.']" id="package_no_'.$j.'" value="'.$row2box['package_no'].'" readonly="true"/></td>';
$data10.='<td class="tabledata"><input type="text" name="no_of_package['.$j.']" id="no_of_package_'.$j.'" value="'.$row2box['no_of_package'].'" readonly="true"/></td>';
$data10.='<td class="tabledata"><input type="text" name="content['.$j.']" id="content_'.$j.'" value="'.$row2box['content'].'" readonly="true" ></td>';
$data10.='<td class="tabledata">';
$data10.='<select name="layout['.$j.']" id="layout_'.$j.'" disabled="disabled">';
$data10.='<option value="0">Select</option>';
$sql1=DB_query("select * from log_floor where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
while($sql_floor=DB_fetch_array($sql1))
{
	if($sql_floor['id']==$row2box['layout']){
	$data10.='<option value="'.$sql_floor['id'].'" selected="selected">'.$sql_floor['floor_name'].'</option>';
	}else{
	$data10.='<option value="'.$sql_floor['id'].'">'.$sql_floor['floor_name'].'</option>';
	}
}
$data10.='</select>';
$data10.='</td><td class="tabledata">';
$data10.='<select name="itemid1['.$j.']" id="itemid_'.$j.'" disabled="disabled">';
	$data10.='<option value="0">Select</option>';
	$sql2=DB_query("select * from item_master where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	while($sql_floor2=DB_fetch_array($sql2))
	{
		if($sql_floor2['id']==$row2box['itemid']){
		$data10.='<option value="'.$sql_floor2['id'].'" selected="selected">'.$sql_floor2['item_name'].'</option>';
		}else{
		$data10.='<option value="'.$sql_floor2['id'].'">'.$sql_floor2['item_name'].'</option>';
		}
	}
	$data10.='</select>';
	$data10.='<input type="hidden" name="itemid['.$j.']" id="itemid_'.$j.'" value="'.$row2box['itemid'].'" />';
$data10.='</td></tr>';
$j++;}
$data10.='<input type="hidden" name="countrow" id="countrow" value="'.$j.'" />';

echo $data=$data9.'__'.$data10;?>