<?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;}
//+++++++++
$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="";
//
$IdUsu=vbval(V($_SESSION['SYS_USER_ID']));
//
$TODO_OK=1;
//
$MODO_AR=0;
include("ges_invoice_fun.php");
//
$VP_RegXPag=10;
$LStrTR=0;//gn("count(*)","temp_compras","temc_index>0 AND cod_temc='$StrHWND'");
$LStrPag=0;//PagGet($LStrPag,$StrCmd,$LStrTR,$VP_RegXPag);	
$TI=0;
//
$AT=gs("at","usuarios","id_usuario=$IdUsu");
//
$ACC_INV_ELI=USU_PER_GET($IdUsu,"INV_ELI");
$ACC_INV_EDI=USU_PER_GET($IdUsu,"INV_EDI");
?>

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Comercial invoice</title>
<!--INI_SCRIPT------------------------------------------------------------------------------>
<?php AddJs(); ?>
<script type="text/javascript" src="NumeroALetras.js"></script>
<script type="text/javascript" src="ja/ges_invoice7.js"></script>
<script type="text/javascript" src="ja/funciones.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"  />

<style type="text/css">
.tableFixHead          { overflow-y: auto; }
.tableFixHead thead th { position: sticky; top: 0; }
table  {border-collapse:collapse;width:100%;}
th, td {padding: 3px 3px;}
th     {background:#CCC;}


.cF {height:1100px;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();  
   
   //CHE_CLI();
   //CHE_SEG();
   
   kalcular();
   
   document.getElementById("TAB_AJAX").style.display="";
   document.getElementById("TAB_CAPTION").style.display="";
   //
   var acc_inv_eli=gv("ACC_INV_ELI");
   var acc_inv_edi=gv("ACC_INV_EDI");
   if(acc_inv_eli=="NO"){
	   document.getElementById("CmdE").disabled=true;
   }
   if(acc_inv_edi=="NO"){
	   document.getElementById("CmdG").disabled=true;
   }
   //
});
//----------------------------------------------------------
var FOCO=0;
var myVar=window.setInterval(function(){myTimer()},500);
//
var UNI_TOT=<?php echo gn("count(*)","ges_unidades","id_und>0");?>;
var UNI_ABR=new Array();
var UNI_FAC=new Array();

//
<?php
$IDX=0;
$s="SELECT * FROM ges_unidades WHERE id_und>0";
$rs=grs($s);
while($r=$rs->fetch_assoc()){
	$A=$r['und_abr'];
	$F=$r['und_factor'];
	$IDX++;
?>
UNI_ABR[<?php echo $IDX;?>]="<?php echo $A;?>";
UNI_FAC[<?php echo $IDX;?>]=<?php echo $F;?>;
<?php
}
?>
</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_invoice.php" 
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">COMERCIAL INVOICE </div>
</div>


<!--TEXTOS-------------------------------->

<div class="s1" style="left:35px; top: 136px; width: 107px;">
PROVEEDOR</div>
<select name="Prv" id="Prv"  onChange="PRV_OC()"
class="lt" style="left: 35px; top: 154px; width: 188px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("prv_nom","ges_proveedores","id_prv>0",$Prv,"N","S");
?>
</select>

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




<div class="s1" style="left:235px; top: 120px; width: 89px;">
  PROFORMA</div>
<div class="s1" style="left:235px; top: 136px; width: 63px;">
SERIE</div>


<div class="s1" style="left:332px; top: 136px; width: 89px;">
  NUMERO</div>
<p>
  <input name="ProNum"  type="text" id="ProNum"
class="nei" style="left:332px; top: 154px; width:90px" 
value="<?php echo $ProNum;?>"  onBlur="FILL_1(this)"
tabindex="<?php echo ++$TI;?>"/>
  
</p>
<div class="s1" style="left:434px; top: 120px; width: 132px;">
  INVOICE</div>
<div class="s1" style="left:434px; top: 136px; width: 55px;">
SERIE</div>
<input name="InvSer"  type="text" id="InvSer"
class="roi" style="left:434px; top: 154px; width:90px" 
value="<?php echo $InvSer;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left:532px; top: 136px; width: 71px;">
NUMERO</div>
<input name="InvNum"  type="text" id="InvNum"
class="nei" style="left:532px; top: 154px; width: 90px" 
value="<?php echo $InvNum;?>" onBlur="FILL_1(this)"
tabindex="<?php echo ++$TI;?>"/>

