<?php
$PageSecurity = 11;
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc'); 
include('includes/function_lib.php');


$SQLQUOTES=DB_query("SELECT * FROM quotation where id='".$_REQUEST['QuotesId']."'",$db);
$QuoteRow=DB_fetch_array($SQLQUOTES);
$data1="";
$data1.="<select name='order_type' id='order_type' style='width:206px;'   onchange='getorder(this.value)'>";
$data1.="<option value='Consolidate' ".($QuoteRow['order_type']=='Consolidate'?'selected':'').">TBI</option>";
$data1.="</select>";

$data2="";
$data2.="<table width='100%' border='1' cellspacing='0' cellpadding='0' style='border:#666666 solid 1px;'>";
		  $data2.="<tr class='row1'>";
		  $data2.="<td class='tabledata'>S.No</td>";
		  $data2.="<td class='tabledata'></td>";
		  $data2.="<td class='tabledata' style='width:40px;'>Item Code</td>";
		  $data2.="<td class='tabledata'>Item Name. </td>";
		  $data2.="<td class='tabledata'>Qty</td>";
		  $data2.="<td class='tabledata'>Price</td>";
		  $data2.="<td class='tabledata'>Total Amt</td>"; 
		  
		  $data2.="<td class='tabledata'>Excise Duty Rate</td>";
		  $data2.="<td class='tabledata'>ED Amt</td>";
		  $data2.="<td class='tabledata'>Remarks</td>";
		  $data2.="</tr>";
		  $data2.="<tbody id='dataTable'>";
		 // echo "SELECT * FROM quotation_details where parentId='".$QuoteRow['id']."'";
		  
$SQLItemList=DB_query("SELECT * FROM quotation_details where parentId='".$QuoteRow['id']."'",$db);
$i=0;
while($ItemList=DB_fetch_array($SQLItemList)){
$ItemCode=$s->GetFieldValue('item_master',"id='".$ItemList['itemCode']."'",'StockID');
$ItemName=$s->GetFieldValue('item_master',"id='".$ItemList['itemCode']."'",'item_name');
$ItemDesc=$s->GetFieldValue('item_master',"id='".$ItemList['itemCode']."'",'item_desc');
		  $data2.="<tr class='row1'>";
          $data2.="<td style='white-space:nowrap;' class='tabledata'><input name='delitem[]' type='checkbox' value='".$ItemList['id']."' /></td>";
          $data2.="<td class='tabledata'><input type='hidden' name='item_code[]' id='itemid' value='".$ItemList['itemCode']."' /></td>";
          $data2.="<td class='tabledata'>".$ItemCode."</td>";
          $data2.="<td class='tabledata' style='white-space:nowrap'>".$ItemName."</td>";
         
          $data2.="<td class='tabledata'><input type='text' name='Qty[]' id='qty_".$i."' value='".$ItemList['quantity']."' size='6' /></td>";
          $data2.="<td class='tabledata'><input type='text' name='price[]' value='".$ItemList['price']."' id='price_".$i."' onkeyup='calculateTotalAmt(this.value,this.id)' size='6'/></td>";
          $data2.="<td class='tabledata'><input type='text' name='stock_qty[]' value='".$ItemList['totalValue']."' id='totalamt_".$i."' readonly='true' size='9'/></td>";
		  
		 
		  
          $data2.="<td class='tabledata'>";
		  $data2.="<select name='EDRate[]' id='exciserate_".$i."' style='width:100px' 
onchange='calculateExcise(this.value,this.id)'>";
                  $data2.="<option value='0'>--Select--</option>";
$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
$ServiceRes=DB_query($ServiceSql,$db);
while($ServiceRow=DB_fetch_array($ServiceRes)){
	$sel1='';
	if($ItemList['EDRate']==$ServiceRow['id'])
	$sel1='selected';
         $data2.="<option value='".$ServiceRow['id']."' ".$sel1.">".$ServiceRow['caption']."</option>";}
         $data2.="</select>";
		 $data2.="</td>";
         $data2.="<td class='tabledata'><input type='text' name='EDAmt[]' value='".$ItemList['EDAmt']."' id='excisevalue_".$i."' size='6'/></td>";
         $data2.="<td class='tabledata'><textarea  name='remarks[]' value='' id='remarks' style='width:129px;'></textarea></td>";
         $data2.="<input type='hidden' name='ApprovalStatus[]' value='Pending'>";
         $data2.="</tr>";
$i++;}// END OF WHILE
$data2.="<input type='hidden' name='hiditemcount1' id='hiditemcount1' value='".$i."' />";
         $data2.="</tbody>";
         $data2.="</table>";
		 
		 
