<?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_sel_inv_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>Seleccionar Invoice</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:1120px;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;
		}
	}
  
});
//
/*
$FUN="";
	$FUN=$FUN."jsSel('".$r['ID']."','".$r['EMP_NC']."','";
	$FUN=$FUN.$r['PRO_SER']."','".$r['PRO_NUN']."','".$r['INV_SER']."','";
	$FUN=$FUN.$r['INV_NUM']."','".$r['FEC_']."','".$r['PROVEEDOR']."','";
	$FUN=$FUN.$r['PTO_ORI']."','".$r['PTO_DES']."')";
	
*/

function jsSel( id , emp_nc , pro_ser , pro_num , 
				inv_ser , inv_num , fec , prov , pto_ori , pto_des ){
	
	window.opener.document.getElementById("FAC_KOD").value=id;
	window.opener.document.getElementById("Pro").value=emp_nc;
	window.opener.document.getElementById("ProSer").value=pro_ser;
	window.opener.document.getElementById("ProNro").value=pro_num;
	window.opener.document.getElementById("InvSer").value=inv_ser;
	window.opener.document.getElementById("InvNro").value=inv_num;
	window.opener.document.getElementById("Fec").value=fec;
	window.opener.document.getElementById("EmpTo").value=prov;
	window.opener.document.getElementById("PueOri").value=pto_ori;
	window.opener.document.getElementById("PueDes").value=pto_des;
	window.close();
	/*
	window.opener.document.getElementById("FAC_KOD").value=id;
	window.opener.document.getElementById("Ser").value=ser;
	window.opener.document.getElementById("Num").value=num;
	window.opener.document.getElementById("Fec").value=fec;
	window.opener.document.getElementById("Mnd").value=mnd;
	window.opener.document.getElementById("EmiRuc").value=xml_emi_ruc;
	window.opener.document.getElementById("EmiNom").value=xml_emi_nom;	
	window.opener.document.getElementById("CliRuc").value=xml_cli_ruc;
	window.opener.document.getElementById("CliNom").value=xml_cli_nom;
	window.opener.document.getElementById("Tot").value=xml_tot;	
	window.close();
	*/
}
</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 Id="DivFRM"  class="cF" style="background-color:#FEFACB;" >
<form id="Frm" name="Frm" method="post" action="ges_costeo_sel_inv.php" 
autocomplete="off"
style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">

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

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

<div class="s1" style="left: 34px; top: 90px; width: 102px;">
EMPRESA</div>
<select name="Emp" id="Emp" 
class="lt" style="left: 34px; top: 107px; width: 134px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("emp_nom_cor","ges_empresas","id_emp>0",$Emp,"S","N");
?>
</select>
<div class="s1" style="left: 178px; top: 75px; width: 45px;"> INVOICE
</div>
<div class="s1" style="left: 178px; top: 91px; width: 45px;">
SERIE</div>
<input name="InvSer" type="text" id="InvSer" 
class="lt" style="left: 178px; top: 108px; width: 69px;"
value="<?php echo $InvSer;?>"  
tabindex="<?php echo ++$TI;?>"/>

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


<div class="s1" style="left: 340px; top: 75px; width: 45px;">
DESDE</div>
<div class="s1" style="left: 340px; top: 91px; width: 69px;">
dd-mm-yy</div>
<input name="Dex" type="text" id="Dex" 
class="fe tcal" style="left: 339px; top: 108px; width: 90px;"
value="<?php echo $Dex;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 439px; top: 75px; width: 60px;">
HASTA</div>
<div class="s1" style="left: 438px; top: 91px; width: 69px;">
dd-mm-yy</div>
<input name="Hax" type="text" id="Hax" 
class="fe" style="left: 437px; top: 108px; width: 90px;" 
value="<?php echo $Hax;?>"  
tabindex="<?php echo ++$TI;?>"/>

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


<div class="s1" style="left: 689px; top: 91px; width: 140px;">PUERTO ORIGEN</div>
<select name="PunOri" id="PunOri" 
class="lt" style="left: 689px; top: 108px; 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: 834px; top: 91px; width: 140px;">PUERTO DESTINO</div>
<select name="PunDes" id="PunDes" 
class="lt" style="left: 834px; top: 108px; width: 137px" 
tabindex="<?php echo ++$TI;?>">
<?php 
	echo FCBO("pto_nom","ges_puertos","pto_tip='DESTINO'",$PunDes,"S","N");
?>
</select>


<input name="CmdB" type="button" id="CmdB" class="btm"
value="Buscar" onClick="fFiltrar();"   style="position: absolute; top: 107px; left: 980px"
tabindex="<?php echo ++$TI;?>" />






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

<div  style="position: absolute; top: 142px; left: 35px; height: 27px; background-color: #FEFACB; width: 1039px;">
  <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: 176px; width: 1042px; height: 391px; overflow: auto; border: solid 1px #363636; background-color: #FFF">
<table id="Exportar_a_Excel" width="100%" style="font-family:Arial, Helvetica, sans-serif; font-size:11px">
<thead>
<tr>
<th width="26" style="text-align:center; background:#999"">#</th>
<th width="79" style="text-align:left; background:#999">EMPRESA</th>
<th width="52"  style="text-align:left; background:#999"">I.SERIE</th>
<th width="68"  style="text-align:left; background:#999"">I.NUMERO</th>
<th width="73" style="text-align:left; background:#999"">FECHA</th>
<th width="437" 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"">#</th>
</tr>
</thead>
<tbody>
<?php	
$ST=0;
$TOT_CTNS=0;	  		
$i=0;
$s="SELECT * FROM vis_ges_invoice 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="";	
	//
	$FUN="";
	$FUN=$FUN."jsSel('".$r['ID']."','".$r['PROVEEDOR']."','";
	$FUN=$FUN.$r['PRO_SER']."','".$r['PRO_NUN']."','".$r['INV_SER']."','";
	$FUN=$FUN.$r['INV_NUM']."','".$r['FEC_']."','".$r['EMP_NC']."','";
	$FUN=$FUN.$r['PTO_ORI']."','".$r['PTO_DES']."')";
	//
	$COS=gn("count(*)","ges_xml_costeo","id_fac=".$r['ID']);
	if($COS>0){
		if($i%2==0){
			$CSS=' style="background-color:#E2E2E2;font-style: italic; font-weight: bold " ';
		}else{
			$CSS=' style="font-style: italic;font-weight: bold " ';
		}
	}else{
		if($i%2==0)	$CSS=' style="background-color:#E2E2E2;" ';
	}
?>	
	<tr onDblClick="<?php echo $FUN;?>" <?php echo $CSS;?>>
	<!----------------------------------------------->
    <td align="center">
    <a href="javascript:void(0)" onClick="<?php echo $FUN;?>">
    <img src="c.png"  border="0"/></a></td>
	<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="javascript:void(0)" onClick="<?php echo $FUN;?>">
    <img src="c.png"  border="0"/></a></td>
	</tr>
<?php
}
?>		  
</tbody>
</table>
</div>


<div class="s1" style="left: 34px; top: 572px; width: 500px;">
Los registro en <b><i>NEGRITA Y CURSIVA</i></b> ya tiene registrado su costeo</div>
<!----------------------------------------->
<?php include("ocultos.php");?>
</form>





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