<?php if(strlen($Fec)==0)$Fec=date("d-m-y");?>
<div class="s1" style="left:632px; top: 136px; width: 71px;">
FECHA</div>
<input name="Fec"  type="text" id="Fec"
class="fe tcal" style="left:631px; top: 154px; width:90px" 
value="<?php echo $Fec;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 730px; top: 136px; width: 127px;">EMPRESA (TO)</div>
<select name="Emp" id="Emp"  
class="lt" style="left: 731px; top: 154px; width: 178px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("emp_nom_cor","ges_empresas","id_emp>0",$Emp,"N","S");
?>
</select>

<div class="s1" style="left:922px; top: 136px; width: 140px;">PUERTO ORIGEN</div>
<select name="PunOri" id="PunOri" 
class="lt" style="left:922px; top: 154px; width: 147px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("pto_nom","ges_puertos","pto_tip='ORIGEN'",$PunOri,"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 INVOICE</td>
</tr>
</table>
</div>


<div class="s1" style="left:1077px; top: 136px; width: 140px;">PUERTO DESTINO</div>
<select name="PunDes" id="PunDes" 
class="lt" style="left:1077px; top: 154px; width: 137px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("pto_nom","ges_puertos","pto_tip='DESTINO'",$PunDes,"N","S");
?>
</select>

<!--CHECKS-------------------------------->
<div class="s1" style="left: 51px; top: 197px; width: 137px;">
<label for="ChN_BAR">CODIGO DE BARRAS</label></div>
<input name="ChN_BAR" type="checkbox" id="ChN_BAR" 
class="lt" style="left:32px; top: 194px;"
value="1"   onchange="ChN_BAR_OnChange();"
<?php if($StrN_BAR=="1"){echo "checked=\"checked\"";}?>
/>


<div class="s1" style="left: 35px; top: 223px; width: 54px;">CODIGO</div>
<input name="Cod"  type="text" id="Cod"
style="left: 35px; top: 244px; width:97px"
tabindex="<?php echo ++$TI;?>" 
onKeyDown="return cCod(event);" 
onKeyUp="return cCodUP(event);" 
onFocus="FOCO=0;"
value='<?php echo $Cod;?>' />

<input name="ProSer"  type="text" id="ProSer"
class="roi" style="left:234px; top: 154px; width:90px" 
value="<?php echo $ProSer;?>" 
tabindex="<?php echo ++$TI;?>"/>

 
<div class="s1" style="left: 140px; top: 223px; width: 96px;">DESCRIPCION</div>
<input name="Des"  type="text" id="Des"
class="lt" style="left: 140px; top: 244px; width: 246px" 
value="<?php echo $Des;?>" 
onKeyDown="return cDes(event);" 
onKeyUp="return cDesUP(event);" 
onFocus="FOCO=1;"
tabindex='<?php echo ++$TI;?>'/>

<div class="s1" style="left: 395px; top: 223px; width: 60px;">MEASURES</div>
<input name="Mea"  type="text" id="Mea"
class="lt" style="left: 395px; top: 244px; width: 118px;text-transform:none;"
value="<?php echo $Mea;?>" 
onfocus="selecciona_value(this);"
tabindex='<?php echo ++$TI;?>'/>



<div class="s1" style="left: 522px; top: 223px; width: 60px;">PIEZAS</div>
<input name="Pie"  type="text" id="Pie"
class="ned" style="left: 521px; top: 244px; width: 53px;"
value="<?php echo $Pie;?>" onKeyUp="fImporte();"
onfocus="selecciona_value(this);"
tabindex='<?php echo ++$TI;?>'/>

<div class="s1" style="left: 580px; top: 223px; width: 47px;">CAJAS</div>
<input name="Caj"  type="text" id="Caj"
class="ned" style="left:581px; top: 244px; width: 59px;"
value="<?php echo $Caj;?>" onKeyUp="fImporte();"
onfocus="selecciona_value(this);"
tabindex='<?php echo ++$TI;?>'/>

