<?php
 
session_start();
include("DMMYSQLG.php");
include("DSA1000.php");
//require_once("JQUERY.inc");
include("DFJSISCI.inc");
include("DF80000.php");
include("JQUERY.inc");
include("datatables.inc");

?>
<?php

$path = "sync/rs/";

createTables($path);

function createTables($path,$r=1){
	if (@$gestor = opendir($path)) {
		while (false !== ($archivo = readdir($gestor))) {
			if ($archivo != "." && $archivo != "..") {
				$cont=file_get_contents($path.$archivo ,true); 
                 $p=explode("|", $cont);

				if ($p[0]=='0') continue;
				$fecf = chfecha($p[2],'d/m/Y','Y-m-d');
				if($p[3]=='A'){
					if(mysqli_query($con ,"update valeryus19 set fol_fac='$p[1]', fec_fac='$fecf' where n_reg='$p[4]'")) unlink($path.$archivo);
				}elseif($p[3]=='B'){
					if(mysqli_query($con ,"update gfdfgd set fol_fac='$p[1]', fec_fac='$fecf' where n_reg='$p[4]'")) unlink($path.$archivo);				
				}			
			}
			
		}
		closedir($gestor);
	}
}
?>
<html>
<head>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script type="text/javascript" src="//unpkg.com/xlsx/dist/shim.min.js"></script>
<script type="text/javascript" src="//unpkg.com/xlsx/dist/xlsx.full.min.js"></script>
<script type="text/javascript" src="//unpkg.com/blob.js@1.0.1/Blob.js"></script>
<script type="text/javascript" src="//unpkg.com/file-saver@1.3.3/FileSaver.js"></script>
<script>
	function doit(type, fn, dl) {
	var elt = document.getElementById('data-table');
	var wb = XLSX.utils.table_to_book(elt, {sheet:"Sheet JS"});
	return dl ?
		XLSX.write(wb, {bookType:type, bookSST:true, type: 'base64'}) :
		XLSX.writeFile(wb, fn || ('test.' + (type || 'xlsx')));
	}
</script>
<script language="javascript">
function checaDaatos(){
	busca();
}
</script>
<script language="javascript">
function fac_hotel(){
openWindow({
			action:"caj_checkout_MO.php",
			name:"Facturacion"
		},{
		     bot:getValRadChe('bot')
		});
}
/*$('#facturacion').click(function(){
		openWindow({
			action:"caj_checkout_MO.php",
			name:"Facturacion"
		},{
		 bot:getValRadChe('bot')
		});
	});

});
<!--input name="facturacion" type="button" class="bot_WsW" id="facturacion" value="Facturacion" onClick="fac_hotel();" /-->
*/
function busca(){
	getOnLayer({
			action:'caj_checkout_GRAL-SRV.php',
			idLayer:'regBus'
		},{
            tbus3:ge('tbus3').value,
            fec:ge('fec').value,
			fec2:ge('fec2').value
	});
}

</script>
<style type="text/css">
<!--
#Layer1 {
	position:absolute;
	width:1000px;
	height:180px;
	z-index:1;
	left: 93px;
	top: 240px;
}
</style>
<style>
#regBus{
	height : 400px;
	overflow : auto;
}
#frm1 {
    overflow: auto;
}
</style>
</head>
  
<body onload="">


<div align="center">
  <?php
  // hora actual
//echo date('h:i:s') . "\n";

// dormir durante 10 segundos


// ?despierta!
//echo date('h:i:s') . "\n";
  
  ?>
  
  <form name="form1" method="post" action="">
    <table width="458" border="0" align="center">
      <tr>
        <th colspan="2"><span class="Estilo1">CUENTA DE HUESPEDES</span></th>
      </tr>
      <tr>
        <th width="192"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /> FECHA </th>
        <th width="256"><div align="left">
          <span class="Estilo5"><strong>DEL</strong>
	      <input name="fec" type="text" class="emplea datefrom" id="fec" size="9" maxlength="20" value="<?=$fec?>"
			<?php

				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}else{
					echo 'value="'.date("d/m/Y").'"';
				}
			?> onkeypress="return soloNumeros(event)"
		/>
            <strong> AL </strong>
            </span>
	    <input name="fec2" type="text" class="emplea dateto" id="fec2" size="9" maxlength="20" 
			<?php

				if(isset($_POST['fec2'])){ //este es el truco
					echo 'value="' . $_POST['fec2'] .  '"';
				}else{
					echo 'value="'.date("d/m/Y").'"';
				}
			?>onkeypress="return soloNumeros(event)"
		/>
        </div></th>
      </tr>
       <tr>
        <th width="192"><img src="magnifier.png" alt="Buscar" onClick="alert('Buscar')" /> FOLIO </th>
        <th width="256"><div align="left">
          <input name="tbus3" id="tbus3" type="text" onBlur="may(this)" size="30"/>
        </div></th>
      </tr>
      <tr>
        <td colspan="2"><div align="center">
		<?php //<input name="Submit" type="submit" class="bot_WsW" value="Buscar" /> ?>
		 <input type="button" name="Submit" value="Buscar" class="bot_WsW" onClick="checaDaatos();"/>
        </div></td>
      </tr>
    </table>
  </form>
</div>
<div align="center">
<form name="frm1" id="frm1" method="post" action="">
<input name="vali" type="hidden" 
<?php
 
if (isset($_REQUEST['vali'])){
	echo ' value = "'.$_REQUEST['vali'].'"';
	$nr = $_REQUEST['vali'];
}else{
	echo ' value = "0"';
	$nr = 0;
}
$nr2 =  20;

?>
      
/>

<table width="1003" border='1'>
		<tr>
        <th colspan="11"> <div align="center">
			<p id="xportxlsx" class="xport"><input type="submit" value="Exportar a Excel" onclick="doit('xlsx');"></p>
		</div></th>
		</tr>
      <tr>
          <TD>
              <div id="regBus">
                  <table width="1050" border="0">
                    <tr>
                                <th nowrap><div align="center">FOLIO</div></th>       
                                <th nowrap><div align="center">ENTRADA</div></th>
                                <th nowrap><div align="center">SALIDA</div></th> 
                                <th width="50"  nowrap><div align="center">PAX</div></th>
                                <th width="50"  nowrap><div align="center">HAB</div></th>
                                <th width="50"  nowrap><div align="center">#VOUCHER O RECIBO</div></th>
                                <th width="50"  nowrap><div align="center">CONCEPTO</div></th>
                                <th width="50"  nowrap><div align="center">SUBTOTAL</div></th>
                                <th width="50"  nowrap><div align="center">IVA</div></th>
                                <th width="50"  nowrap><div align="center">3%</div></th>
								<th width="50"  nowrap><div align="center">NO GRAVABLE</div></th>
								<th width="50"  nowrap><div align="center">TOTAL</div></th>
								<?php
									$conceptos_abono = mysqli_query($con ,"select n_reg, descripcion from valeryus09 where pmontomax='ABONO' ORDER BY descripcion");
									$conceptos = array();
									echo mysqli_error($con);
									while($concepto = mysqli_fetch_array($conceptos_abono))
										$conceptos[] = array("n_reg" => $concepto['n_reg'], "descripcion" => $concepto['descripcion']);
									foreach($conceptos as $concepto)
										echo '<th width="50"  nowrap><div align="center">'.$concepto['descripcion'].'</div></th>';
								?>
								<th width="50"  nowrap><div align="center">TOTAL ABONOS</div></th>
                      </tr>
                  </table>
    </tr>
                  
              </div>  
              
          </TD>
      </tr>
    </table>
  </form>
</div>
</body>
</html>