<?php
session_start();
include("cls_conexion.php");
$CNN=new ClsMySQL();
include("conexion23.php");
include("phpmnu_fun.php");
//++
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
//++
/*
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
*/
$HW=V($_SESSION['SYS_HW']);
//-++++++
$StrGT="";$LStrMsg="";$LStrFoc="";$LStrMM="";
$LStrPag=V($_POST['TxtPag']);
//+++++++
$SYS_MSG="";
$SYS_FOC="Prv";
$SYS_KOD=0;
//+++++
$PRV_ORI="";
$PRV_NUM="";
$ES_XML=V($_POST['ES_XML']);
//
$IdUsu=vbval(V($_SESSION['SYS_USER_ID']));
//
include("ges_costeo_funciones.php");
include("ges_costeo_fun.php");
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Invoice Costeo</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="ja/ges_costeo3.js"></script>
<script type="text/javascript" src="ja/funciones28.js"></script>
<!--FIN_SCRIPT------------------------------------->
<link rel="stylesheet" type="text/css" href="css/estiloss.css"  />
<link rel="stylesheet" type="text/css" href="css/basic.css"  />
<link rel="stylesheet" type="text/css" href="css/mnu.css"  />

<link rel="stylesheet" type="text/css" href="tcal.css" />
<script type="text/javascript" src="tcal.js"></script> 