<div class="s1" style="left:645px; top: 223px; width: 59px;">UNIDAD</div>
<select name="Und" id="Und"  onChange="fImporte()"
class="lt" style="left:647px; top: 244px; width: 70px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("und_abr","ges_unidades","id_und>0",$Und,"N","S");
?>
</select>


<div class="s1" style="left:728px; top: 210px; width: 75px;">
TOTAL PIEZAS</div>
<input name="TotPie"  type="text" id="TotPie"
class="rod" style="left:728px; top: 244px; width:62px;"
value="<?php echo $TotPie;?>" 
tabindex='<?php echo ++$TI;?>'/>

<div class="s1" style="left:796px; top: 210px; width: 88px;">
TOTAL UNIDADES (1)</div>
<input name="TotUni"  type="text" id="TotUni"
class="rod" style="left:799px; top: 244px; width: 82px;"
value="<?php echo $TotUni;?>" 
tabindex='<?php echo ++$TI;?>'/>

<div class="s1" style="left:890px; top: 210px; width: 95px;">
TOTAL UNIDADES (2)</div>
<input name="TotUwi"  type="text" id="TotUwi"
onKeyUp="cImporte();" class="ndd" style="left:890px; top: 244px; width: 82px;"
value="<?php echo $TotUwi;?>" 
tabindex='<?php echo ++$TI;?>'/>


<div class="s1" style="left: 980px; top: 223px; width: 59px;">PRECIO</div>
<input name="Pre"  type="text" id="Pre"
class="ndd" style="left: 980px; top: 244px; width: 65px;" 
value="<?php echo $Pre;?>" onKeyUp="cImporte();"
onfocus="selecciona_value(this);"
tabindex='<?php echo ++$TI;?>'/>


<div class="s1" style="left: 1056px; top: 223px; width: 54px;">IMPORTE</div>
<input name="Imp"  type="text" id="Imp"
class="rod" style="left: 1054px; top: 244px; width: 81px;"
value='<?php echo $Imp;?>'/>

<input name="CmdAdd" type="button" id="CmdAdd" 
value="+" style="position: absolute; left: 1142px; top: 242px; width: 33px; height: 25px;"
onClick="fAgregar();" 
tabindex="<?php echo ++$TI;?>"/>

<input name="CmdCls" type="button" id="CmdCls" 
value="X" style="position: absolute; left: 1181px; top: 242px; width: 32px; height: 25px;"
onClick="fCls();" 
tabindex="<?php echo ++$TI;?>"/>




<!--GRIDD-------------------------------->
<div class="tableFixHead" style="position: absolute; left: 36px; top: 277px; width: 1180px; height: 432px; overflow: auto; border:solid 1px #A9A9A9">
<table width="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:11px;" >
<thead>

<tr>
<th width="1%">#</th>
<th width="4%">CODIGO</th>
<th width="12%">DESCRIPCION</th>
<th width="8%">MEDIDAS</th>
<th width="4%" align="right">PIEZAS</th>
<th width="4%" align="right">CAJAS</th>
<th width="4%" >UNIDAD</th>
<th width="6%" align="right">TOT.PIEZAS</th>
<th width="8%" align="right">TOT.UNIDADES(1)</th>
<th width="8%" align="right">TOT.UNIDADES(2)</th>
<th width="4%" align="right">PRECIO</th>
<th width="5%" align="right">IMPORTE</th>
<th width="2%">&nbsp;</th>
<th width="2%">&nbsp;</th>
<th width="2%">&nbsp;</th>
<th width="26%">&nbsp;</th>
</tr>

