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

$data1='';
$data2='';
$data3='';
$data4='';
$data5='';
$data6='';
$data7='';
$data8='';
$data9='';
$data10='';

$sql = "select * from log_add_mrn where id = '".$gid."' ";
$result=DB_query($sql,$db);
$myrow=DB_fetch_array($result);

$data1.=ConvertSQLDate($myrow['grn_date']);
$data2.=$myrow['document_type'];
$data3.=$myrow['document_no'];
$data4.=ConvertSQLDate($myrow['doc_date']);
$data5.=$myrow['lr_no'];
$data6.=ConvertSQLDate($myrow['lr_date']);
$data7.=$myrow['form_type'];
$data8.=$myrow['form_no'];


$i=1;
$sqlQty = "SELECT * From log_addmrnqty Where grn_id='".$gid."'";
$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 SUM(dispatchqty) AS disqty From log_dispatchqty Where grn_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;}
	$pendingqty=$row2['reciveqty']-$row3['disqty'];

$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="'.$row2['reciveqty'].'" 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="" onblur="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 grn_id='".$gid."'";
$Qty_resultbox = DB_query($sqlQtybox, $db);
while($row2box=DB_fetch_array($Qty_resultbox))
{
$k=$j+1;
$data10.='<tr>';
if($row2box['dispatch']==1){
$data10.='<td class="tabledata"><input name="" type="checkbox" id="disboxid_'.$j.'" value="1" checked="checked"  disabled="disabled" /></td>';
}else{
$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></tr>';
$j++;}
$data10.='<input type="hidden" name="countrow" id="countrow" value="'.$j.'" />';

echo $data=$data1.'__'.$data2.'__'.$data3.'__'.$data4.'__'.$data5.'__'.$data6.'__'.$data7.'__'.$data8.'__'.$data9.'__'.$data10;?>