<?php
session_start();
include("DMMYSQLG.php"); //base de datos
include("DSA1000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include ("varfun.php");
include("JQUERY.inc");
$f_m = "";

//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);

date_default_timezone_set ( 'America/Mexico_City' ) ;
?>

<html>
    <HEAD> <meta name="tipo_contenido" content="text/html;" http-equiv="content-type" charset="utf-8">
    </HEAD>
    <link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
    <script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
        <body>
        <div align="center">
            <form name="frm1" id="frm1" method="post" action="" autocomplete='off'>
                <table width="441" border="0">
                    <tr>
                        <th colspan="2"><span class="Estilo23">REPORTE DE CAMBIOS DE HABITACION</span></th>
                    </tr>
                    <tr>

                        <td align="center">
                            <strong>Folio:</strong>

                            <input name="val" type="text" class="emplea" id="val" size="9" maxlength="20" value="<?= $_POST['val'] ?>" />

                    </tr>
                    <tr>

                        <td align="center">
                            <strong>Habitaci&oacuten:</strong>
                            <input name="hab" type="text"   class="emplea" id="hab" size="9" maxlength="20" value="<?= $_POST['hab'] ?>"/>
                    </tr>
                    <tr>
                        <td align="center">
                            <strong> Fecha: </strong>

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

                        </td>
                    </tr>



                    <tr>
                        <td colspan="2">
                            <div align="center">
                                <a style="text-decoration:underline;cursor:pointer;" href="menu_PR.php"/></a>
                                <input name="Submit" type="button" class="original" onClick="openpage('ger_cambios_PR.php', '_self')" value="Buscar"/>
                            </div></td>  </tr>  
                </table>  </form> </div>
        <div align="center">
            <form method="post" action="" >
                <?php
                $fol = $_POST['val'];
                
                if (isset($fol) && $fol != '')
//                    @$result = mysqli_query($con ,"SELECT 'uno' as origin, valeryus19.*,'actual' as fec_mod FROM valeryus19  where n_reg like '$fol'
//union all select * from valeryus19_his where n_reg like '$fol'  order by fec_mod desc");
                
                    @$result = mysqli_query($con ,"SELECT 'uno' as origin, valeryus19.n_reg,valeryus19.fnumcto,valeryus19.fmuncto,valeryus19.ffecllegada,
ffecsalida,fnorasvip,
'actual' as fec_mod FROM valeryus19  
where n_reg LIKE '$fol'
union all select 'dos' AS origin,valeryus19_his.* from valeryus19_his where n_reg LIKE '$fol' order by fec_mod desc ");
                
                
                echo mysqli_error($con);
                ?>
                <?php       
                $h = $_POST['hab'];
                if (isset($h) && $h != '')
//                    @$result = mysqli_query($con ,"SELECT 'uno' as origin, valeryus19.*,'actual' as fec_mod FROM valeryus19  where fnumcto like '$h'
//union all select * from valeryus19_his where fnumcto like '$h' order by  n_reg desc");
//                @$result = mysqli_query($con ,"SELECT 'uno' as origin, valeryus19.*,'actual' as fec_mod FROM valeryus19  
//WHERE  n_reg IN (SELECT n_reg FROM valeryus19_his WHERE fnumcto ='$h')
//union all select * from valeryus19_his WHERE fnumcto ='$h'  ORDER BY n_reg desc ");
                    
                     @$result = mysqli_query($con ,"SELECT 'uno' as origin, valeryus19.n_reg,valeryus19.fnumcto,valeryus19.fmuncto,valeryus19.ffecllegada,
ffecsalida,fnorasvip,
'actual' as fec_mod FROM valeryus19  
WHERE  n_reg IN (SELECT n_reg FROM valeryus19_his WHERE fnumcto ='$h')
union all SELECT 'dos' AS origin, valeryus19_his.* from valeryus19_his WHERE fnumcto ='$h'  ORDER BY n_reg ");
                
                echo mysqli_error($con);
                ?> 
                
                <?php
               $f = $_POST['fec'];
               //echo $f ."<br />";
               $date = str_replace('/', '-', $f);
               $fec =  date('Y-m-d', strtotime($date));
               
               //echo $fec;             
                
                
                if (isset($f) && $f != '') 
                    @$result = mysqli_query ("SELECT 'uno' as origin, valeryus19.n_reg,valeryus19.fnumcto,valeryus19.fmuncto,valeryus19.ffecllegada,
ffecsalida,fnorasvip,
'actual' as fec_mod FROM valeryus19  
INNER JOIN  (SELECT n_reg FROM valeryus19_his WHERE DATE(fec_mod)='$fec') AS his
ON valeryus19.n_reg= his.n_reg
union all select 'dos' AS origin, valeryus19_his.* from valeryus19_his WHERE DATE(fec_mod)='$fec'  ORDER BY n_reg DESC");
                
                /*echo "SELECT 'uno' as origin, valeryus19.n_reg,valeryus19.fnumcto,valeryus19.fmuncto,valeryus19.ffecllegada,
ffecsalida,fnorasvip,
'actual' as fec_mod FROM valeryus19  
INNER JOIN  (SELECT n_reg FROM valeryus19_his WHERE DATE(fec_mod)='$fec') AS his
ON valeryus19.n_reg= his.n_reg
union all select 'dos' AS origin, valeryus19_his.* from valeryus19_his WHERE DATE(fec_mod)='$fec'  ORDER BY n_reg DESC";*/  
                
                ?> 


                <table width="79%"   align="center" bordercolor=" " bordercolordark=" ">
                    <tr><th colspan="15"><span class="Estilo23">
                            </span></th></tr>
                    <tr>
                        <th width="8%"><div align="center">FOLIO</div></th>
                        <th width="7%"><div align="center">HAB ANTERIOR</div></th>
                        <th width="7%"><div align="center">HAB ACTUAL</div></th>
                        <th width="9%"><div align="center">TIPO</div></th>
                        <th width="13%"><div align="center">HUESPED</div></th>

                        <th width="8%"><div align="center">STATUS</div></th>
                        <th width="13%"><div align="center">FECHA DE LLEGADA</div></th>
                        <th width="12%"><div align="center">FECHA DE SALIDA</div></th>
                        <th width="38%"><div align="center">NOTAS</div></th>	
                        <th width="38%"><div align="center">LIMITE CREDITO</div></th>
                        <th width="38%"><div align="center">TARIFA</div></th>
                        <th width="38%"><div align="center">USUARIO</div></th>	
                        <th width="38%"><div align="center">MODIFICACI&Oacute;N</div></th>				
                        <th width="38%"><div align="center">MOSTRAR TODO</div></th>				
                    </tr>
                    <?php
                    $i = 0;
                    while ($reg = mysqli_fetch_array($result)) {
                        echo ($reg["origin"] != 'uno') ? "<tr >" : "<tr style='background: aquamarine;'>";
                        echo "<td> <div align='center'><strong>" . $reg["n_reg"] . "&nbsp;</strong></div></td>";
                        $fol = ($reg["origin"] == 'uno') ? $reg["n_reg"] : $reg["origin"];
                        $ty = ($reg["origin"] == 'uno') ? 'mod' : 'his';
                        echo "<td> <div align='center'><strong>" . $reg["cuarto_seguro"] . "&nbsp;</strong></div></td>";
                        if ($reg["fnumcto"] == '') {
                            echo "<td> <div align='center'><strong>" . $reg["fmuncto"] . "&nbsp;</strong></div></td>";
                        } else {
                            echo "<td> <div align='center'><strong>" . $reg["fnumcto"] . "&nbsp;</strong></div></td>";
                        }
                        echo "<td> <div align='center'><strong>" . $reg["ftipocto"] . "&nbsp;</strong></div></td>";
                        echo "<td> <div align='left'><strong> &nbsp;" . $reg["fapellido"] . ' ' . $reg["fnombre"] . "&nbsp;</strong></div></td>";

                        echo "<td> <div align='center'><strong>" . $reg["status"] . "&nbsp;</strong></div></td>";
                        $fec1 = $reg["ffecllegada"];
                        include('DF20000.php');
                        echo "<td> <div align='center'><strong>" . $f_f . "&nbsp</strong></div></td>";
                        $fec1 = $reg["ffecsalida"];
                        include('DF20000.php');
                        echo "<td> <div align='center'><strong>" . $f_f . "&nbsp</strong></div></td>";
                        echo "<td> <div align='left'><strong>&nbsp;" . $reg["fnorasvip"] . "&nbsp;</strong></div></td>";
                        echo "<td> <div align='left'><strong>&nbsp;" . $reg["flimite"] . "&nbsp;</strong></div></td>";
                        echo "<td> <div align='left'><strong>&nbsp;" . $reg["tex4"] . "&nbsp;</strong></div></td>";
                        echo "<td> <div align='left'><strong>&nbsp;" . $reg["fusucamb"] . "&nbsp;</strong></div></td>";

                        echo "<td> <div align='left'><strong>&nbsp;" . $reg["fec_mod"] . "&nbsp;</strong></div></td>";
                        echo "<td> <input name='send' type='button' class='original' onClick=\"openpage('res_registro_ACEX.php?bot=$fol&type=$ty','_self')\" value='Mostrar'/> </td></tr>";
                        $i++;
                    }
                    echo "<tr><th colspan='10'><div align='right' style=' '><strong>TOTAL DE CAMBIOS :</strong></div></th>
				  <th colspan='3'><div align=\"left\" style=' '><strong>" . $i . "</strong></div></th></tr>";
                    mysqli_close($con);
                    ?>
                </table> </form>  </div>  </body>  </html>
<?php //252 --> 168  ULTIMA ACTUALIZACION 12/ENERO/2012 REPORTE DE CAMBIO DE HABITACION    ?>
<?php //252 --> 168  ULTIMA ACTUALIZACION Agosto 2020  busqueda por habitacion y fecha    ?>
<?php //252 --> 168  ULTIMA ACTUALIZACION Diciembre 2020  busqueda por habitacion y folio (modificacion alas consultas )    ?>