</thead>
<tbody>
<script>
var DET_COD=new Array();
var DET_DES=new Array();
var DET_PIE=new Array();
var DET_CAJ=new Array();
var DET_MED=new Array();
</script>
<?php
	$TOT_CAJ=0;
	$DET_TOT=0;
	$ZX=0;
	$TOT=0;
	$s="SELECT * FROM vis_ges_invoice_det_t WHERE HW='$HW' ORDER BY CX";
	$rs=grs($s);
	while($r=$rs->fetch_assoc()){
		$TOT_CAJ=$TOT_CAJ+$r['CAJ'];
		$DET_TOT++;
		$ZX++;
		$CSS="";
		if($ZX%2==0)$CSS=' style="background-color:#CCC" ';
	?>
		<tr  >
		<!----------------------------------------------->
        <td style="border: 1px solid black;" ><?php echo $ZX;?></td>
		<td style="border: 1px solid black;" ><?php echo $r['COD'];?></td>
		<td style="border: 1px solid black;" ><?php echo $r['DES'];?></td>
        <td style="border: 1px solid black;" ><?php echo $r['MEDIDAS'];?></td>
        <td style="border: 1px solid black;" align="right"><?php echo $r['PIE'];?></td>
        <td style="border: 1px solid black;" align="right"><?php echo $r['CAJ'];?></td>
        <td style="border: 1px solid black;" ><?php echo $r['UND'];?></td>        
        <td style="border: 1px solid black;" align="right"><?php echo $r['TOT_PIE'];?></td>
        <td style="border: 1px solid black;" align="right"><?php echo $r['TOT_UNI'];?></td>
        <td style="border: 1px solid black;" align="right"><?php echo $r['TOT_UWI'];?></td>
		<td style="border: 1px solid black;" align="right"><?php echo $r['PRE'];?></td>
        <td style="border: 1px solid black;" align="right"><?php echo $r['IMP'];?></td>
		<!----------------------------------------------->
        <td style="border: 1px solid black;" align="center">
		<a href="javascript:void(0)" onClick="fE('<?php echo $r['CX'];?>');">
		<img src="img/b_edit.png"  border="0"/></a>
        </td>
        
        <td style="border: 1px solid black;" align="center">
		<a href="javascript:void(0)" onClick="fR('<?php echo $r['CX'];?>','<?php echo $r['ID_PRO'];?>','<?php echo $ZX; ?>');">
		<img src="img/ed.png"  border="0"/></a></td>
        
        
		<td style="border: 1px solid black;" align="center">
		<a href="javascript:void(0)" onClick="fK('<?php echo $r['CX'];?>');">
		<img src="img/eliminar.png"  border="0"/></a></td>        
        
        
        <td style="border: 1px solid black;padding:0 0 0 0" >
        <script>
		DET_COD[<?php echo $DET_TOT?>]="<?php echo $r['COD']?>";
		DET_DES[<?php echo $DET_TOT?>]="<?php echo $r['DES']?>";
		DET_PIE[<?php echo $DET_TOT?>]="<?php echo $r['PIE']?>";
		DET_CAJ[<?php echo $DET_TOT?>]="<?php echo $r['CAJ']?>";
		DET_MED[<?php echo $DET_TOT?>]="<?php echo $r['MEDIDAS']?>";
		</script>
        <div style="position:inherit; width:300px; top:0px; background-color:#CCC height:2rem; overflow:auto; padding:0 0 0 0" class="inner">
        <table style="font-size:10px; position:inherit; left:0px; top:0px;" border="0" cellpadding="0" cellspacing="0">         
        <tr>        
        <?php
		$DI=0;
		$z="SELECT FOB_USS,DUA,DUA_ITEM,OBS,LINK 
			FROM vis_ges_productos_referencias 
			WHERE ID_PRO=".$r['ID_PRO']." ORDER BY INV_FEC "; 
		$rz=grs($z);
		while($z=$rz->fetch_assoc()){
			$DI++;
			$CSS="tdx";
			if($DI%2==0)$CSS="tdy";
		?>
        
        	<td class="<?php echo $CSS;?>"><b>FobUSS</b></td>
            <td class="tdb"><?php echo $z['FOB_USS'];?></td>
            
            <td class="<?php echo $CSS;?>"><b>DUA</b></td>
            <td class="tdb"><?php echo $z['DUA'];?></td>

			<td class="<?php echo $CSS;?>"><b>ITEM</b></td>
            <td class="tdb"><?php echo $z['DUA_ITEM'];?></td>
            
            <td class="<?php echo $CSS;?>"><b>OBS</b></td>
            <td class="tdb"><?php echo $z['OBS'];?></td>
            
			<?php if(strlen($z['LINK'])>0){?>
            <td class="tdb"><a href="<?php echo $z['LINK'];?>" target="_new">IR</a></td>  
            <?php }?>
            <td width="2%">&nbsp;</td>
        <?php
        }
		?>
        </tr>
        </table>
        </div>
        </td>
		</tr>

        
        
	<?php
		$TOT=$TOT + $r['IMP'];
	}		