$data3="";
$data3.="<input name='basicAmount' type='text' value='".$QuoteRow['basicAmount']."'  style='width:150px;' onfocus='calculateBasic()' id='basicAmount'/>";

$data4="";
if($QuoteRow['order_type']!='Consolidate' && $QuoteRow['order_type']!='' ) { 

$dis='disabled'; 
}
$data4.="<select name='EDBillRate' id='EDRate' style='width:107px' onchange='calculateBillExcise(this.value)' ".$dis.">";
$data4.="<option value='0'>--Select--</option>";
$ServiceSql="select * from  excise_tax WHERE caption LIKE '%excise%'" ;
$ServiceRes=DB_query($ServiceSql,$db);
while($ServiceRow=DB_fetch_array($ServiceRes)){
$sel2='';
if($QuoteRow['exciseDuty']==$ServiceRow['id'])
$sel2='selected';
$data4.="<option value='".$ServiceRow['id']."' ".$sel2.">".$ServiceRow['caption']."</option>";
}
$data4.="</select>";
$data4.="<input name='totalDiscountedPrice' id='totalDiscountedPrice' type='text' value='".$QuoteRow['totalDiscountedPrice']."'  style='width:107px;' onfocus='calculateTotalExcise()'/>";


$data5="";
$data5.="<input name='ECessPercentage' id='ECessPercentage' type='text' value='".$QuoteRow['ECessPercentage']."'  readonly style='width:107px' />";
$data5.="<input name='ECessValue' id='ECessValue' type='text' value='".$QuoteRow['ECessValue']."' readonly onfocus='calculateECess()' style='width:107px'/>";

$data6="";
$data6.="<input name='SAHCessPercentage' id='SAHCessPercentage' type='text' value='".$QuoteRow['SAHCessPercentage']."' style='width:107px;' readonly/>";
$data6.="<input name='SAHCessValue' id='SAHCessValue' type='text' value='".$QuoteRow['SAHCessValue']."' style='width:107px;' readonly onfocus='calculateSAHCess()'/>";


$data7="";
$data7.="<input name='taxableAmount' id='taxableAmount' type='text' style='width:150px;' value='".$QuoteRow['taxableAmount']."' onfocus='calculateTaxable()'/>";


$data8="";
$data8.="<select name='VatCst' id='value3' onchange='calculateVATCST(this.value)' style='width:150px;'>";
$data8.="<option value=''>Select</option>";
$salesSql=DB_query("Select * from sales_tax_master",$db);
while($salesRow=DB_fetch_array($salesSql)){
$sel3='';
if($QuoteRow['VatCst']==$salesRow['salestax_id'])
$sel3='selected';
$data8.="<option value='".$salesRow['salestax_id']."' ".$sel3.">".$salesRow['tax_code']."</option>";
}
$data8.="</select>";
$data8.="<div id='VATId'>";
$data8.="<input name='VatCstValue' id='VatCstValue' type='text' value='".$QuoteRow['VatCstValue']."' style='width:150px;' readonly  onfocus='calculateEditVATCST()' />";
$data8.="</div>";
$data8.="<input type='hidden' name='' id='rate' value='".$rate."' />";


$data9="";
$data9.="<input name='grandTotal' id='grandTotal' type='text' value='".$QuoteRow['grandTotal']."'  style='width:150px;' onfocus='calculateGrand()' readonly='readonly'  />";

$data9.="<input type='hidden' name='quotesId' value='".$_REQUEST['QuotesId']."'>";
//$data9.="<input type='hidden' name='quotes_type' value='".$QuoteRow['process_quote_type']."'>";
		 
echo $data=$data1."__".$data2."__".$data3."__".$data4."__".$data5."__".$data6."__".$data7."__".$data8."__".$data9;
?>