<?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;}
//
include("ges_costeo_bx.php");
$IdUsu=0;
$AT=gs("at","usuarios","id_usuario=$IdUsu");
?>

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

.cF {height:600px;width:1250px;position:relative;top:0px}
.mM {height:34px;width:1250px;position:relative;top:0px;background-color:#09C; z-index:500;}

</style>

<!----------------------------------------->
<script>
$(document).ready(function(){  
   Inicializar();
   jF("Emp");
});

function fGenPDF(){
	var CboAlm=document.getElementById("CboAlm").value;
	if(CboAlm=="TODOS"){
		alert("Seleccione un Almacen");
		document.getElementById("CboAlm").focus();
		return;
	}
	document.getElementById("TxtAc").value="GEN_PDF";
	document.getElementById("Frm").submit();
}

$(document).keydown(function(e){
	var AT=gv("TxtAT");

	if(e.which==66 && e.altKey){
		if(AT=="1"){	
		document.getElementById("CmdB").click();
		return;
		}
	}

	if(e.which==86 && e.altKey){
		if(AT=="1"){
		document.getElementById("CmdZ").click();
		return;
		}
	}
  
});
</script>

<!----------------------------------------->
<script language="javascript">
$(document).ready(function() {
	$(".botonExcel").click(function(event) {
		$("#datos_a_enviar").val( $("<div>").append( $("#Exportar_a_Excel").eq(0).clone()).html());
		$("#FormularioExportacion").submit();
});
});
</script>
<!----------------------------------------->
<body  <?php echo $LStrMsg;?>  >
<div align="center">

<div class="mM" align="left" style="font-size:12px">
<?php
//$HTM=file_get_contents("http://inversionessounduniversal.com/ventas/phpmnu.php?USER_ID=$IdUsu");
echo GEN_MENU(vbval(V($_SESSION['SYS_USER_ID'])));
?>
</div>

<div Id="DivFRM"  class="cF" style="background-color:#FFFFFF;" >
<form id="Frm" name="Frm" method="post" action="ges_costeo_b.php" 
autocomplete="off"
style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">

<!----------------------------------------->
<div id="DivT" class="dT"  style="width:1250px;">
<img src="b.png" class="iT" />
<div class="tT">INVOICE COSTEO - BUSCAR</div>
</div>

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

<div class="s1" style="left: 35px; top: 121px; width: 102px;">
EMPRESA</div>
<select name="Emp" id="Emp" 
class="lt" style="left: 35px; top: 138px; width: 314px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("emp_nom_cor","ges_empresas","id_emp>0",$Emp,"S","N");
?>
</select>
<div class="s1" style="left: 363px; top: 105px; width: 45px;"> INVOICE
</div>
<div class="s1" style="left:363px; top: 121px; width: 45px;">
SERIE</div>
<input name="InvSer" type="text" id="InvSer" 
class="lt" style="left:363px; top: 138px; width: 69px;"
value="<?php echo $InvSer;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left:440px; top: 121px; width: 45px;">
NUMERO</div>
<input name="InvNum" type="text" id="InvNum" 
class="lt" style="left:440px; top: 138px; width: 69px;"
value="<?php echo $InvNum;?>"  
tabindex="<?php echo ++$TI;?>"/>


<div class="s1" style="left: 525px; top: 105px; width: 45px;">
DESDE</div>
<div class="s1" style="left: 525px; top: 121px; width: 69px;">
dd-mm-yy</div>
<input name="Dex" type="text" id="Dex" 
class="fe tcal" style="left: 524px; top: 138px; width:90px;"
value="<?php echo $Dex;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 624px; top: 105px; width: 60px;">
HASTA</div>
<div class="s1" style="left: 623px; top: 121px; width: 69px;">
dd-mm-yy</div>
<input name="Hax" type="text" id="Hax" 
class="fe" style="left: 622px; top: 138px; width: 90px;" 
value="<?php echo $Hax;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left:722px; top: 121px; width: 130px;"> PROVEEDOR
</div>
<select name="Prv" id="Prv" 
class="lt" style="left:722px; top: 138px; width: 190px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("prv_nom","ges_proveedores","id_prv>0",$Prv,"S","N");
?>
</select>


<div class="s1" style="left:927px; top: 121px; width: 140px;">PUERTO ORIGEN</div>
<select name="PunOri" id="PunOri" 
class="lt" style="left:927px; top: 138px; width: 127px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("pto_nom","ges_puertos","pto_tip='ORIGEN'",$PunOri,"S","N");
?>
</select>


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






<!----------------------------------------->
<div id="DivBtn" align="left" style="position:absolute; left: 33px; top: 71px; width: 551px; height: 26px;">
<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar" onClick="fFiltrar();"  
tabindex="<?php echo ++$TI;?>" />

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

<input name="CmdPDF" type="button" id="CmdPDF" class="btm" 
value="Generar PDF" onClick="fGenPDF();" style="display:none"
tabindex="<?php echo ++$TI;?>" />
</div>

<div  style="position:absolute; top:165px; left:35px; height:27px; background-color:#FFF; width: 1180px;">
<table width="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:11px" border="0">
<tr>
<td align="center">
	<?php echo PagBtn($LStrTR,$VP_RegXPag,$LStrPag);?>
</td>
</tr>
</table>
</div> 
    
<!----------------------------------------->
<div class="tableFixHead" style="position: absolute; left: 35px; top: 194px; width: 1180px; height: 380px; overflow:auto; border:solid 1px #363636">
<table id="Exportar_a_Excel" width="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:11px">
<thead>
<tr>
<th width="108" style="text-align:left; background:#999">EMPRESA</th>


<th width="50"  style="text-align:left; background:#999"">I.SERIE</th>
<th width="66"  style="text-align:left; background:#999"">I.NUMERO</th>
<th width="99" style="text-align:left; background:#999"">FECHA</th>
<th width="386" style="text-align:left; background:#999"">PROVEEDOR</th>
<th width="162" style="text-align:left; background:#999"">P.ORIGEN</th>
<th width="141" style="text-align:left; background:#999"">P.DESTINO</th>
<th width="38" style="text-align:right; background:#999"">CTNS</th>
<th width="58" style="text-align:right; background:#999"">TOTAL</th>
<th width="26" style="text-align:center; background:#999"">&gt;</th>
</tr>
</thead>
<tbody>
<?php	
$ST=0;
$TOT_CTNS=0;	  		
$i=0;
$s="SELECT * FROM vis_ges_xml_costeo_inv WHERE ".$FF." ORDER BY FEC DESC,INV_NUM DESC";
$s=PagSql($s,$LStrPag,$VP_RegXPag,$LStrTR);
$rs=grs($s);				
while($r=$rs->fetch_assoc()){
	$i++;
	$CSS="";
	if($i%2==0)$CSS=' style="background-color:#E2E2E2" ';
	$CTNS=gn("SUM(dt_caj)","ges_invoice_det","det_id_inv=".$r['ID']);
	$TOT_CTNS=$TOT_CTNS+ $CTNS;
	$ST=$ST + $r['TOT'];
?>	
	<tr onDblClick="location.href='ges_costeo.php?Id=<?php echo $r['ID'];?>&Pag=0'" <?php echo $CSS;?>>
	<!----------------------------------------------->
	<td><?php echo $r['EMP_NC'];?></td>  
	<td><?php echo $r['INV_SER'];?></td>
	<td><?php echo $r['INV_NUM'];?></td> 
	<td><?php echo $r['FEC_'];?></td>
    <td><?php echo $r['PROVEEDOR'];?></td>   
    <td><?php echo $r['PTO_ORI'];?></td>   
    <td><?php echo $r['PTO_DES'];?></td>    
    <td align="right"><?php echo $CTNS;?></td>    
    <td align="right"><?php echo NF2($r['TOT'],2);?></td>    
	<!----------------------------------------------->
    <td align="center">
    <a href="ges_costeo.php?Id=<?php echo $r['ID'];?>&Pag=0" target="_blank" >
    <img src="open.png"  border="0"/></a></td>
	</tr>
<?php
}
?>		  
</tbody>
</table>
</div>
<!----------------------------------------->
<?php include("ocultos.php");?>
</form>





</div>
</div>
</body>
</html>