?>
</tbody>
</table>
</div>

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



<script>
	function O_Z1(){
		var hw=gv("HW");
		Ow('lq_com_xls_01.php?Z=1&HW='+hw,1020*ZO(),490*ZO());
	}
</script>

<input type="button" name="CmdXls1" id="CmdXls1" value="Importar desde excel" 
onClick="O_Z1()" style="position: absolute; left: 422px; top: 750px; width: 162px;"
/>

<div style="position: absolute; padding-top: 3px; left: 597px; top: 750px; width: 213px; background-color: #FFCC00; layer-background-color: #FFCC00; border: 1px none #000000; height: 20px; font-family:Tahoma, Geneva, sans-serif">
<a style="font-size:13px;" target="_blank" href="formato_items_invoice.xlsx">DESCARGAR PLANTILLA EXCEL</a>
</div>


<div style="position: absolute; padding-top: 3px; left:822px; top: 750px; width: 396px; background-color: #FFCC00; layer-background-color: #FFCC00; border: 1px none #000000; height: 20px;">
<a style="font-size:13px; font-family:Verdana, Geneva, sans-serif" target="_blank" href="aplicaciones/invoice_generar.zip" download="">DESCARGAR APLICACION</a>
</div>

<div style="position: absolute; padding-top: 3px; left:823px; top: 782px; width: 395px; background-color: #FFCC00; layer-background-color: #FFCC00; border: 1px none #000000; height: 20px;">
<a style="font-size:13px; font-family:Verdana, Geneva, sans-serif" target="_blank" href="aplicaciones/invoice_generar_measures.zip" download="">DESCARGAR APLICACION (Inc. measures)</a>
</div>

<div style="position: absolute; padding-top: 3px; left:823px; top: 809px; width: 395px; background-color: #FFCC00; layer-background-color: #FFCC00; border: 1px none #000000; height: 20px;">
<a style="font-size:13px; font-family:Verdana, Geneva, sans-serif" target="_blank" href="aplicaciones/Invoice24.zip" download="">VERSION DIC-24</a>
</div>


<div style="position: absolute; padding-top: 3px; left:823px; top: 837px; width: 395px; background-color: #FFCC00; layer-background-color: #FFCC00; border: 1px none #000000; height: 20px;">
<a style="font-size:13px; font-family:Verdana, Geneva, sans-serif" target="_blank" href="aplicaciones/Invoice25.zip" download="">VERSION ENE-25 (Partidas) <b>2026</b></a>
</div>

<div style="position: absolute; padding-top: 3px; left: 823px; top: 863px; width: 395px; background-color:#3C6; layer-background-color: #FFCC00; border: 1px none #000000; height: 20px;">
<a style="font-size:13px; font-family:Verdana, Geneva, sans-serif" target="_blank" href="aplicaciones/Invoice26.zip" download="">VERSION FEB-26(Seguro y CIF) <b>2026</b></a>
</div>



<div class="s1" style="left: 814px; top: 722px; width: 58px;">
<b>CTNS</b></div>

<input name="Cajas" type="text" id="Cajas" 
class="rod" style="left:876px; top: 719px; width: 97px; height:25px; border:none;"
value="<?php echo $TOT_CAJ;?>" />


<div class="s1" style="left: 1063px; top: 722px; width: 44px;">
<b>TOTAL</b></div>

<input name="Tot" type="text" id="Tot" 
class="rod" style="left: 1115px; top: 719px; width: 103px; height:25px; border:none;"
value="<?php echo NF2($TOT,2);?>" />

<div class="s1" style="left:60px; top: 751px; width: 66px;">
FLETE</div>
<div class="s1" style="left:142px; top:733px; width: 61px;">
PRICE</div>
<div class="s1" style="left:241px; top:733px; width: 72px;">
NUMBER</div>
<div class="s1" style="left:310px; top:733px; width: 71px;">
AMOUNT</div>

