<?php 
if($_REQUEST['Cancel']!='')
{
	unset($_SESSION['EONumber']);
}
if($_REQUEST['Save']!='')
{
	$Insert="Insert into export_proforma_invoice set
				site='".$_REQUEST['site']."',    
				EONumber='".$_SESSION['EONumber']."',  
				PInvoiceNo='".$_REQUEST['PInvoiceNo']."',   
				PInvoiceDate='".FormatDateForSQL($_REQUEST['PInvoiceDate'])."',  
				createdBy='".$_SESSION['UserID']."',  
				createdDate='".date('Y-m-d')."',
				CompanyId='".$_SESSION['ACGCompanyId']."' ";
				
	$result=DB_query($Insert,$db);
	unset($_SESSION['EONumber']);
	
}
?>
<script language="JavaScript" type="text/javascript">
function generateCode(str)
{
	
	if (str.length==0)
  {
  document.getElementById("codeId").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("codeId").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","codeGenerator.php?site="+str,true);
xmlhttp.send();
}

function calculateTotal(a)
{
	var qty=document.getElementById("quantity_"+a).value;
	var price=document.getElementById("price_"+a).value;
	var unit=document.getElementById("pricePer_"+a).value;
	
	
	var total=qty*(price/unit);
	document.getElementById("totalValue_"+a).value=total.toFixed(2);
}
function getEOOrderDetail(str)
{
	if (str.length==0)
  {
  document.getElementById("codeId").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("codeId").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","codeGenerator.php?q="+str,true);
xmlhttp.send();
}
function item_window()
{
	window.open("getExportOrders.php?action=add&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>","item_popup_window","height=500,width=300,toolbar=no,menubar=no,dependent=yes,resizable =yes, scrollbars=yes");
	
}
function validate()
{
	if(document.getElementById("site").value=='0')
	{
		alert("Please Choose A Branch");
		return false;
	}
}
</script>
<p><h2 align="center">Export Proforma Invoice</h2></p>
<form action="" method="post">
	
<div style="overflow: auto; width:800px">
<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">	
 <?php 
            if($_SESSION['EONumber']!='')
            {
            $sql="Select * from export_sales_order where id='".$_SESSION['EONumber']."'";
			$result=DB_query($sql,$db);
			$myrow=DB_fetch_array($result);
			
			$sql="Select prefix from locations where loccode='".$myrow['site']."'";
			$result=DB_query($sql,$db);
			$row=DB_fetch_array($result);
			$sitePrefix=$row['prefix'];

			
			$PINoSql="Select PInvoiceNo from export_proforma_invoice where site='".$myrow['site']."' order by id desc";
			$PINoResult=DB_query($PINoSql,$db);
			if(DB_num_rows($PINoResult)>0)
			{
				$PINoRow=DB_fetch_array($PINoResult);
				$brk=substr($PINoRow['PInvoiceNo'],-4);
				$next=$brk+1;
				$final=str_pad($next,4,"0",STR_PAD_LEFT);
			}
			else 
			{
				$final="0001";
			}
			}
  ?>
	<tr>
    	<td>
        	<table width="30%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF" style="border:1px solid #CCC;">
          <tr>
            <th width="41%">Branch Name</th>
            <td width="59%"><select name="site" id="site" style="width: 98%; height: 20px" onchange="generateCode(this.value)">
              <?php $site_sql=DB_query("Select loccode, locationname from locations where loccode='".$myrow['site']."'",$db);
                while($site_row=DB_fetch_array($site_sql))
                {?>
              <option value="<?php echo $site_row['loccode'];?>"<?php echo($_SESSION['site']==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname'];?></option>
              <?php 	
                }
                ?>
            </select></td>
          </tr>
        </table>
        </td>
    </tr>
    <tr>
    <td>
    <fieldset style="background:#CCC;">
    <legend><strong>Order Information</strong></legend>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#FFFFFF">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="33%">
    <fieldset>
        <legend><strong>Order Details</strong></legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
          <tr>
            <th width="60%" scope="row">EO No.</th>
            <td width="40%">
            	
            <input type="submit" name="item_popup" value="+" id="item_popup"  onclick="item_window();" />
            <input name="EONumber" type="text" value="<?php echo $myrow['EONumber'];?>" size="25"  style="width:90%;" readonly/>
            </tr>
          <tr>
            <th scope="row">PI . No./Date</th>
            <td nowrap="nowrap"><input name="PInvoiceNo" type="text" value="<?php echo $sitePrefix."/PI-".$final?>" size="25"  style="width:49%;"/> <input name="PInvoiceDate" type="text" value="" size="25"  style="width:49%;" class="datepicker"/></td>
            </tr>
            <tr>
            <th scope="row">PO Ref. No./Date</th>
            <td nowrap="nowrap"><input name="PORefNo" type="text" value="<?php echo $myrow['PORefNo'];?>" size="25"  style="width:49%;"/> <input name="PORefDate" type="text" value="<?php echo ConvertSQLDate($myrow['PORefDate']);?>" size="25"  style="width:49%;" class="datepicker"/></td>
            </tr>
          <tr>
            <th scope="row">Sale Contract No. &amp; Date</th>
            <td nowrap="nowrap"><input name="saleContractNo" type="text" value="<?php echo $myrow['saleContractNo'];?>" size="25"  style="width:49%;"/>
              <input name="saleContractDate" type="text" value="<?php echo ConvertSQLDate($myrow['saleContractDate']);?>" size="25"  style="width:49%;" class="datepicker"/></td>
          </tr>
          <tr>
            <th scope="row">Shipment Date</th>
            <td><input name="shipmentDate" type="text" value="<?php echo ConvertSQLDate($myrow['shipmentDate']);?>" size="25"  style="width:100%;" class="datepicker"/></td>
          </tr>
          <tr>
            <th scope="row">Order Confirm Date</th>
            <td><input name="orderConfirmDate" type="text" value="<?php echo ConvertSQLDate($myrow['orderConfirmDate']);?>" size="25"  style="width:100%;" class="datepicker"/></td>
          </tr>
        </table>
    </fieldset>
    </td>
  </tr>
  <tr>
  	<td height="8"></td>
  </tr>
  <tr>
    <td>
    	<fieldset>
        <legend><strong>Shipment Details</strong></legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr  bgcolor="#B7B7B7">
            <td width="47%"><strong>Pre Carriage By</strong></td>
            <td width="53%"><strong>Reciept Place</strong></td>
          </tr>
          <tr>
            <td>
            <input type="text" name="" value="<?php echo $myrow['preCarriageBy'];?>" style="width: 100%" readonly/>	</td>
            <td><select name="receiptPlace" id="receiptPlace" style="width: 100%">
              <?php $c_sql=DB_query("Select id, country from country_master where country !='India' and id='".$myrow['receiptPlace']."'",$db);
                while($c_row=DB_fetch_array($c_sql))
                {?>
              <option value="<?php echo $c_row['id'];?>"><?php echo $c_row['country'];?></option>
              <?php 	
                }
                ?>
            </select></td>
          </tr>
          <tr bgcolor="#B7B7B7">
            <td><strong>Vessel Flight No.</strong></td>
            <td><strong>Port of Loading</strong></td>
          </tr>
          <tr>
            <td><input name="vesselFlightNo" type="text" value="<?php echo $myrow['vesselFlightNo']?>" size="25"  style="width:100%;" /></td>
            <td><select name="portOfLoading" style="width: 100%">
              <?php $p_sql=DB_query("Select * from port_master where id='".$myrow['portOfLoading']."'",$db);
                while($p_row=DB_fetch_array($p_sql))
                {?>
              <option value="<?php echo $p_row['id'];?>"><?php echo $p_row['name'];?></option>
              <?php 	
                }
                ?>
            </select></td>
          </tr>
          <tr bgcolor="#B7B7B7">
            <td><strong>Port of Discharge</strong></td>
            <td><strong>Place of Delivery</strong></td>
          </tr>
          <tr>
            <td><select name="portOfDischarge" style="width: 100%" onchange="generateCode(this.value)" >
               <?php $p_sql=DB_query("Select * from port_master where id='".$myrow['portOfDischarge']."'",$db);
                while($p_row=DB_fetch_array($p_sql))
                {?>
              <option value="<?php echo $p_row['id'];?>"><?php echo $p_row['name'];?></option>
              <?php 	
                }
                ?>
            </select></td>
            <td><input name="deliveryPlace" type="text" value="<?php echo $myrow['deliveryPlace']?>" size="25"  style="width:100%;" /></td>
          </tr>
          <tr bgcolor="#B7B7B7">
            <td><strong>Country of Origin</strong></td>
            <td><strong>Country of Destination</strong></td>
          </tr>
          <tr>
            <td><select name="originCountry" style="width: 100%" onchange="generateCode(this.value)" >
              <?php $c_sql=DB_query("Select id, country from country_master where id='".$myrow['originCountry']."'",$db);
                while($c_row=DB_fetch_array($c_sql))
                {?>
              <option value="<?php echo $c_row['id'];?>"><?php echo $c_row['country'];?></option>
              <?php 	
                }
                ?>
            </select></td>
            <td><select name="destinationCountry" style="width: 100%" onchange="generateCode(this.value)" >
              <?php $c_sql=DB_query("Select id, country from country_master where id='".$myrow['destinationCountry']."'",$db);
                while($c_row=DB_fetch_array($c_sql))
                {?>
              <option value="<?php echo $c_row['id'];?>"><?php echo $c_row['country'];?></option>
              <?php 	
                }
                ?>
            </select></td>
          </tr>
        </table>
        </fieldset>
    </td>
  </tr>
</table>

</td>
<td bgcolor="#FFFFFF" valign="top" width="30%">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
    	<fieldset>
        <legend><strong>Consignee/Buyer Details</strong></legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
          <tr>
            <td width="31%">
              <select name="consignee" style="width: 100%" onchange="partyAddress1(this.value)" >
                <?php $v_sql=DB_query("Select id, vendor_code, vendor_name from suppliers where vendor_code='".$myrow['consignee']."'",$db);
                while($v_row=DB_fetch_array($v_sql))
                {?>
                <option value="<?php echo $v_row['vendor_code'];?>"><?php echo $v_row['vendor_name'];?></option>
                <?php 	
                }
                ?>
              </select></td>
            </tr>
          <?php $vendor_sql=DB_query("Select adrress1,adrress2,address3,country,state,city from suppliers where vendor_code='".$myrow['consignee']."'",$db);
          $vendor_row=DB_fetch_array($vendor_sql);
		  $cityName=$fnLib->getField('city_master','id',$vendor_row['city'],'city');
	      $stateName=$fnLib->getField('state_master','id',$vendor_row['state'],'state');
		  $countryName=$fnLib->getField('country_master','id',$vendor_row['country'],'country');
          ?>
          <tr><td id="party1"><table width="100%" border="0">
          <tr>
            <td><input name="address1" type="text" value="<?php echo $vendor_row['adrress1'];?>" size="25"  style="width:100%;" class=""/></td>
            </tr>
          <tr>
            <td><input name="address2" type="text" value="<?php echo $vendor_row['adrress2']." ".$vendor_row['address3'];?>" size="25"  style="width:100%;" class=""/></td>
            </tr>
          <tr>
            <td><input name="address3" type="text" value="<?php echo $cityName." ".$stateName." ".$countryName;?>" size="25"  style="width:100%;" class=""/></td>
          </tr></table></td>
          </tr>
          
          
          <tr></tr>
        </table>
    </fieldset>
    </td>
    </tr>
  <tr>
    <td>
    	<fieldset>
        <legend><strong>Buyer (if other than consignee)</strong>        </legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
          <tr>
            <td width="31%">
              <select name="otherThanConsignee" style="width: 100%" onchange="partyAddress2(this.value)" >
               <?php $v_sql=DB_query("Select id, vendor_code, vendor_name from suppliers where vendor_code='".$myrow['otherThanConsignee']."'",$db);
                while($v_row=DB_fetch_array($v_sql))
                {?>
                <option value="<?php echo $v_row['vendor_code'];?>"><?php echo $v_row['vendor_name'];?></option>
                <?php 	
                }
                ?>
              </select></td>
            </tr>
            <?php $vendor_sql=DB_query("Select adrress1,adrress2,address3,country,state,city from suppliers where vendor_code='".$myrow['otherThanConsignee']."'",$db);
          $vendor_row=DB_fetch_array($vendor_sql);
		  $cityName=$fnLib->getField('city_master','id',$vendor_row['city'],'city');
	      $stateName=$fnLib->getField('state_master','id',$vendor_row['state'],'state');
		  $countryName=$fnLib->getField('country_master','id',$vendor_row['country'],'country');
          ?>
            <tr><td id="party1"><table width="100%" border="0">
          <tr>
            <td><input name="address1" type="text" value="<?php echo $vendor_row['adrress1'];?>" size="25"  style="width:100%;" class=""/></td>
            </tr>
          <tr>
            <td><input name="address2" type="text" value="<?php echo $vendor_row['adrress2']." ".$vendor_row['address3'];?>" size="25"  style="width:100%;" class=""/></td>
            </tr>
          <tr>
            <td><input name="address3" type="text" value="<?php echo $cityName." ".$stateName." ".$countryName;?>" size="25"  style="width:100%;" class=""/></td>
          </tr></table></td>
          </tr>
          <tr></tr>
        </table>
    </fieldset>
    </td>
    </tr>
  <tr>
    <td>
        <fieldset>
        <legend><strong>Agent Details</strong></legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
        <tr>
        <th width="50%" scope="row">Shipping Agent</th>
        <td width="50%"><select name="shippingAgent" style="width: 100%" onchange="generateCode(this.value)" >
          <?php $a_sql=DB_query("Select * from agent_type_master where agentType='Shipping' and id='".$myrow['shippingAgent']."'",$db);
                while($a_row=DB_fetch_array($a_sql))
                {?>
          <option value="<?php echo $a_row['id'];?>"><?php echo $a_row['agentName'];?></option>
          <?php 	
                }
                ?>
        </select></td>
        </tr>
        <tr>
        <th scope="row">Commission Agent</th>
        <td nowrap="nowrap"><select name="commissionAgent" style="width: 100%" onchange="generateCode(this.value)" >
          <?php $a_sql=DB_query("Select * from agent_type_master where agentType='Commision' and id='".$myrow['commissionAgent']."'",$db);
                while($a_row=DB_fetch_array($a_sql))
                {?>
          <option value="<?php echo $a_row['id'];?>"><?php echo $a_row['agentName'];?></option>
          <?php 	
                }
                ?>
        </select></td>
        </tr>
        <tr>
        <th scope="row">Nominee Agent</th>
        <td nowrap="nowrap"><select name="nomineeAgent" style="width: 100%" onchange="generateCode(this.value)" >
         <?php $a_sql=DB_query("Select * from agent_type_master where agentType='Nominee' and id='".$myrow['nomineeAgent']."'",$db);
                while($a_row=DB_fetch_array($a_sql))
                {?>
          <option value="<?php echo $a_row['id'];?>"><?php echo $a_row['agentName'];?></option>
          <?php 	
                }
                ?>
        </select></td>
        </tr>
        </table>
        </fieldset>
    </td>
    </tr>
</table>

</td><td bgcolor="#FFFFFF" valign="top" width="33%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td> 
    <fieldset>
        <legend><strong>LC Details</strong> </legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
          <tr>
            <th width="19%" scope="row">LC No./Date</th>
            <td width="31%" nowrap="nowrap"><input name="LCNo" type="text" value="<?php echo $myrow['LCNo'];?>" size="25"  style="width:49%;"/>
              <input name="LCDate" type="text" value="<?php echo ConvertSQLDate($myrow['LCDate']);?>" size="25"  style="width:49%;" class="datepicker"/></td>
            </tr>
          <tr>
            <th scope="row">Payment Terms</th>
            <td><input name="paymentTerms" type="text" value="<?php echo $myrow['paymentTerms'];?>" size="25"  style="width:100%;" class=""/></td>
            </tr>
          <tr>
            <th scope="row">Payment Desc.</th>
            <td><input name="paymentDesc" type="text" value="<?php echo $myrow['paymentDesc'];?>" size="25"  style="width:100%;" class=""/></td>
            </tr>
          <tr>
            <th scope="row">Notify</th>
            <td><input name="notify" type="text" value="<?php echo $myrow['notify'];?>" size="25"  style="width:100%;" class=""/></td>
          </tr>
          <tr>
            <th scope="row">Bank</th>
            <td><input name="bank" type="text" value="<?php echo $myrow['bank'];?>" size="25"  style="width:100%;" class=""/></td>
          </tr>
          <tr>
            <th scope="row">Shipping Mark</th>
            <td><input name="shippingMark" type="text" value="<?php echo $myrow['shippingMark'];?>" size="25"  style="width:100%;" class=""/></td>
          </tr>
          <tr>
            <th scope="row">Partial Shipment</th>
            <td><input name="partialShippment" type="text" value="<?php echo $myrow['partialShippment'];?>" size="25"  style="width:100%;" class=""/></td>
          </tr>
        </table>
    </fieldset>
   </td>
  </tr>
  <tr>
    <td> 
    <fieldset>
        <legend><strong>Other Details</strong></legend>
        <table width="100%" border="0" cellspacing="1" cellpadding="2" align="center">
          <tr bgcolor="#B7B7B7">
            <td width="46%"><strong>Currency</strong></td>
            <td width="54%"><strong>Conversion Rate</strong></td>
          </tr>
          <tr>
            <td><select name="currency" style="width: 100%" onchange="showRate(this.value)" >
              <?php $curr_sql=DB_query("Select * from currency_master where id='".$myrow['currency']."'",$db);
                while($curr_row=DB_fetch_array($curr_sql))
                {?>
              <option value="<?php echo $curr_row['id'];?>"><?php echo $curr_row['currency'];?></option>
              <?php 	
                }
                ?>
            </select></td>
            <?php 
           $rateSql=DB_query("Select rate from currency_master where id='".$myrow['currency']."'",$db);
		   $rateRow=DB_fetch_array($rateSql);
            ?>
            <td id="rateDiv"><input name="currencyRate" id="currencyRate" type="text" value="<?php echo $rateRow['rate']?>" size="25"  style="width:100%;" /></td>
          </tr>
          <tr bgcolor="#B7B7B7">
            <td colspan="2"><strong>Sales Key Executive</strong></td>
            </tr>
          <tr>
            <td colspan="2"><select name="salesExecutive" style="width: 100%" onchange="generateCode(this.value)" >

              <?php $salesman_sql=DB_query("Select * from salesman_master where id='".$myrow['salesExecutive']."'",$db);
                while($salesman_row=DB_fetch_array($salesman_sql))
                {?>
              <option value="<?php echo $salesman_row['id'];?>"><?php echo $salesman_row['sales_name'];?></option>
              <?php 	
                }
                ?>
            </select></td>
            </tr>
          <tr bgcolor="#B7B7B7">
            <td colspan="2"><strong>Remarks</strong></td>
            </tr>
          <tr>
            <td colspan="2"><input name="remarks1" type="text" value="<?php echo $myrow['remarks1'];?>" size="25"  style="width:100%;" /></td>
            </tr>
        </table>
    </fieldset>
   </td>
  </tr>
</table>

   
</td>
</tr>

</table>
</fieldset>
</td></tr></table>
</div>
<br/>
<div style="overflow: auto; width: 800px;">
  <table width="100%" border="0" cellpadding="2" cellspacing="2">
    <tr>
      <th>Item Code</th>
      <th width="25%">Item Name</th>
      <th>Unit</th>
      <th>Qty</th>
      <th>Price</th>
      <th>Per Unit(s)</th>
      <th>Value</th>
      <th  width="8%">Discount Type</th>
      <th  width="8%">Discount</th>
      <th width="8%">Discounted Value</th>
      </tr>
    <?php 
	$detailsSql=DB_query("Select * from export_order_details where parentId='".$_SESSION['EONumber']."'",$db);
	while($detailsRow=DB_fetch_array($detailsSql))
	{
		$item_sql=DB_query("Select * from item_master where StockID='".$detailsRow['itemCode']."'",$db);
		$item_row=DB_fetch_array($item_sql);
	
		$clientId=$s->getField('clientmaster','client_code',$_SESSION['enquiryParty'],'id');
		$itemId=$s->getField('item_master','StockID',$tt[$i],'id');
		
		$rate_sql=DB_query("Select Rate from rate_master where ItemId ='".$itemId."' and PartyId='".$clientId."' and DeActivate='0'",$db);
		$rate_row=DB_fetch_array($rate_sql);
		
	
	?>
   <tr bgcolor="#FFFFFF">
      
      <td><input type="text" name="itemCode[]" id="itemCode" value="<?php echo $detailsRow['itemCode'];?>" readonly="true"/></td>
      <td><input type="text" name="itemName[]" id="itemName" value="<?php echo $item_row['item_name'];?>" readonly="true"/></td>
      <?php $unitName=$fnLib->getField('unitsofmeasure','unitid',$item_row['unit'],'unitname')?>
      <td><input type="text" name="unit[]" id="unit" value="<?php echo $unitName;?>" readonly="true"/></td>
      <td><input type="text" name="quantity[]" id="quantity" value="<?php echo $detailsRow['quantity'];?>" readonly/></td>
      <td><input type="text" name="price[]" id="price" value="<?php echo $detailsRow['price'];?>" readonly/></td>
      <td><input type="text" name="pricePer[]" id="pricePer" value="1000" readonly onfocus="dispVal(this.id)" readonly/></td>
      <td><input type="text" name="totalValue[]" id="totalValue" value="<?php echo $detailsRow['totalValue'];?>" onfocus="calculateTotalValue(this.id)" readonly/></td>
      <td><input type="text" name="discountType[]" id="discountType" value="<?php echo $detailsRow['discountType'];?>" readonly/></td>
      <td><input type="text" name="discount[]" id="discount" value="<?php echo $detailsRow['discount'];?>" readonly/></td>
      <td><input type="text" name="discountedValue[]" id="discountedValue" value="<?php echo $detailsRow['discountedValue'];?>" onfocus="calculateDiscounted(this.id)" readonly/></td>
      </tr>
    <?php 	
} 
?>
    <input type="hidden" name="count" value="<?php echo $i;?>" />
  </table>
</div>
<div style="width:100%; margin:20px 0px 0px 0px;">
<table width="100%" border="0" cellspacing="0" cellpadding="5" style="border:1px solid #CCC;" bgcolor="#FFFFFF";>
  <tr>
    <td valign="top"><strong>Remarks</strong><br />
      <textarea name="remarks2" id="remarks2" cols="45" rows="5" style="width:100%;" readonly><?php echo $myrow['remarks2'];?></textarea>      </td>
    <td width="40%"><table width="95%" border="0" align="right" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF"; style="border:1px solid #CCC;">
  <tr>
    <th width="49%">Basic Value</th>
    <td width="51%" align="right"><input name="basicAmt" type="text" value="<?php echo $myrow['basicAmt'];?>" size="25" id="basic"  style="width:100%;" onfocus="calculateBasic()" readonly/></td>
  </tr>
  <tr>
    <th>Discount (if any)</th>
    <td align="right"><input name="discountPerc" id="discountPerc" type="text" value="<?php echo $myrow['discountPerc'];?>" size="25"  style="width:20%;" readonly/>
       <input name="discountAmount" id="discountAmount" type="text" value="<?php echo $myrow['discountAmount'];?>" size="25"  style="width:70%;" readonly/></td>
  </tr>
  <tr>
    <th>Advance  (if any)</th>
    <td align="right"><input name="advance" id="advance" type="text" value="<?php echo $myrow['advance'];?>" size="25"  style="width:100%;" readonly/></td>
  </tr>
  <tr>
    <th>Freight (if any)</th>
    <td align="right"><input name="freight" id="freight" type="text" value="<?php echo $myrow['freight'];?>" size="25"  style="width:100%;" readonly/></td>
  </tr>
   <tr>
    <th>Sale Contract Rs.</th>
    <td align="right"><input name="finalTotal" id="finalTotal" type="text" value="<?php echo $myrow['finalTotal'];?>" size="25"  style="width:100%;" onfocus="calculateFinalTotal()" readonly/></td>
  </tr>
  <tr>
    <th nowrap="nowrap">Sale Contract (Foreign Currency)</th>
    <td align="right"><input name="finalTotalForeign" id="finalTotalForeign" type="text" value="<?php echo $myrow['finalTotalForeign'];?>" size="25"  style="width:100%;" onfocus="calculateForeignTotal()" readonly/></td>
  </tr>
 
  <tr>
    <th>Round Off</th>
    <td align="right"><input type="checkbox" name="checkbox" id="checkbox" />
      <input name="roundOff" type="text" value="<?php echo $myrow['roundOff'];?>" size="25"  style="width:80%;" readonly/></td>
  </tr>
  <tr>
    <th>Sale Contract Value</th>
    <td align="right"><input name="grandTotal" id="grandTotal" type="text" value="<?php echo $myrow['grandTotal'];?>" size="25"  style="width:100%;" readonly/></td>
  </tr>
</table></td>
  </tr>
</table>


<div style="clear:both;"></div>
</div>
<div>
<p align="center"><input type="submit" name="Save" value="Save" onclick="return validate();"/><input type="submit" name="Cancel" value="Cancel"></p>
</div>
</form>