<style type="text/css">
	.tableFixHead          { overflow-y: auto; }
	.tableFixHead thead th { position: sticky; top: 0; }
	table  {border-collapse:collapse;width:100%;}
	th, td {padding: 2px 2px;}
	th     {background:#CCC;}
	
	
	.cF {height:950px;width:1250px;position:relative;top:0px}
	.mM {height:34px;width:1250px;position:relative;top:0px;background-color:#09C; z-index:500;}
	
	.tzt{
		background-color:transparent; width:100%; font-size:11px; position:inherit!Important; border:none;
	}
	
	.container {
	  width: 300px;
	}
	
	.inner {
	  display: flex;
	  overflow-x: scroll;
	}
	
	.inner::-webkit-scrollbar {
	  height: 8px;
	}
	  
	.inner::-webkit-scrollbar-thumb {
	  background-color:blue;
	}
	
	.inner::-webkit-scrollbar-track-piece:end {
	  margin-right:20px; 
	}
	
	.inner::-webkit-scrollbar-track-piece:start {
	  margin-left:20px;
	}
	
	.tdb{
		white-space:nowrap;
	}
	
	
	.tdx{
		white-space:nowrap; background-color:#F4F0A2;
	}
	.tdy{
		white-space:nowrap; background-color:#9BD6F4;
	}
</style>
<script>
	$(document).ready(function(){
	   Inicializar();
	   SYS_LOAD();  
	});
	function POP_ACT(){
		SM("");
	}
</script>

</head>

<body >
<div align="center">

<div class="mM" align="left" style="font-size:12px">
<?php
echo GEN_MENU($IdUsu);
?>
</div>


<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" >
<form id="Frm" name="Frm" method="post" action="ges_costeo.php" enctype="multipart/form-data"
autocomplete="off" style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">
<!--TITULO-------------------------------->
<div id="DivT" class="dT" >
<img src="png/ges_invoi.png" width="53" height="53" class="iT" />
<div class="tT">INVOICE - COSTEO </div>
</div>



<div class="s1" style="left: 35px; top: 124px; width: 66px;"> PROVEEDOR
</div>
<input name="Pro"  type="text" id="Pro"
class="roi" style="left: 35px; top: 142px; width: 165px" 
value="<?php echo $Pro;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 213px; top: 124px; width: 91px;">
  PROF. SERIE</div>
<input name="ProSer"  type="text" id="ProSer" 
class="roi" style="left: 210px; top: 142px; width: 103px" 
value="<?php echo $ProSer;?>" 
tabindex="<?php echo ++$TI;?>"/>



<div class="s1" style="left: 323px; top: 124px; width: 96px;">
PROF. NUMERO
</div>
<input name="ProNro"  type="text" id="ProNro"
class="roi" style="left: 321px; top: 142px; width: 102px" 
value="<?php echo $ProNro;?>"  
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 432px; top: 124px; width: 65px;">INV. SERIE</div>
<input name="InvSer"  type="text" id="InvSer"
class="roi" style="left: 431px; top: 142px; width: 73px" 
value="<?php echo $InvSer;?>" 
tabindex="<?php echo ++$TI;?>"/>






<div class="s1" style="left: 513px; top: 124px; width: 105px;"> INV. NUMERO
</div>
<input name="InvNro"  type="text" id="InvNro"
class="roi" style="left: 512px; top: 142px; width: 99px" 
value="<?php echo $InvNro;?>"  
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 620px; top: 124px; width: 65px;">FECHA</div>
<input name="Fec"  type="text" id="Fec"
class="roi" style="left: 620px; top: 142px; width: 92px" 
value="<?php echo $Fec;?>" 
tabindex="<?php echo ++$TI;?>"/>



<div class="s1" style="left: 720px; top: 124px; width: 127px;">
EMPRESA (TO)
</div>
<input name="EmpTo"  type="text" id="EmpTo"
class="roi" style="left: 722px; top: 142px; width: 128px" 
value="<?php echo $EmpTo;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 860px; top: 107px; width: 77px;">
PUERTO ORIGEN</div>
<input name="PueOri"  type="text" id="PueOri"
class="roi" style="left: 859px; top: 142px; width: 88px" 
value="<?php echo $PueOri;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 957px; top: 107px; width: 77px;">
PUERTO DESTINO</div>
<input name="PueDes"  type="text" id="PueDes"
class="roi" style="left: 956px; top: 142px; width: 119px" 
value="<?php echo $PueDes;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 1083px; top: 124px; width: 133px; text-align:center"> INVOICE
</div>

<?php
$BIS="";
$REF_KOD=vbval($REF_KOD);
if($REF_KOD>0){
	$BIS=" disabled ";
}
?>
<input type="button" name="CmdAddCos" id="CmdAddCos" 
value="Seleccionar" tabindex="<?php echo ++$TI;?>"
onClick="fxSelFac()" <?php echo $BIS;?> 
style="position: absolute; left: 1083px; top: 142px; width: 80px;"
/>

<input type="button" name="CmdInvVer" id="CmdInvVer" 
value="Ver" tabindex="<?php echo ++$TI;?>"
onClick="fxVerFac()"  
style="position: absolute; left: 1165px; top: 142px; width: 54px;"
/>
<a href="ges_invoice.php?Id=2452&Pag=0" id="LnkVer" target="new" style="display:none">Ver</a>
<script>
function fxVerFac(){
	var fac_kod=gv("FAC_KOD");
	if(jL(fac_kod)==0){
		alert("Seleccione un invoice");
		return;
	}
	document.getElementById("LnkVer").href="ges_invoice.php?Id="+fac_kod;
	document.getElementById("LnkVer").click();
}
function fxSelFac(){
	Ow("ges_costeo_sel_inv.php",1150,620);
}
</script>

<?php
$ZSS="";
$DIS="";
$REF_KOD=vbval($REF_KOD);
if($REF_KOD==0){
	$ZSS="rod";
	$DIS=" disabled ";
}
?>

<div class="s1" style="left: 35px; top: 183px; width: 133px; display:none">
PRODUCT NAME</div>
<input name="ProNom"  type="text" id="ProNom"
class="lt <?php echo $ZSS;?>" style="left: 35px; top: 200px; width: 224px; display:none" 
value="<?php echo $ProNom;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 270px; top: 167px; width: 137px; text-align: center; display:none">
ORDER QTY</div>

<div class="s1" style="left: 270px; top: 183px; width: 49px;; display:none">
CTNS</div>
<input name="ProCtn"  type="text" id="ProCtn"
class="ned <?php echo $ZSS;?>" style="left: 270px; top: 200px; width: 59px; display:none" 
value="<?php echo $ProCtn;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 343px; top: 183px; width: 47px;; display:none">
SET/U</div>
<input name="ProSet"  type="text" id="ProSet"
class="ned <?php echo $ZSS;?>" style="left: 338px; top: 200px; width: 70px; display:none" 
value="<?php echo $ProSet;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 419px; top: 169px; width: 80px;; display:none">
UNIT PRICE (USD)</div>
<input name="ProPre"  type="text" id="ProPre"
class="ndd <?php echo $ZSS;?>" style="left: 419px; top: 200px; width: 80px; display:none" 
value="<?php echo $ProPre;?>" 
tabindex="<?php echo ++$TI;?>"/>


<input type="button" name="CmdAddPro" id="CmdAddPro" 
value="Agregar" tabindex="<?php echo ++$TI;?>"  disabled
onClick="fxAddPro()" style="position: absolute; left: 509px; top: 200px; width: 102px;; display:none"/>

<style type="text/css">
	.tda{border:1px solid #000;padding-left:0.5rem}
	.tdb{border:1px solid #000;text-align:right; padding-right:0.5rem}
	.tdz{
		position:sticky;
		bottom:0;
		background:#ffffcc;   /* para que destaque */
		font-weight:bold;
		z-index:2;
		border-top:2px solid #999;
		font-size:11px;
		padding-right:0.5rem;
		text-align:right;
		border: 1px solid black;
	}
</style>
<div class="tableFixHead" style="position: absolute; left: 35px; top: 230px; width: 1185px; height: 201px; overflow: auto; border: solid 1px #A9A9A9">
<table width="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;" >
<thead>
    <tr>
    <th style="border: 1px solid black;" width="1%">#</th>
    <th style="border: 1px solid black;" width="9%">CODIGO</th>
    <th style="border: 1px solid black;" width="23%">PRODUCT NAME</th>
    <th style="border: 1px solid black;" width="5%">CTNS</th>
    <th style="border: 1px solid black;" width="5%">SET/U</th>
    <th style="border: 1px solid black;" width="6%">UNIT PRICE </th>
    <th style="border: 1px solid black;" width="5%">FOB</th>    
    <th style="border: 1px solid black; font-size:8px" width="8%">FOB + COSTO PRORRATEADO (SIN MARGEN DE UTILIDAD)</th>
    <th style="border: 1px solid black; font-size:8px" width="7%">IMPORT CON MARGEN DE UTILIDAD 3% (VALOR DE VENTA)</th>
    <th style="border: 1px solid black; text-align:center" width="2%">#</th>
    <th style="border: 1px solid black; text-align:center" width="2%">#</th>
    
    <th style="border: 1px solid black; text-align:center; background-color:#FFF" width="1%"></th>
    
    <th style="border: 1px solid black; text-align:center" width="4%">UNIDAD DE VENTA</th>
    <th style="border: 1px solid black; text-align:center" width="5%">CANTIDAD</th>
    <th style="border: 1px solid black; text-align:center" width="4%">PRECIO</th>
    <th style="border: 1px solid black; text-align:center" width="4%">TOTAL</th>
    <th style="border: 1px solid black; text-align:center" width="10%">PRECIO POR CAJA</th>
    
    
    </tr>
</thead>
<tbody>
<?php
$BX=0;
$SUM_CTN=0;
$SUM_FOB=0;
$SUM_EX1=0;
$SUM_EX2=0;
$SUM_FIN=0;
$REF_KOD=vbval($REF_KOD);
$s="SELECT * FROM ges_xml_costeo_det_pro WHERE id_ref=$REF_KOD ORDER BY id";
$rs=grs($s);
while($r=$rs->fetch_assoc()){
	$SUM_CTN=$SUM_CTN + $r['pro_ctn'];
	$SUM_FOB=$SUM_FOB + $r['pro_fob'];
	//
	$SUM_EX1=$SUM_EX1 + $r['pro_ext1'];
	$SUM_EX2=$SUM_EX2 + $r['pro_ext2'];
	$CODIGO=gs("pro_cod","ges_productos","id_pro=".$r['pro_kod']);
	$UNIDAD=gs("UND","vis_ges_productos","ID=".$r['pro_kod']);
	$BX++;
	$CSS="";
	if($BX%2==0)$CSS=' style="background-color:#E8E8E8" ' ;
?>
    <tr <?php echo $CSS;?>>
    <td class="tda"><?php echo $BX;?></td>
    <td class="tda"><?php echo $CODIGO;?></td>
    <td class="tda"><?php echo $r['pro_nom'];?></td>
    <td class="tdb"><?php echo NF2($r['pro_ctn'],2);?></td>
    <td class="tdb"><?php echo NF2($r['pro_set'],2);?></td>
    <td class="tdb"><?php echo NF2($r['pro_pre'],3);?></td>
    <td class="tdb"><?php echo NF2($r['pro_fob'],3);?></td>
    <td class="tdb"><?php echo NF2($r['pro_ext1'],3);?></td>
    <td class="tdb"><?php echo NF2($r['pro_ext2'],3);?></td>
    <td class="tda" style="padding-right:0.4rem">
    <img src="img/el.png"  style="cursor:pointer; display:none" width="16" height="16"  disabled
    onClick="fxKillPro('<?php echo $r['id'];?>')">
    </td>
    <td class="tda" align="center" style="padding-right:0.4rem">
    <img src="img/b_edit.png"  style="cursor:pointer;display:none" width="16" height="16" 
    onClick="fxEdiPro('<?php echo $r['id'];?>')">
    </td>
    
    <td class="tda" style="background-color:#FFF">&nbsp;</td>
    <td class="tda" align="center"><?php echo $UNIDAD;?></td>
    
    <td class="tdb"><?php echo NF2($r['pro_set'],2);?></td>
    <?php
		$PRE_FIN=round($r['pro_ext2'] / $r['pro_set'],3);
		$TOT_FIN=round($PRE_FIN * $r['pro_set'],3);
		$CAJ_FIN=round($TOT_FIN / $r['pro_ctn'] ,3);
		
		$SUM_FIN=$SUM_FIN + $TOT_FIN;
	?>
    <td class="tdb"><?php echo NF2($PRE_FIN,2);?></td>
    <td class="tdb"><?php echo NF2($TOT_FIN,3);?></td>
    <td width="10%" class="tdb"><?php echo NF2($CAJ_FIN,3);?></td>
    
    </tr>
<?php
}
?>

<tfoot>
    <tr  >
    <td class="tdz" >&nbsp;</td>
    <td class="tdz" >&nbsp;</td>
    <td class="tdz" >TOTAL</td>
    <td class="tdz" ><?php echo NF2($SUM_CTN,2);?></td>
    <td class="tdz">&nbsp;</td>
    <td class="tdz">&nbsp;</td>
    <td class="tdz" ><?php echo NF2($SUM_FOB,3);?></td>
    <td class="tdz" ><?php echo NF2($SUM_EX1,3);?></td>
    <td class="tdz" ><?php echo NF2($SUM_EX2,3);?></td>
    <td class="tdz">&nbsp;</td>
    <td class="tdz">&nbsp;</td>
    
    <td class="tdz" style="background-color:#FFF">&nbsp;</td>
    <td class="tdz">&nbsp;</td>
    
    <td class="tdz">&nbsp;</td>
    <td class="tdz">&nbsp;</td>
    <td class="tdz"><?php echo NF2($SUM_FIN,3);?></td>
    <td class="tdz">&nbsp;</td>
    
    </tr>
</tfoot>

</tbody>
</table>
</div>
<script>
function fxAddCon(){
	//Ow(url,ancho,alto)
	Ow("ges_xml_costos.php",500,630);
}
</script>
<div class="s1" onClick="fxAddCon()" style="left: 35px; top: 440px; width: 140px; cursor: pointer; color: #03F">
<b>CONCEPTO</b></div>
<select name="Con" id="Con" <?php echo $DIS;?>
class="lt" style="left: 35px; top: 458px; width: 278px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("ct_nom","ges_xml_costos_tipos","id_ct>0",$Con,"N","S");
?>
</select>


<div class="s1" style="left: 327px; top: 440px; width: 87px;">
TOTAL</div>
<input name="ConTot"  type="text" id="ConTot"
class="ndd <?php echo $ZSS;?>" style="left: 327px; top: 458px; width: 105px" 
value="" 
tabindex="<?php echo ++$TI;?>"/>





<div class="s1" style="left: 445px; top: 440px; width: 96px;">
MONEDA</div>
<select name="ConMon" id="ConMon"  <?php echo $DIS;?> 
class="lt" style="left: 444px; top: 458px; width: 83px" 
tabindex="<?php echo ++$TI;?>">
<?php
	echo FCBO("valor","ges_xml_aux","tab='MND'",$ConMon,"N","S");
?>
</select>







<div class="s1" id="DivInvEli" style="left:223px; top: 53px; width: 251px; height:25px; background-color:#FF9; display:none">
  <table width="100%" border="0" style="font-family:Tahoma, Geneva, sans-serif; font-size:11px">
<tr>
<td>
<input type="checkbox" name="CH_INV_ELI" id="CH_INV_ELI" style="position:inherit" >
</td>
<td>&nbsp;</td>
<td>CONFIRMAR ELIMINAR FACTURA</td>
</tr>
</table>
</div>
<input type="button" name="CmdAddCos" id="CmdAddCos" 
value="Agregar" tabindex="<?php echo ++$TI;?>"
onClick="fxAddCosto()"   <?php echo $DIS;?>
style="position: absolute; left: 536px; top: 458px; width: 75px;"
/>


<div class="s1" style="left: 700px; top: 440px; width: 236px;">
TIPO DE CAMBIO (Por defecto 1)
</div>
<input name="TipCam"  type="text" id="TipCam"
class="ndd rod" style="left: 700px; top: 458px; width: 105px; background-color:#CBF5AF; padding-right:1rem" 
value="<?php echo $TipCam;?>" 
tabindex="<?php echo ++$TI;?>"/>

<input type="button" name="CmdTCam" id="CmdTCam" <?php echo $DIS;?> 
value="Asignar tipo de cambio" tabindex="<?php echo ++$TI;?>"
onClick="fxTipCam()"  
style="position: absolute; left: 815px; top: 458px; width: 200px;"
/>




<div class="s1" style="left: 700px; top: 513px; width: 331px;"> PORCENTAJE DE MARGEN DE UTILIDAD (Por defecto 3)
</div>
<input name="PorUti"  type="text" id="PorUti"
class="ndd rod" style="left: 700px; top: 532px; width: 105px; background-color: #CBF5AF;padding-right:1rem" 
value="<?php echo $PorUti;?>" 
tabindex="<?php echo ++$TI;?>"/>

<input type="button" name="CmdPorUti" id="CmdPorUti" <?php echo $DIS;?> 
value="Asignar margen de util." tabindex="<?php echo ++$TI;?>"
onClick="fxPorUti()"  
style="position: absolute; left: 815px; top: 532px; width: 200px;"
/>



<div class="s1" style="left: 700px; top: 577px; width: 285px;"> COMISION DE EXPORTACION (Por defecto 3)
</div>
<input name="ComExp"  type="text" id="ComExp"
class="ndd rod" style="left: 700px; top: 596px; width: 105px; background-color: #CBF5AF;padding-right:1rem" 
value="<?php echo $ComExp;?>" 
tabindex="<?php echo ++$TI;?>"/>

<input type="button" name="CmdComExp" id="CmdComExp" <?php echo $DIS;?> 
value="Asignar comision de export." tabindex="<?php echo ++$TI;?>"
onClick="fxComExp()"  
style="position: absolute; left: 815px; top: 596px; width:200px;"
/>




<style type="text/css">
	.tdc{border:1px solid #000;padding-left:0.5rem}
	.tdd{border:1px solid #000;text-align:right; padding-right:0.5rem}
</style>


<div class="tableFixHead" style="position: absolute; left: 35px; top: 487px; width: 573px; height: 289px; overflow: auto; border: solid 1px #A9A9A9">
<table id="TabCostos" width="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;" >
<thead>
    <tr>
    <th style="border: 1px solid black;" width="57%" height="21">CONCEPTO</th>
    <th style="border: 1px solid black;" width="19%" >Importe Inc. IGV Soles</th>
    <th style="border: 1px solid black;" width="16%" >Importe Inc. IGV USD</th>
    <th style="border: 1px solid black; text-align:center" width="4%">#</th>
    <th style="border: 1px solid black; text-align:center" width="4%">#</th>
    </tr>
</thead>
<tbody>
<?php
$SUM_IMP_SOL=0;
$SUM_IMP_DOL=0;
$REF_KOD=vbval($REF_KOD);
$s="SELECT * FROM vis_ges_xml_costeo_det WHERE REF_ID=$REF_KOD ORDER BY ID";
$rs=grs($s);
while($r=$rs->fetch_assoc()){
	$MND=$r['MND'];
	$TOT=$r['TOT'];
	//
	$IMP_SOL=0;
	$IMP_DOL=0;
	$CSS_SOL="";
	$CSS_DOL="";
	if($MND=="S"){
		$CSS_DOL="background-color:#DFDFDF";
		$CSS_SOL="background-color:#FFFFFF";
	}else{
		$CSS_SOL="background-color:#DFDFDF";
		$CSS_DOL="background-color:#FFFFFF";
	}
	$IMP_SOL=$r['TOT_SOL'];
	$IMP_DOL=$r['TOT_DOL'];
	$SUM_IMP_SOL=$SUM_IMP_SOL + $IMP_SOL;
	$SUM_IMP_DOL=$SUM_IMP_DOL + $IMP_DOL;
?>
    <tr>
    <td class="tdc"><?php echo $r['NOM'];?></td>
    <td class="tdd" style="<?php echo $CSS_SOL;?>"><?php echo NF2($IMP_SOL,2);?></td>
    <td class="tdd" style="<?php echo $CSS_DOL;?>"><?php echo NF2($IMP_DOL,2);?></td>
    <td class="tdc" style="padding-right:0.4rem">
    <img src="img/el.png"  style="cursor:pointer" width="16" height="16" 
    onClick="fxKillCos('<?php echo $r['ID'];?>')">
    </td>    
    <td class="tdc" align="center" style="padding-right:0.4rem">
    <img src="img/b_edit.png"  style="cursor:pointer" width="16" height="16" 
    onClick="fxEdiCos('<?php echo $r['ID'];?>')">
    </td>
    </tr>
<?php
}
?>
</tbody>
</table>
</div>




<div class="tableFixHead" style="position: absolute; left: 35px; top: 789px; width: 573px; height: 114px; overflow: auto; border: solid 1px #A9A9A9">

<table id="TabCostoz" width="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;" >
<tbody>
  
  <tr>
    <td  class="tdc" width="55%" ><b>GASTOS DE IMPORTACION</b></td>
    <td class="tdd" width="18%" align="right" style="padding-right:0.4rem">S/ <?php echo NF2($SUM_IMP_SOL,2);?></td>
    <td class="tdc" width="16%" align="right"  style="padding-right:0.4rem">$ <?php echo NF2($SUM_IMP_DOL,2);?></td>
    
    <td class="tdd" width="11%" >&nbsp;</td>

    
    
    </tr>
  <?php
  $SYS_COM_EXP=round($ComExp/100,2);
  $SUM_FOB_X3=round($SUM_FOB * $SYS_COM_EXP,2);//$SYS_COM_EXP=0.03
  ?>
  <tr>
    <td  class="tdc" >COMISION 3% DE EXPORTACION</td>
    <td class="tdd" >&nbsp;</td>
    <td class="tdc" align="right"  style="padding-right:0.4rem"><?php echo NF2($SUM_FOB_X3,2);?></td>
    <td class="tdd" >&nbsp;</td>
  </tr>
  <tr>
    <td  class="tdc" >IMPORTE USD FOB + 3% FLUCTUACION</td>
    <td class="tdd" >&nbsp;</td>
    <td class="tdc" align="right"  style="padding-right:0.4rem"><?php echo NF2($SUM_FOB,2);?></td>
    <td class="tdd" >&nbsp;</td>
  </tr>
  <?php
  $SYS_TOTAL=round($SUM_IMP_DOL +  $SUM_FOB_X3 + $SUM_FOB,2);
  ?>
  <tr>
    <td  class="tdc" >&nbsp;</td>
    <td class="tdd" style="text-align:left; padding-left:0.4rem; background-color:#FFC" ><b>TOTAL</b></td>
    <td class="tdc" align="right"  style="padding-right:0.4rem; background-color:#FFC"><?php echo NF2($SYS_TOTAL,2);?></td>
    <td class="tdd" >&nbsp;</td>
  </tr>
  <?php
  $SYS_FACTOR=round($SYS_TOTAL / $SUM_FOB,3);
  if(is_nan($SYS_FACTOR)){
	  $SYS_FACTOR=0;
  }
  if(is_infinite($SYS_FACTOR)){
	  $SYS_FACTOR=0;
  }
  ?>
  <tr>
    <td  class="tdc" >&nbsp;</td>
    <td class="tdd" style="text-align:left; padding-left:0.4rem; background-color:#039; color:#FFF" ><b>FACTOR</b></td>
    <td class="tdc" align="right"  style="padding-right:0.4rem; background-color:#FFC; color:#F00"><b><?php echo NF2($SYS_FACTOR,3);?></b></td>
    <td class="tdd" >&nbsp;</td>
  </tr>
  
</tbody>
</table>

</div>





<!--BOTONES-------------------------------->
<div class="s1" style="left: 35px; top: 85px; width: 500px; height: 26px;">
<input name="CmdB" type="button" id="CmdG" class="btm"
onclick="fGuardar();" 
<?php
if(vbval($REF_KOD)==0){
	echo "value=\"Guardar\"";
}else{			
	echo "value=\"Modificar\"";

	$StrAnu="N";//gs("anulado","compras","id_compra=$StrId");
	if($StrAnu=="S"){
	echo " disabled=\"disabled\"";
	}
}
?>
tabindex="<?php echo ++$TI;?>" />

<input name="CmdB" type="button" id="CmdC"  class="btm"
value="Nuevo" onClick="fCancelarPHP();"  
tabindex="<?php echo ++$TI;?>" />


<input name="CmdB" type="button" id="CmdE" class="btm"
value="Eliminar" onClick="fLEliminar();"
<?php
if(vbval($REF_KOD)==0){
	echo ' disabled="disabled" ';
}
?>
tabindex="<?php echo ++$TI;?>" />

<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar" onClick="fBuscar('ges_costeo_b.php');"  
tabindex="<?php echo ++$TI;?>" />


</div>
<!--BOTONES-------------------------------->
<!--INI_OCULTOS-------------------------------->
<?php include("ocultos.php");?>
<div>
<input name="TxtHora" type="hidden" id="TxtHora" value="0" />
<input name="TxtRuc_" type="hidden" id="TxtRuc_"  />       
</div>
<!--FIN_OCULTOS-------------------------------->
<input name="HW" id="HW" type="hidden"  value="<?php echo $HW;?>">

<input name="TXT_KIL" id="TXT_KIL" type="hidden"  value="<?php echo $TXT_KIL;?>">

<input name="SYS_MSG" type="hidden" id="SYS_MSG" value="<?php echo $SYS_MSG;?>"/>
<input name="SYS_FOC" type="hidden" id="SYS_FOC" value="<?php echo $SYS_FOC;?>"/>



<input name="SUM_FOB" type="hidden" id="SUM_FOB" value="<?php echo $SUM_FOB;?>"/>



<input name="SYS_TOTAL" type="hidden" id="SYS_TOTAL" value="<?php echo $SYS_TOTAL;?>"/>
<input name="SYS_FACTOR" type="hidden" id="SYS_FACTOR" value="<?php echo $SYS_FACTOR;?>"/>

<input name="REF_KOD" type="hidden" id="REF_KOD" value="<?php echo $REF_KOD;?>"/>

<input name="FAC_KOD" type="hidden" id="FAC_KOD" value="<?php echo $FAC_KOD;?>"/>

</form>
</div>
</div>
, 
</body>
</html>