<?php
$SEL="";
$REO=" readonly ";
$BAC=" background-color:#CCC ";
if($CheFle==1){
	$SEL=" checked";
	$REO="";
	$BAC="";
}
?>
    <div class="s1" style="left:35px; top: 750px; width: 31px; ">
    <input name="CheFle" id="CheFle" onClick="CHE_CLI()" class="lt" 
    type="checkbox" <?php echo $SEL;?>  value="1" tabindex="<?php echo ++$TI;?>" >
    </div>

    <input name="PreFle"  type="text" id="PreFle" <?php echo $REO;?>
    class="ndd" style="left:142px; top: 751px; width:89px; <?php echo $BAC;?>" 
    value="<?php echo $PreFle;?>"  onKeyUp="kalcular()"
    tabindex="<?php echo ++$TI;?>"/>
    
    <input name="NumFle"  type="text" id="NumFle" <?php echo $REO;?>
    class="ndd" style="left:241px; top: 751px; width:57px; <?php echo $BAC;?>" 
    value="<?php echo $NumFle;?>" onKeyUp="kalcular()"
    tabindex="<?php echo ++$TI;?>"/>



    <input name="AmoFle"  type="text" id="AmoFle"
    class="rod" style="left:309px; top: 751px; width:93px" 
    value="<?php echo $AmoFle;?>" 
    tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left:60px; top: 785px; width: 83px;">
FOB NINGBO</div>
<input name="PreFob"  type="text" id="PreFob"
class="rod" style="left:142px; top: 785px; width:89px" 
value="<?php echo NF($TOT,2);?>" 
tabindex="<?php echo ++$TI;?>"/>

<?php if(strlen($NumFob)==0)$NumFob="1";?>
<input name="NumFob"  type="text" id="NumFob"
class="rod" style="left:241px; top: 785px; width:57px" 
value="<?php echo $NumFob;?>" 
tabindex="<?php echo ++$TI;?>"/>

<input name="AmoFob"  type="text" id="AmoFob"
class="rod" style="left:309px; top: 785px; width:93px" 
value="<?php echo NF($TOT,2);?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left:60px; top: 815px; width: 83px;">
CFR</div>

<input name="PreCfr"  type="text" id="PreCfr"
class="rod" style="left:142px; top: 815px; width:89px" 
value="<?php echo $PreCfr;?>" 
tabindex="<?php echo ++$TI;?>"/>

<?php if(strlen($NumCfr)==0)$NumCfr="1";?>
<input name="NumCfr"  type="text" id="NumCfr"
class="rod" style="left:241px; top: 815px; width:57px" 
value="<?php echo $NumCfr;?>" 
tabindex="<?php echo ++$TI;?>"/>

<input name="AmoCfr"  type="text" id="AmoCfr"
class="rod" style="left:309px; top: 815px; width:93px" 
value="<?php echo $AmoCfr;?>" 
tabindex="<?php echo ++$TI;?>"/>




<?php

$SEL="";
$REO=" readonly ";
$BAC=" background-color:#CCC ";
if($CheSeg==1){
	$SEL=" checked";
	$REO="";
	$BAC="";
}
?>
<div class="s1" style="left:35px; top: 850px; width: 31px;">
<input name="CheSeg" id="CheSeg" onClick="CHE_SEG()" class="lt"
type="checkbox" <?php echo $SEL;?>  value="1" tabindex="<?php echo ++$TI;?>" >
</div>

<div class="s1" style="left: 60px; top: 846px; width: 66px;"> SEGURO
</div>

<?php
	if($CheSeg==1){
		$PreSeg=$PreSeg;
	}else{
		$PreSeg="";
	}
?>
<input name="PreSeg"  type="text" id="PreSeg" <?php echo $REO;?>
class="ndd" style="left: 142px; top: 846px; width: 89px;<?php echo $BAC; ?>" 
value="<?php echo $PreSeg;?>"  onKeyUp="kalcular()"
tabindex="<?php echo ++$TI;?>"/>

<?php
	if($CheSeg==1){
		$NumSeg=$NumSeg;
	}else{
		$NumSeg="";
	}
?>

<input name="NumSeg"  type="text" id="NumSeg" <?php echo $REO;?>
class="ndd" style="left: 241px; top: 846px; width: 57px;<?php echo $BAC; ?>" 
value="<?php echo $NumSeg;?>" onKeyUp="kalcular()"
tabindex="<?php echo ++$TI;?>"/>


