<?php $PageSecurity = 11;
include('includes/session.inc');
include('includes/header.inc');
include('includes/SQL_CommonFunctions.inc');
include("includes/function_lib.php");
include('includes/stockcalculation.php');
$SQLP=DB_query("SELECT * FROM dbl_dealer_dispatch where id='".$_REQUEST['PickListId']."'",$db);
$SalesRec=DB_fetch_array($SQLP);

$SOINO=$s->GetFieldValue('dbl_process_sale_order',"id='".$SalesRec['SOI_no']."'",'SOI_no');
$data1="";
$data1.="<input name='soi_no' id='soi_no' type='hidden' style='width:150px;' value='".$SalesRec['SOI_no']."' />";
$data1.="<input name='soi_no1' id='soi_no1' type='text' style='width:150px;' value='".$SOINO."' />";

$data2="";
$data2.="<input name='soi_date' id='soi_date' type='text' style='width:150px;' class='datepicker' value='".ConvertSQLDate($SalesRec['SOI_date'])."' />";

$data3="";



$data3.="<table width='100%' border='1' cellspacing='0' cellpadding='3'>";
$data3.="<tr class='row1'>";
$data3.="<td class='tabledata'><strong>Sr. No.</strong></td>";
$data3.="<td class='tabledata'><strong>Part No.</strong></td>";
$data3.="<td class='tabledata'><strong>Part name</strong></td>";
$data3.="<td class='tabledata'><strong>Invoice Qty</strong></td>";
$data3.="<td class='tabledata'><strong>Returned Qty</strong></td>";
$data3.="<td class='tabledata'><strong>Accepted Qty </strong></td>";
$data3.="<td class='tabledata'><strong>Rate Amount</strong></td>";
$data3.="<td class='tabledata'><strong>Return Reason</strong></td>";
$data3.="<td class='tabledata'><strong>Return Type</strong></td>";
$data3.="<td class='tabledata'><strong>Store</strong></td>";
$data3.="</tr>";


$SQLDetails=DB_query("SELECT * FROM dbl_dealer_dispatch_details where parentid='".$_REQUEST['PickListId']."'",$db);
$i=0;
$k=$i+1;
while($GetpickDetails=DB_fetch_array($SQLDetails)){
$PartNo=$s->GetFieldValue('item_master',"id='".$GetpickDetails['mst_itemid']."'",'stockID');
$PartNames=$s->GetFieldValue('item_master',"id='".$GetpickDetails['mst_itemid']."'",'item_name');

$data3.="<tr class='row1'>";
$data3.="<td>".$k."</td>";
$data3.="<td>".$PartNo."</td>";
$data3.="<td>".$PartNames."<input name='mst_itemid[]' id='mst_itemid_".$i."' type='hidden' style='width:70px;' value='".$GetpickDetails['mst_itemid']."' readonly='' /></td>";
$data3.="<td>".$GetpickDetails['dispatch_qty']."<input name='invoice_qty[]' id='invoice_qty_".$i."' type='hidden' style='width:70px;' value='".$GetpickDetails['dispatch_qty']."' readonly='' /></td>";
$data3.="<td><input name='return_qty[]' id='return_qty_".$i."' type='text' onkeyup='chkretutnqty(this.value,this.id)' style='width:70px;' value='' /></td>";
$data3.="<td><input name='accepted_qty[]' id='accepted_qty_".$i."' onkeyup='chkacceptedqty(this.value,this.id)' type='text' style='width:70px;' value=''  /></td>";
$data3.="<td><input name='rate[]' id='rate_".$i."' type='text' style='width:70px;' value='".$GetpickDetails['rate']."' readonly='' /></td>";
$data3.="<td><input name='return_reason[]' id='return_reason_".$i."' type='text' style='width:80px;' value='' /></td>";
$data3.="<td><select style='width:150px;' name='return_type[]' id='return_type_".$i."'>";
$data3.="<option>--Select--</option>";
$data3.="<option value='Replacement'>Replacement</option>";
$data3.="<option value='Rejection'>Rejection</option>";
$data3.="</select>";
$data3.="</td>";
$data3.="<td><select name='dblstore[]' id='dblstore' style='width:70px;' >
 <option value='0'>Select</option>";

$sql1=DB_query("select * from dbl_dealer_store ",$db);
while($dbrow=DB_fetch_array($sql1))
{ 
$p='';
if($GetpickDetails['dblstore']==$dbrow['id'])
$p='selected="selected"';

$data3.="<option value=".$dbrow['id']." ".$p." >".$dbrow['dealer_store_name']."</option>";
}
$data3.="</select></td>";


$data3.="</tr>";
$i++;}
$data3.="</table>";
echo $data=$data1."__".$data2."__".$data3;
?>