<?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_fac_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 factura</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:550px;width:980px;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("EmiRuc");
});

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;
		}
	}
  
});
/*
$JS=$JS."fxSel('".$r['id_xml']."','".$r['xml_ser']."','";
	$JS=$JS.$r['xml_num']."','".ParseFec($r['xml_fec'])."','";
	$JS=$JS.$r['xml_mnd']."','".$r['xml_emi_ruc']."','";
	$JS=$JS.$r['xml_emi_nom']."','".$r['xml_cli_ruc']."','";
	$JS=$JS.$r['xml_cli_nom']."','".$r['xml_tot']."')";
	
*/
function fxSel(id,ser,num,fec,mnd,xml_emi_ruc,xml_emi_nom,xml_cli_ruc,xml_cli_nom,xml_tot){
	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:#FAFCC7;" >
<form id="Frm" name="Frm" method="post" action="ges_costeo_sel_fac.php" 
autocomplete="off"
style="margin:0px; padding:0px; display:inline;" onSubmit="return false;">

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

<!----------------------------------------->
<div class="s1" style="left: 261px; top: 69px; width: 45px;">
<b>FACTURA</b>
</div>
<div class="s1" style="left: 35px; top: 85px; width: 98px;">
EMISOR RUC
</div>
<input name="EmiRuc" type="text" id="EmiRuc" 
class="lt" style="left: 35px; top: 102px; width: 87px;"
value="<?php echo $EmiRuc;?>"  maxlength="11"
tabindex="<?php echo ++$TI;?>"/>



<div class="s1" style="left: 133px; top: 85px; width: 118px;"> EMISOR NOMBRE
</div>
<input name="EmiNom" type="text" id="EmiNom" 
class="lt" style="left: 133px; top: 102px; width: 118px;"
value="<?php echo $EmiNom;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 261px; top: 85px; width: 44px;">
<b>SERIE</b></div>
<input name="FacSer" type="text" id="FacSer" 
class="lt" style="left: 261px; top: 102px; width: 71px;"
value="<?php echo $FacSer;?>"  
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 341px; top: 85px; width: 44px;">
<b>NUMERO</b></div>
<input name="FacNum" type="text" id="FacNum" 
class="lt" style="left: 341px; top: 102px; width: 71px;"
value="<?php echo $FacNum;?>"  
tabindex="<?php echo ++$TI;?>"/>


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

<div class="s1" style="left: 522px; top: 69px; width: 60px;">
HASTA</div>
<div class="s1" style="left: 521px; top: 85px; width: 69px;">
dd-mm-yy</div>
<input name="Hax" type="text" id="Hax" 
class="fe" style="left: 520px; top: 102px; width: 90px;" 
value="<?php echo $Hax;?>"  
tabindex="<?php echo ++$TI;?>"/>



<div class="s1" style="left: 618px; top: 85px; width: 118px;">
CLIENTE RUC
</div>
<input name="CliRuc" type="text" id="CliRuc" 
class="lt" style="left: 617px; top: 102px; width: 89px;"
value="<?php echo $CliRuc;?>"   maxlength="11"
tabindex="<?php echo ++$TI;?>"/>

<div class="s1" style="left: 713px; top: 85px; width: 118px;">
CLIENTE NOMBRE
</div>
<input name="CliNom" type="text" id="CliNom" 
class="lt" style="left: 713px; top: 102px; width: 119px;"
value="<?php echo $CliNom;?>"  
tabindex="<?php echo ++$TI;?>"/>


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


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


<div  style="position: absolute; top: 130px; left: 35px; height: 27px; background-color: #FAFCC7; width: 902px;">
<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: 164px; width: 900px; height: 351px; 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="2%" style="text-align:center; background:#999"">#</th>
<th width="6%" style="text-align:left; background:#999"">SERIE</th>
<th width="8%" style="text-align:left; background:#999"">NUMERO</th>
<th width="7%" style="text-align:left; background:#999"">FECHA</th>
<th width="12%" style="text-align:left; background:#999"">EMISOR RUC</th>
<th width="15%" style="text-align:left; background:#999"">EMISOR NOMBRE</th>
<th width="12%" style="text-align:left; background:#999"">CLIENTE RUC</th>
<th width="16%" style="text-align:left; background:#999"">CLIENTE NOMBRE </th>
<th width="14%" style="text-align:right; background:#999"">TOTAL</th>
<th width="2%" style="text-align:center; background:#999"">#</th>
</tr>
</thead>
<tbody>
<?php	
$TOT=0;	  		
$i=0;
$s="SELECT * FROM ges_xml WHERE ".$FF." ORDER BY xml_fec DESC ";
//echo $s."<br>";
$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" ';	
	//
	$JS="";
	$JS=$JS."fxSel('".$r['id_xml']."','".$r['xml_ser']."','";
	$JS=$JS.$r['xml_num']."','".ParseFec($r['xml_fec'])."','";
	$JS=$JS.$r['xml_mnd']."','".$r['xml_emi_ruc']."','";
	$JS=$JS.$r['xml_emi_nom']."','".$r['xml_cli_ruc']."','";
	$JS=$JS.$r['xml_cli_nom']."','".NF2($r['xml_tot'],2)."')";
?>	
	<tr <?php echo $CSS;?>  onDblClick="<?php echo $JS;?>">
	<!----------------------------------------------->
    <td align="center">
    <a href="javascript:void(0)"  onClick="<?php echo $JS;?>" >
    <img src="c.png"  border="0"/></a></td>
	<td style="white-space: nowrap;"><?php echo $r['xml_ser'];?></td>
	<td style="white-space: nowrap;"><?php echo $r['xml_num'];?></td> 
	<td style="white-space: nowrap;"><?php echo FEP($r['xml_fec']);?></td>
    <td style="white-space: nowrap;"><?php echo $r['xml_emi_ruc'];?></td>   
    <td style="white-space: nowrap;"><?php echo $r['xml_emi_nom'];?></td>   
    <td style="white-space: nowrap;"><?php echo $r['xml_cli_ruc'];?></td>    
    <td style="white-space: nowrap;"><?php echo $r['xml_cli_nom'];?></td>    
    <td style="white-space: nowrap;" align="right"><?php echo NF2($r['xml_tot'],2);?></td>    
	<!----------------------------------------------->
    <td align="center">
    <a href="javascript:void(0)" onClick="<?php echo $JS;?>" >
    <img src="c.png"  border="0"/></a></td>
	</tr>
<?php
}
?>		  
</tbody>
</table>
</div>
<!----------------------------------------->
<?php include("ocultos.php");?>
</form>





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