<input name="AmoSeg"  type="text" id="AmoSeg"
class="rod" style="left: 309px; top: 846px; width: 93px" 
value="<?php echo $AmoSeg;?>" 
tabindex="<?php echo ++$TI;?>"/>



<div class="s1" style="left: 60px; top: 880px; width: 83px;">
CFI</div>

<?php
	if($CheSeg==1){
		$PreCfi=$PreCfi;
	}else{
		$PreCfi="";
	}
?>
<input name="PreCfi"  type="text" id="PreCfi"
class="rod" style="left: 142px; top: 880px; width: 89px" 
value="<?php echo $PreCfi;?>" 
tabindex="<?php echo ++$TI;?>"/>

<?php
	if($CheSeg==1){
		$NumCfi="1";
	}else{
		$NumCfi="";
	}
?>

<input name="NumCfi"  type="text" id="NumCfi"
class="rod" style="left: 241px; top: 880px; width: 57px" 
value="<?php echo $NumCfi;?>" 
tabindex="<?php echo ++$TI;?>"/>

<?php
	if($CheSeg==1){
		$AmoCfi=$AmoCfi;
	}else{
		$AmoCfi="";
	}
?>
<input name="AmoCfi"  type="text" id="AmoCfi"
class="rod" style="left: 309px; top: 880px; width: 93px" 
value="<?php echo NF($AmoCfi,2);?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 35px; top: 940px; width: 90px;">
  PERIODO &gt;&gt;</div>
<select name="Per" id="Per"  onChange="PER_OC()"
class="lt" style="left: 35px; top: 958px; width: 104px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("per_nom","ges_periodos","id_per>0",$Per,"N","S");
?>
</select>

<div class="s1" style="left: 151px; top: 940px; width: 139px;">
PAYMENT TERMS</div>
<input name="Per1"  type="text" id="Per1"
class="lt" style="left: 149px; top: 958px; width: 147px" 
value="<?php echo $Per1;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 305px; top: 940px; width: 177px;">
Finish Time</div>
<input name="Per2"  type="text" id="Per2"
class="lt" style="left: 304px; top: 958px; width: 205px" 
value="<?php echo $Per2;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 518px; top: 940px; width: 117px;">
TOTAL AMOUNT</div>
<input name="TotAmo"  type="text" id="TotAmo"
class="rod" style="left: 518px; top: 958px; width: 120px" 
value="<?php echo $TotAmo;?>" 
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 650px; top: 940px; width: 149px;">
SAY TOTAL</div>
<input name="SayTot"  type="text" id="SayTot"
class="roi" style="left: 649px; top: 958px; width: 572px" 
value="<?php echo $SayTot;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 35px; top: 989px; width: 149px;">
<b>BANK INFORMATION</b></div>

<div class="s1" style="left: 35px; top: 1010px; width: 119px;">
EXPORT AGENT</div>
<input name="ExpAge"  type="text" id="ExpAge"
class="roi" style="left: 35px; top: 1028px; width: 145px" 
value="<?php echo $ExpAge;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 193px; top: 1010px; width: 162px;">
EXPORT AGENT ACCOUNT</div>
<input name="ExpAgeAcc"  type="text" id="ExpAgeAcc"
class="roi" style="left: 193px; top: 1028px; width: 182px" 
value="<?php echo $ExpAgeAcc;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 387px; top: 1010px; width: 164px;">
THE BANCK</div>
<input name="TheBan"  type="text" id="TheBan"
class="roi" style="left: 385px; top: 1028px; width: 244px" 
value="<?php echo $TheBan;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 639px; top: 1010px; width: 212px;">
ADDRESS</div>
<input name="Add"  type="text" id="Add"
class="roi" style="left: 639px; top: 1028px; width: 423px" 
value="<?php echo $Add;?>" 
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 1075px; top: 1010px; width: 133px;">
SWIFT CODE</div>
<input name="Swi"  type="text" id="Swi"
class="roi" style="left: 1074px; top: 1028px; width: 144px" 
value="<?php echo $Swi;?>" 
tabindex="<?php echo ++$TI;?>"/>


<!--BOTONES-------------------------------->
<div class="s1" style="left: 35px; top: 85px; width: 672px; height: 26px;">
<input name="CmdB" type="button" id="CmdG" class="btm"
onclick="fGuardar();" 
<?php
if(strlen($StrId)==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(strlen($StrId)==0){
	echo ' disabled="disabled" ';
}
?>
tabindex="<?php echo ++$TI;?>" />

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

<input name="CmdB" type="button" id="CmdB" class="btm" style="width:150px"
value="Buscar detallado" onClick="fBuscar('ges_invoice_bd.php');"  
tabindex="<?php echo ++$TI;?>" />


</div>
<!--BOTONES-------------------------------->





<style type="text/css">
.gr1{
	visibility: hidden; 
	overflow-x: hidden; 
	overflow-y: scroll; 
	color: #0FF; 
	background-color: #FFFFFF; 
	layer-background-color: #CCCCCC; 
	border: 1px none #000000;
}
.gr2{
	visibility:hidden; 	
	color: #0FF; 
	overflow-y: scroll; 
	background-color: #CCCCCC; 
	layer-background-color: #CCCCCC; 
	border: 1px none #000000;	
}
.gr3{
	padding-left:15px; 	
	background-color: #FFCC00; 
	layer-background-color: #FFCC00; 
	border: 1px none #000000;
	padding-top:2px;
	border-radius: 0.25rem;
	
}
</style>

<div id="TAB_AJAX" class="datagrid gr1" style="height: 202px; width: 1180px; position: absolute; left: 36px; top: 289px; display:none" align="left"></div>

<div id="TAB_CAPTION" class="datagrid gr2" style=" height:20px; width:1180px; position:absolute; left: 36px; top: 279px;; display:none" align="left">
    <table width="1080" border="1" cellpadding="0" cellspacing="0" bgcolor="#d4e3e5" >   
    <tr height="10 px">
    <td width="128" bgcolor="#CCCCCC">CODIGO</td>
    <td width="400" bgcolor="#CCCCCC">DESCRIPCION</td>
    <td width="100" bgcolor="#CCCCCC">MEDIDAS</td>
    <td width="55" bgcolor="#CCCCCC">UNIDAD</td>
    <td width="40" bgcolor="#CCCCCC">$ PRECIO</td>
    <td width="40" align="right" bgcolor="#CCCCCC">&nbsp;</td>
    </tr> 
    <div style=" position:inherit; top:0px; left:1114px">
    <input name="CmdClose" type="button" value="Cerrar" onClick="CerrarDIV();" style="background-color:#F90" />
    </div>
    </table>
  
</div>

<div class="s1 gr3" 
style="position: absolute; left: 237px; top: 198px; width: 126px; height:17px;">
<a target="_blank" href="ges_productos.php">NUEVO PRODUCTO</a></div>

<div class="s1" style="left:249px; top: 223px; width: 64px;"><i>UNIDAD :</i></div>
<div class="s1" id="DivUni" style="left:309px; top: 223px; width: 67px;"></div>

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

<input name="CmdUP" id="CmdUP" type="button" onClick="SM()" style="display:none">

<input name="HW" id="HW" type="hidden"  value="<?php echo $HW;?>">
<input name="PRO_ID" type="hidden" id="PRO_ID" value=""/>
<input name="PRO_COD" type="hidden" id="PRO_COD" value=""/>
<input name="PRO_DES" type="hidden" id="PRO_DES" value=""/>
<input name="PRO_PRE" type="hidden" id="PRO_PRE" value=""/>
<input name="PRO_KIL" type="hidden" id="PRO_KIL" value=""/>
<!--FIN_OCULTOS-------------------------------->
<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="PRV_ORI" type="hidden" id="PRV_ORI" value="<?php echo $PRV_ORI;?>"/>
<input name="PRV_NUM" type="hidden" id="PRV_NUM" value="<?php echo $PRV_NUM;?>"/>

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

<input name="ACC_INV_ELI" type="hidden" id="ACC_INV_ELI" value="<?php echo $ACC_INV_ELI;?>"/>
<input name="ACC_INV_EDI" type="hidden" id="ACC_INV_EDI" value="<?php echo $ACC_INV_EDI;?>"/>
</form>
</div>
</div>
</body>
</html>

