
<?php
session_start();
$com = "M";
include("DSA3000.php");
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
include ("varfun.php");
include("DFJQUERY.inc");
include("JQUERY.inc");

$bot = (isset($_POST["bot"])) ? $_POST["bot"] : $_GET['bot'];
$Segundos = 0;
$cuenta = 0;
$val2 = 0;
$val1 = 0;
$f_f = "";
//include("DIF_FECHAS.php");
?>
<html>
    <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" language="JavaScript1.2" src="RSSCRIPT.js"></script>

    <script language="javascript">

        function restaTex() {
            var objTex1 = document.getElementById('tex4'),
                    objTex2 = document.getElementById('tex5'),
                    objTex3 = document.getElementById('tex6');
            objTex3.value = (parseFloat(objTex1.value) * parseFloat(objTex2.value)).toFixed(2);
        }
		
		function checapass(cb) {
			 var res = prompt("Contraseña de Reservas", "esta opcion esta protegida");
				
				console.log(res);
				
				if (res===null){ 
					console.log(document.getElementById(cb).checked);
					document.getElementById(cb).checked = !document.getElementById(cb).checked;
					return false;
				}
				else if (res=='Reservas2021'){
					console.log(document.getElementById(cb).checked);
                                        if(document.getElementById(cb).checked){
                                            $("#buscarHabitaion").hide();
                                            bloquearCampos(1);
                                        }else{
                                            $("#buscarHabitaion").show();
                                            desbloquearCampos(); 
                                        }
                                        
				}
				else{
					document.getElementById(cb).checked = !document.getElementById(cb).checked;
				}
		}	
				
				
		function bloquearCampos(activo) {
                    if(noMover.includes("1") || activo == 1){
                        //$("#ffecllegada,#ffecsalida,#fnummenor,#ftipocto,#fnorasvip").attr('readonly', true);
                        setTimeout(() => {
                            $("#buscarHabitaion").hide();
                            let arrId = ['btnModificar' , 'btnRegresar' , 'tipo'];
                            let tagInput = document.getElementById('tableReservas').getElementsByTagName('INPUT');
                            let tagSelect = document.getElementById('tableReservas').getElementsByTagName('select');
                            let tagTextarea = document.getElementById('tableReservas').getElementsByTagName('textarea');
                            for(var i = 0 ; i < tagInput.length; i++){
                                if(!arrId.includes(tagInput[i].id)){
                                    tagInput[i].disabled = true;
                                }
                            }
                            for(var i = 0 ; i < tagSelect.length; i++){
                                tagSelect[i].disabled = true;
                            }
                            for(var i = 0 ; i < tagTextarea.length; i++){
                                tagTextarea[i].disabled = true;
                            }
                        },500);
                           
                    }
                }
                
                function desbloquearCampos(){
                            $("#buscarHabitaion").show();
                            let body2Inputs = document.getElementById('tableReservas').getElementsByTagName('INPUT');
                            let tagSelect = document.getElementById('tableReservas').getElementsByTagName('select');
                            let tagTextarea = document.getElementById('tableReservas').getElementsByTagName('textarea');
                            for(var i = 0 ; i < body2Inputs.length; i++){
                                body2Inputs[i].disabled = false;
                            }
                            for(var i = 0 ; i < tagSelect.length; i++){
                                tagSelect[i].disabled = false;
                            }
                            for(var i = 0 ; i < tagTextarea.length; i++){
                                tagTextarea[i].disabled = false;
                            }
                }
				
            
    </script>
    <script language="javascript">
        function restaFecha()
        {
            var d1 = $('#ffecllegada').val().split("/");
            var dat1 = new Date(d1[2], parseFloat(d1[1]) - 1, parseFloat(d1[0]));
    //console.log(dat1);
            var d2 = $('#ffecsalida').val().split("/");
            var dat2 = new Date(d2[2], parseFloat(d2[1]) - 1, parseFloat(d2[0]));
    //    //var dif = fFecha2 - fFecha1;
            var fin = dat2.getTime() - dat1.getTime();
            var dias = Math.floor(fin / (1000 * 60 * 60 * 24));
    //   //return dias
            $("#fnumctos,#fnumadu").val(dias);
            $("#tex5").val(dias);
        }

    </script>

    <?php
    if (isset($_POST["fnumctos"]) && $_POST["fnumctos"] == "") {
        "<script languaje=\"javascript\"> javascript:document.getElementById('frm1').submit();</script>";
    }
//if (isset($bot)&&$bot==""){
//$_REQUEST['bot']=$bot;
//$bot=$bot;
//}else{
//$_REQUEST['bot']=$_REQUEST['bot'];
//$bot=(isset($bot))?$bot:"";
//}

    if (isset($bot) && $bot == "") {
        echo '<h2>!!! SELECCIONE UN REGISTRO !!!</h2>';
        echo '<meta content="1; url=res_cancelacion_PR.php"  HTTP-EQUIV="REFRESH">';
    } else {
        if ($_GET['type'] == 'his') {
            $disabled = 'style="display:none"';
            require_once('res_historico_CL.php'); //rec_chin_CL.php
            $varible_clase = new clase();
            $varb = (isset($bot)) ? $bot : $bot;
            $res = $varible_clase->lista_busqueda($varb);
        } else {
            $disabled = '';
            require_once('res_registro_CL.php'); //rec_chin_CL.php

            $varible_clase = new clase();
            $varb = (isset($bot)) ? $bot : $bot;
            $res = $varible_clase->lista_busqueda($varb);
        }
		
		
  
	  
  
		
        $reg = mysqli_fetch_array($res);
        if (!isset($_POST['fnombre'])) {
            $_REQUEST['fcodtarifa'] = $reg['fcodtarifa'];
            $_REQUEST['fnumres'] = $reg['fnumres'];
            $_REQUEST['fnumcto'] = $reg['fnumcto'];
            $_REQUEST['fmuncto'] = $reg['fmuncto'];
            $_REQUEST['ffecllegada'] = chfecha($reg['ffecllegada'], 'Y-m-d', 'd/m/Y');
            $_REQUEST['ffecsalida'] = chfecha($reg['ffecsalida'], 'Y-m-d', 'd/m/Y');
            $_REQUEST['fnumadu'] = $reg['fnumadu'];
            $_REQUEST['fnummenor'] = $reg['fnummenor'];
            $_REQUEST['fhorallega'] = $reg['fhorallega'];
            $_REQUEST['fnumctos'] = $reg['fnumctos'];
            $_REQUEST['ffecalt'] = chfecha($reg['ffecalt'], 'Y-m-d', 'd/m/Y');
            $_REQUEST['ftipocto'] = $reg['ftipocto'];
            $_REQUEST['select1'] = $reg['status'];
            $_REQUEST['fusualta'] = $reg['fusualta'];

            //forma de pago
            $_REQUEST['fformpago'] = $reg['fformpago'];
            $_REQUEST['fnumtar'] = $reg['fnumtar'];
            $_REQUEST['fsaldo'] = $reg['fsaldo'];
            $_REQUEST['flimite'] = $reg['flimite'];
            $_REQUEST['fcodseg'] = $reg['fcodseg'];
            $_REQUEST['codseg'] = $reg['codseg'];
            //datos
            $_REQUEST['fcodgrupo'] = $reg['fcodgrupo'];
            $_REQUEST['fcodagen'] = $reg['fcodagen'];
            $_REQUEST['fcodmeca'] = $reg['fcodmeca'];
            $_REQUEST['fplan'] = $reg['fplan'];
            $_REQUEST['smerf'] = $reg['smerf'];
            $_REQUEST['fnorasvip'] = $reg['fnorasvip'];
            $_REQUEST['extra4'] = $reg['extra4'];
            //direccion
            $_REQUEST['fnombre'] = $reg['fnombre'];
            $_REQUEST['fapellido'] = $reg['fapellido'];
            $_REQUEST['flengua'] = $reg['flengua'];
            $_REQUEST['fempresa'] = $reg['fempresa'];
            $_REQUEST['ftelefono'] = $reg['ftelefono'];
            $_REQUEST['fvip'] = $reg['fvip'];
			 $_REQUEST['tipo'] = $reg['tipo'];
            $_REQUEST['femail'] = $reg['femail'];
            $_REQUEST['fmail'] = $reg['fmail'];
            $_REQUEST['fdireccion'] = $reg['fdireccion'];
            $_REQUEST['tcol'] = $reg['fgntd'];
            $_REQUEST['tcp'] = $reg['fcp'];
            $_REQUEST['pais'] = $reg['fpais'];
            $_REQUEST['estados'] = $reg['festado'];
            $_REQUEST['tmun'] = $reg['fciudad'];
            $_REQUEST['fvehiculo'] = $reg['fvehiculo'];
            $_REQUEST['fplacas'] = $reg['fplacas'];
            $_REQUEST['ftelemp'] = $reg['ftelemp'];
            $_REQUEST['ftiphuesped'] = $reg['ftiphuesped'];
            $_REQUEST['cuarto_seguro'] = $reg['cuarto_seguro'];
            $_REQUEST['tex'] = $reg['tex'];
            $_REQUEST['tex2'] = $reg['tex2'];
            $_REQUEST['tex3'] = $reg['tex3'];
            $_REQUEST['tex4'] = $reg['tex4'];
            $_REQUEST['tex5'] = $reg['tex5'];
            $_REQUEST['tex6'] = $reg['tex6'];
            $_REQUEST['text1'] = $reg['text1'];
            $_REQUEST['text2'] = $reg['text2'];
            $_REQUEST['text3'] = $reg['text3'];
            $_REQUEST['text4'] = $reg['text4'];
            $_REQUEST['text5'] = $reg['text5'];
            $_REQUEST['text6'] = $reg['text6'];
            $_REQUEST['ftotal'] = $reg['ftotal'];
            $_REQUEST['fdeposito'] = $reg['fdeposito'];
            $_REQUEST['edades'] = $reg['edades'];
			       
            $noMover = $_REQUEST['tipo'];
        }
        ?>
        <?php
    //if(isset($_REQUEST['tipo'])&&$_REQUEST['tipo']==1)$disabled = 'style="display:none"';
    echo "<script languaje=\"javascript\"> const noMover = '<?php echo $noMover ?>'; </script>";
    echo "<script languaje=\"javascript\">javascript:bloquearCampos(0);</script>";  
        ?>

        <body onLoad="restaFechas()">
            <div align="center">
                <form  name="frm1" method="post" id="frm1" action="" enctype="multipart/form-data">
                    <p>
                        <input name="bot" type="hidden" value="<?php echo $varb ?>">
        <?php
        if (!isset($_POST['Submit2'])) {
//CHECA HABITACION OCUPADA O DESCUPADA EN EL MOMENTO DE ESTAR INGRESANDO DATOS
            $fec = $_REQUEST['ffecllegada'];
            include('DF20000.php');
            $fini = $f_m;
            $fec = $_REQUEST['ffecsalida'];
            include('DF20000.php');
            $fsal = $f_m;

            if ($_REQUEST['fnumcto'] != $reg['fnumcto']) {
//COMPARACION DE FECHAS PARA LA OCUPACION DE CUARTOS
                $dt_user = mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='" . $_REQUEST['fnumcto'] . "' AND ffecllegada < '$fini' AND ffecsalida > '$fini' "));
                echo mysqli_error($con);
                $dt_uper = mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='" . $_REQUEST['fnumcto'] . "' AND 
		ffecllegada < '$fsal' AND ffecsalida > '$fsal' "));
                echo mysqli_error($con);
                $dt_uwer = mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='" . $_REQUEST['fnumcto'] . "' AND 
		ffecllegada > '$fini' AND ffecsalida < '$fsal' "));
                echo mysqli_error($con);
                $dt_user2 = mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto,ffecllegada FROM valeryus19 WHERE fnumcto='" . $_REQUEST['fnumcto'] . "'  AND ffecllegada < '$fsal' AND ffecsalida >= '$fsal' "));
                echo mysqli_error($con);

                if ($dt_user2['numRows'] != 0) {
                    $oc1 = 1;
                } else
                if ($dt_user['numRows'] != 0) {
                    $oc1 = 1;
                } else
                if ($dt_uper['numRows'] != 0) {
                    $oc2 = 1;
                } else
                if ($dt_uwer['numRows'] != 0) {
                    $oc3 = 1;
                } else {
                    $oc1 = 0;
                    $oc2 = 0;
                    $oc3 = 0;
                }
                if (($oc1 == 1) || ($oc2 == 1) || ($oc3 == 1)) {
                    echo '	<script language="javascript">
		alert("LA HABITACION ESTA OCUPADA!!!");
			</script>';
                    $_REQUEST['fnumcto'] = '';
                    $_REQUEST['ftipocto'] = '';
                }
            }
        }
        $fecha = daydiff($_REQUEST['ffecsalida'], $_REQUEST['ffecllegada'], 'd/m/Y');

        for ($i = 0; $i < $fecha; $i++) {
            $Segundos = $Segundos + 86400;
            $caduca = date("D", time() + $Segundos);
            if ($caduca == "Fri") {
                $val1 = $val1 + 1;
            } else if ($caduca == "Sat") {
                $val2 = $val2 + 1;
            } else {
                $FechaFinal = date("Y-m-d", time() + $Segundos);
                $cuenta = $cuenta + 1;
            }
        }
        $sabd = $val1 + $val2;

        $lkjsa = daydiff($_REQUEST['ffecsalida'], $_REQUEST['ffecllegada'], 'd/m/Y');
        ?>
                    </p>
                    <p>&nbsp;</p>
                    <p>&nbsp;</p>
                    <div id="width_cabe" align="center">
                        <table width="1059" align="center" onMouseOver="restaTex();" id="tableReservas">
                            <tr><th colspan="13" class=\"titulo\"><div align="center"> MODIFICAR REGISTRO DE RESERVACIONES INDIVIDUALES.</div></th></tr>
                            <tr>
                                <td width="60" style="#000000"><span class="Estilo20">HORA DE LLEGADA</span></td>
                                <td width="48" style="#66CCFF"><!--input name="ffecalt" type="text" id="ffecalt" size="7" disabled="disabled" value="<?php //echo $_REQUEST['ffecalt'];?>"--></td>
                                <td width="114" style="#66CCFF"><input name="fhorallega" type="text" disabled="disabled" class="styTabEspA" id="fhorallega" onKeyPress="return validar(event)"  value="<?php echo (isset($_REQUEST['fhorallega'])) ? $_REQUEST['fhorallega'] : "0"; ?>" size="6"></td>
                                <td colspan="4" style="#000000"><span class="Estilo20">ALTA</span>
                                    <input name="ffecalt" type="text" id="ffecalt"  class="styTabEspA" disabled="disabled" size="7"
                               <?php
                               if (isset($bot)) {
                                   $fec1 = $reg["ffecalt"];
                                   include('DF20000.php');
                                   echo 'value="' . $f_f . '"';
                               }
                               ?>/>
                                    <input name="fusualta" type="text" disabled="disabled" id="fusualta" size="8"
    <?php
    if (isset($bot)) {
        echo 'value="' . $reg['fusualta'] . '"';
    }
    ?>></td>
                                <td style="#000000"><span class="Estilo20">ULTIMO CAMBIO</span></td>
                                <td colspan="2" style="#66CCFF"><input name="ffeccam" type="text" class="styTabEspA" id="ffeccam" size="7" disabled="disabled"
                                                                       <?php
                                                                       if (isset($bot)) {
                                                                           $fec1 = $reg["ffeccam"];
                                                                           include('DF20000.php');
                                                                           echo 'value="' . $f_f . '"';
                                                                       }
                                                                       ?>>
                                    <input name="fusucamb" type="text" id="fusucamb" disabled="disabled" size="8"
                                    <?php
                                    if (isset($bot)) {
                                        echo 'value="' . $reg['fusucamb'] . '"';
                                    }
                                    ?>></td>
                                <td style="#000000"><span class="Estilo20">FOLIO</span></td>
                                <td colspan="2" style="#66CCFF"><input name="ffecalt2" type="text" id="ffecalt2"  class="styTabEspA" disabled="disabled" size="7"
                                    <?php
                                    if (isset($bot)) {
                                        echo 'value="' . $reg['n_reg'] . '"';
                                    }
                                    ?>/></td> 
                            </tr>
                            <tr>
                                <th colspan="2" style="#000000"><span class="Estilo20">FECHA DE LLEGADA </span></th>
                                <td style="#66CCFF">
                                    <input name="ffecllegada" type="text" id="ffecllegada" class="emplea datefrom" size="10"  value="<?php echo $_REQUEST['ffecllegada']; ?>" >
                                </td>
                                <td colspan="2" style="#000000"><span class="Estilo20">NUMERO DE ADULTOS</span></td>
                                <td colspan="2" style="#66CCFF"><input name="fnumadu" type="text" id="fnumadu" tabindex="1" onKeyPress="return validar(event)" size="5"  value="<?php echo $_REQUEST['fnumadu']; ?>"></td>
                                <td colspan="3" style="#66CCFF">
                                    <label>
                                        <div align="center" id="buscarHabitaion"><span class="Estilo1">
                                                <input name="?323" type="button" class="original" tabindex="3" onClick="
                      openWindow(
                              {
                                  action: 'FRGC20000.php',
                                  width: 700,
                                  height: 350
                              }, {
                          val: 'fnumcto',
                          des: 'ftipocto',
                          alta: 'tex4',
                          baja: 'text4'
                      })" value="Buscar Habitacion" >
                                            </span></div> 
                                    </label></td>  
                                <td colspan="2" style="#000000"><div align="center" class="Estilo18 Estilo20">NOTAS</div></td>
                            </tr>
                            <tr>
                                <th colspan="2" style="#000000"><span class="Estilo20">FECHA DE SALIDA</span></th>
                                <td style="#66CCFF"><input name="ffecsalida" type="text" id="ffecsalida" class="emplea dateto" size="10"  onChange="restaFechas()" value="<?php echo $_REQUEST['ffecsalida']; ?>" >
                                </td>
                                <td colspan="2" style="#000000"><span class="Estilo20">NUMERO DE MENORES</span></td>
                                <td colspan="2" style="#66CCFF"><input name="fnummenor" type="text" id="fnummenor" tabindex="2" onKeyPress="return validar(event)" size="5"  value="<?php echo $_REQUEST['fnummenor']; ?>"></td>
                                <td style="#000000"><span class="Estilo20">TIPO DE HABITACION </span></td>
                                <td colspan="2" style="#66CCFF"><input name="ftipocto" type="text" id="ftipocto" value="<?php echo $_REQUEST['ftipocto']; ?>" READONLY></td>
                                <td colspan="2" rowspan="2" style="#66CCFF"><div align="center">
                                        <textarea name="fnorasvip" cols="30" rows="3" id="fnorasvip" onBlur="may(this)" tabindex="4"><?php echo $_REQUEST['fnorasvip']; ?></textarea>
                                    </div></td></tr>
                            <tr>
                                <th colspan="2" style="#000000"><span class="Estilo20">NOCHES</span></th>
                                                <?php
                                                $fecha = chfecha($_REQUEST['ffecsalida'], 'd/m/Y', 'Y-m-d');
                                                list($year, $month, $day) = explode('-', $fecha);
                                                $fecha = mktime(0, 0, 0, $month, $day, $year);
                                                $hoy = chfecha($_REQUEST['ffecllegada'], 'd/m/Y', 'Y-m-d');
                                                list($year, $month, $day) = explode('-', $hoy);
                                                $hoy = mktime(0, 0, 0, $month, $day, $year);
                                                $diad = ($fecha - $hoy ) / (60 * 60 * 24);
                                                $dias = number_format($diad, 0, '.', ',')
                                                ?>

                                <td style="#66CCFF"><input name="fnumctos" type="text" id="fnumctos" tabindex="20" size="15" value="<?php echo $dias; ?>" READONLY></td>
                                <td colspan="2" style="#000000"><span class="Estilo20">EDADES DE MENORES</span></td>
                                <td colspan="2" style="#66CCFF"><input name="edades" type="text" id="edades" tabindex="2" size="5"  value="<?php echo $_REQUEST['edades']; ?>"></td>
                                <td style="#000000"><span class="Estilo20">NUMERO DE HABITACION </span></td>
                                <td colspan="2" style="#66CCFF"><input name="fnumcto" type="text" id="fnumcto" tabindex="20" size="5"  value="<?php echo $_REQUEST['fnumcto']; ?>" READONLY></td></tr>
                            <tr><th colspan="13" class="titulo"><div align="center" class="Estilo18">MODIFICAR DATOS </div></th></tr>
                            <tr>
                                <td style="#000000"><span class="Estilo18 Estilo22"><strong>GRUPO</strong></span></td>
                                <td colspan="4" style="#66CCFF"><span class="Estilo18">
                                        <select name="fcodgrupo" id="fcodgrupo" tabindex="5">
                                            <option value="">----------SELECCIONE----------</option>
                                                                       <?php
                                                                       $sql = mysqli_query($con ,"SELECT * FROM valeryus04 order by gdescrip");
                                                                       while ($reg = mysqli_fetch_array($sql)) {
                                                                           if ($_REQUEST['fcodgrupo'] == $reg['gdescrip']) {
                                                                               echo '<option value="' . $reg['gdescrip'] . '" selected>' . $reg['gdescrip'] . '</option>';
                                                                           } else {
                                                                               echo '<option value="' . $reg['gdescrip'] . '">' . $reg['gdescrip'] . '</option>';
                                                                           }
                                                                       }
                                                                       ?>
                                        </select></span></td>
                                <td style="#000000"><span class="Estilo18 Estilo22"><strong>MERCADO</strong></span></td>
                                <td colspan="2" style="#66CCFF"><span class="Estilo18">
                                        <select name="fcodmeca" id="fcodmeca" tabindex="6">
                                            <option value="">-----SELECCIONE-----</option>
                                <?php
                                $sql = mysqli_query($con ,"SELECT * FROM tipmerca order by tdescrip");
                                while ($reg = mysqli_fetch_array($sql)) {
                                    if ($_REQUEST['fcodmeca'] == $reg['tdescrip']) {
                                        echo '<option value="' . $reg['tdescrip'] . '" selected>' . $reg['tdescrip'] . '</option>';
                                    } else {
                                        echo '<option value="' . $reg['tdescrip'] . '">' . $reg['tdescrip'] . '</option>';
                                    }
                                }
                                ?>
                                        </select>
                                    </span></td>
                                <td style="#000000"></td>
                                <td colspan="1" style="#66CCFF"></td>
                                
                                <td colspan="2" style="#000000"><div align="center" class="Estilo18 Estilo20">NOTAS INTERNAS</div></td>
                            </tr>
                            <tr>
                                <td style="#000000"><span class="Estilo18 Estilo22"><strong>AGENCIA</strong></span></td>
                                <td colspan="4" style="#66CCFF"><span class="Estilo18">
                                        <select name="fcodagen" id="fcodagen" tabindex="8">
                                            <option value="">--SELECCIONE--</option>
                                            <?php
                                            $sql = mysqli_query($con ,"SELECT * FROM valeryus07 order by agdescrip");
                                            while ($reg = mysqli_fetch_array($sql)) {
                                                if ($_REQUEST['fcodagen'] == $reg['agdescrip']) {
                                                    echo '<option value="' . $reg['agdescrip'] . '" selected>' . $reg['agdescrip'] . '</option>';
                                                } else {
                                                    echo '<option value="' . $reg['agdescrip'] . '">' . $reg['agdescrip'] . '</option>';
                                                }
                                            }
                                            ?>
                                        </select>
                                    </span></td>
                                <td style="#000000"><span class="Estilo18 Estilo22"><strong>PLAN</strong></span></td>
                                <td colspan="4" style="#66CCFF"><span class="Estilo18">
                                        <select name="fplan" id="fplan" tabindex="9">
                                            <option value="">--SELECCIONE--</option>
                                            <?php
                                            $sql = mysqli_query($con ,"SELECT * FROM pplan order by pdescrip");
                                            while ($reg = mysqli_fetch_array($sql)) {
                                                if ($_REQUEST['fplan'] == $reg['pdescrip']) {
                                                    echo '<option value="' . $reg['pdescrip'] . '" selected>' . $reg['pdescrip'] . '</option>';
                                                } else {
                                                    echo '<option value="' . $reg['pdescrip'] . '">' . $reg['pdescrip'] . '</option>';
                                                }
                                            }
                                            ?>
                                        </select>
                                    </span></td>
                                    <td colspan="2" rowspan="2" style="#66CCFF"><div align="center">
                                        <textarea name="extra4" cols="30" rows="3" id="extra4" onBlur="may(this)" tabindex="4"><?php echo $_REQUEST['extra4']; ?></textarea>
                                    </div></td>
                            </tr>
                            <tr>
                                <td style="#000000"><span class="Estilo18 Estilo22"><strong>SMERF</strong></span></td>
                                <td colspan="4" style="#66CCFF"><span class="Estilo18">
                                        <select name="smerf" id="smerf" tabindex="11">
                                            <option value="">--SELECCIONE--</option>
                                            <?php
                                            $sql = mysqli_query($con ,"SELECT * FROM fsmerf order by descripcion");
                                            while ($reg = mysqli_fetch_array($sql)) {
                                                if ($_REQUEST['smerf'] == $reg['descripcion']) {
                                                    echo '<option value="' . $reg['descripcion'] . '" selected>' . $reg['descripcion'] . '</option>';
                                                } else {
                                                    echo '<option value="' . $reg['descripcion'] . '">' . $reg['descripcion'] . '</option>';
                                                }
                                            }
                                            ?></select></span>      <div align="center"></div></td>
                                <td style="#000000"><span class="Estilo22"><strong>EMPRESA</strong></span></td>
                                <td colspan="7" style="#66CCFF"><select name="fempresa" id="fempresa" tabindex="7">
                                        <option value="">-----SELECCIONE-----</option>
    <?php
    $sql = mysqli_query($con ,"SELECT * FROM fcompas ORDER BY pdesco");
    while ($reg = mysqli_fetch_array($sql)) {
        if ($_REQUEST['fempresa'] == $reg['pdesco']) {
            echo '<option value="' . $reg['pdesco'] . '" selected>' . $reg['pdesco'] . '</option>';
        } else {
            echo '<option value="' . $reg['pdesco'] . '">' . $reg['pdesco'] . '</option>';
        }
    }
    ?>
                                    </select></td>
                            </tr>
                            <tr>
                                <th colspan="13" class="titulo"><div align="center" class="Estilo18">MODIFICAR FORMA DE PAGO </div></th></tr>
                            <tr>    
                                <td style="#000000">
                                    <span class="Estilo22">  
                                        <strong> TARIFA</strong>		    </span>
                                <td colspan="6" style="#66CCFF">          
                                    <input name="tex" type="text" id="tex" size="3" value="<?php echo $_REQUEST['tex']; ?>" />
                                    <input name="tex2" type="text" id="tex2" size="18" value="<?php echo $_REQUEST['tex2']; ?>" READONLY>
                                    <input name="tex3" type="hidden" id="tex3" size="2" value="<?php echo $_REQUEST['tex3']; ?>" READONLY>
                                    <span class="Estilo17"><strong>$</strong></span>
                                    <input name="manual" type="hidden" id="manual" size="3" value="<?php echo $_REQUEST['manual']; ?>"/>
                                            <?php
                                            @$sql = mysqli_query($con ,"select * from dxopemaex where nombre like '" . $_SESSION['usuario'] . "'");
                                            @$reg = mysqli_fetch_array($sql);
                                            if (!isset($_POST['manual']))
                                                $_POST['manual'] = "";
                                            if ($_POST['manual'] == 'SI' and $reg['manual'] == '1') {
                                                ?>
                                        <input name="tex4" type="text" id="tex4" size="3" value="<?php if ($_REQUEST['tex4'] != '') {
                                            echo $_REQUEST['tex4'];
                                        } else {
                                            echo '0';
                                        } ?>" onMouseMove="restaTex()" />
                                            <?php } else {
                                            ?>
                                        <input name="tex4" type="text" id="tex4" size="3" value="<?php if ($_REQUEST['tex4'] != '') {
                                                echo $_REQUEST['tex4'];
                                            } else {
                                                echo '0';
                                            } ?>" onMouseMove="restaTex()" READONLY>
                                            <?php }
                                        ?>
                                    <input name="tex5" type="text" id="tex5" size="1" value="<?php echo $dias; ?>" onMouseMove="restaTex()" READONLY>
                                    =<span class="Estilo17"><strong>$</strong></span>
                                    <input name="tex6" type="text" id="tex6" size="3" onMouseMove="restaTex()" value="<?php echo $_REQUEST['tex6']; ?>" READONLY>
                               <!--     <input name="?322" type="button" class="original" tabindex="12" onClick="
                                            openWindow(
                                            {
                                                    action:'rec_chin_AG3.php',
                                                    width:700,
                                                    height:350
                                            },{
                                                    val:'tex',
                                                    des:'tex2',
                                                    kji:'tex4'
                                            })" value="Buscar">  -->
                                <td style="#000000"><span class="Estilo22"><strong>FORMA DE PAGO</strong></span>
                                <td colspan="3" style="#66CCFF">            <span class="Estilo1">
                                        <select name="fformpago" id="fformpago" onChange="javascript: document.getElementById('frm1').submit()" tabindex="14">
                                            <option value="">---SELECCIONE---</option>
    <?php
    $sql = mysqli_query($con ,"SELECT * FROM valeryus09 WHERE pmontomax = 'ABONO' AND ppago = 'SI' order by descripcion");
    while ($reg = mysqli_fetch_array($sql)) {
        if ($_REQUEST['fformpago'] == $reg['descripcion']) {
            echo '<option value="' . $reg['descripcion'] . '" selected>' . $reg['descripcion'] . '</option>';
        } else {
            echo '<option value="' . $reg['descripcion'] . '">' . $reg['descripcion'] . '</option>';
        }
    }
    ?>
                                        </select>
                                    </span> 
                                <td colspan="2" style="#000000"><strong><span class="Estilo22">EXPIRA</span>
                                        <input name="flimite" type="text" id="flimite" tabindex="16" size="10" value="<?php echo $_REQUEST['flimite']; ?>">
                                    </strong></tr>
                            <tr>

                                <td style="#000000"><input name="?22" type="button" value="Extras" <?= $disabled ?> onClick="window.open('valeryus55100_AG.php?retPag=res_registro_ACEX.php&bot=<?php echo $bot; ?>', 'popuppage', 'width=850,height=400,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')" class="original" ></td>
                                <td colspan="3" style="#66CCFF"></td>
                                <td style="#000000"><input name="?2" type="button" value="Depositos" <?= $disabled ?> onClick="window.open('res_registro_MODE.php?retPag=res_registro_ACEX.php&bot=<?php echo $bot; ?>', 'popuppage', 'width=850,height=400,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')" class="original" ></td>
                                <td colspan="2" style="#66CCFF"><strong>
                                        <input name="fdeposito" type="text" id="fdeposito" tabindex="14" size="10" value="<?php echo (isset($_REQUEST['fdeposito'])) ? $_REQUEST['fdeposito'] : "0"; ?>" READONLY>
                                    </strong></td>
                                <td style="#000000"><span class="Estilo22"><strong>CODIGO DE SEGURIDAD</strong></span></td>
                                <td colspan="2" style="#66CCFF"><input name="fcodseg" type="text" id="fcodseg" tabindex="15" size="10" value="<?php echo $_REQUEST['fcodseg']; ?>"></td>
                                <td style="#000000"><span class="Estilo22"><strong>NUMERO DE TARJETA</strong></span></td>
                                <td colspan="2" style="#66CCFF"><input name="fnumtar" type="text" id="fnumtar" tabindex="15"
                                                                       onBlur="may(this)" size="18"
    <?php
    if (isset($_REQUEST['fnumtar'])) { //este es el truco
        echo 'value="' . $_REQUEST['fnumtar'] . '"';
    }
    ?>/></td>
                            </tr>

                            <tr>
                                <th colspan="13" class="titulo"><div align="center" class="Estilo18">MODIFICAR DIRECCION</div></th></tr>
                            <tr>
                                <td style="#000000"><span class="Estilo22"><strong>NOMBRE</strong></span></td>
                                <td colspan="3" style="#66CCFF">
                                    <textarea name="fnombre" cols="25" rows="3" id="fnombre" onBlur="may(this)" tabindex="4"><?php echo $_REQUEST['fnombre']; ?></textarea>
                                <td width="95" style="#000000"><span class="Estilo22"><strong>APELLIDO</strong></span></td>
                                <td colspan="3" style="#66CCFF">
                                    <textarea name="fapellido" cols="20" rows="3" id="fapellido" onBlur="may(this)"tabindex="4"><?php echo $_REQUEST['fapellido']; ?></textarea>	</td>
                                <td width="97" style="#000000"><span class="Estilo22"><strong>COMO SE ENTERO? </strong></span></td>
                                <td colspan="2" style="#66CCFF"><select name="ftiphuesped" id="ftiphuesped" onChange="javascript: document.getElementById('frm1').submit()" tabindex="19">
                                        <option value="">--SELECCIONE--</option>
                                            <?php
                                            $sql = mysqli_query($con ,"SELECT * FROM tiphuesped order by tpdescrip");
                                            while ($reg = mysqli_fetch_array($sql)) {
                                                if ($_REQUEST['ftiphuesped'] == $reg['tpdescrip']) {
                                                    echo '<option value="' . $reg['tpdescrip'] . '" selected>' . $reg['tpdescrip'] . '</option>';
                                                } else {
                                                    echo '<option value="' . $reg['tpdescrip'] . '">' . $reg['tpdescrip'] . '</option>';
                                                }
                                            }
                                            ?>
                                    </select></td>
                                <td style="#66CCFF"><div align="center"><strong><span class="Estilo19">VIP</span></strong><span class="Estilo18">
                                            <input name="fvip" type="checkbox" id="fvip" value="SI" <?php if (isset($_REQUEST['fvip']) && $_REQUEST['fvip'] == 'SI') echo 'checked'; ?>>
                                        </span>
										  <span class="Estilo19">No Mover.</span> 
            <input name="tipo" type="checkbox" onchange="checapass('tipo')" id="tipo" value="1"<?php
  if(isset($_REQUEST['tipo'])&&$_REQUEST['tipo']==1) echo 'checked';?>>
										</div></td>
                            <tr>
                                <td style="#000000"><span class="Estilo22"><strong>TELEFONO</strong></span></td>
                                <td colspan="3" style="#66CCFF"><input name="ftelefono" type="text" id="ftelefono" tabindex="20" size="25" value="<?php echo $_REQUEST['ftelefono']; ?>"></td>
                                <td style="#000000"><span class="Estilo22"><strong>TELEFONO EMPRESA</strong></span></td>
                                <td colspan="3" style="#66CCFF"><input name="ftelemp" type="text" id="ftelemp" tabindex="21" size="25" value="<?php echo $_REQUEST['ftelemp']; ?>"></td>
                                <td style="#000000"><span class="Estilo22">
                                        <label><strong>E-MAIL</strong></label>
                                    </span></td>
                                <td colspan="3" style="#66CCFF"><input name="fmail" type="text" id="fmail" tabindex="23" size="25" value="<?php echo $_REQUEST['fmail']; ?>"></td>
                            </tr>
                            <tr>
                                <td style="#000000"><span class="Estilo22"><strong>E-MAIL EMPRESA</strong></span></td>
                                <td colspan="3" style="#66CCFF"><input name="femail" type="text" id="femail" tabindex="24" size="25" value="<?php echo $_REQUEST['femail']; ?>"></td>
                                <td style="#000000"><span class="Estilo22"><strong>DIRECCION</strong></span></td>
                                <td colspan="3" style="#66CCFF"><input name="fdireccion" type="text" id="fdireccion" tabindex="25" size="20" onBlur="may(this)" value="<?php echo $_REQUEST['fdireccion']; ?>">
                                    <span class="Estilo18">
                                        <input name="?" type="button" class="original" tabindex="26" <?= $disabled ?> onClick="window.open('DX40000_AG1.php?retPag=res_registro_ACEX.php', 'popuppage', 'width=750,height=300,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')" value="..." >
                                    </span></td>
                                <td style="#000000"><span class="Estilo22"><strong>CODIGO POSTAL</strong></span></td>
                                <td style="#66CCFF"><input name="tcp" type="text" onKeyPress="return validar(event)" value="<?php echo $_REQUEST['tcp']; ?>" size="10" maxlength="5"></td>
                                <td style="#000000"><span class="Estilo22"><strong>COLONIA</strong></span></td>
                                <td style="#66CCFF"><span class="Estilo18">
                                        <input type="hidden" name="tcol1" id="tcve" value="<?php echo $_REQUEST['tcve']; ?>">
                                        <input name="tcol" type="text" id="tcol" value="<?php echo $_REQUEST['tcol']; ?>" size="20">
                                        <input name="cuarto_seguro" type="hidden" id="cuarto_seguro" value="<?php echo $_REQUEST['cuarto_seguro']; ?>" size="15"/>
                                    </span></td>
                            </tr>
                            <tr>
                                <td style="#000000"><span class="Estilo22"><strong>PAIS</strong></span></td>
                                <td colspan="3" style="#66CCFF"><span class="Estilo18">
                                        <select name="pais" id="pais" onChange="javascript: document.getElementById('frm1').submit()">
                                            <option value="">--Selecciona--</option>
                                        <?php
                                        include("DMMYSQLG.php");
                                        @$resultado = mysqli_query($con ,"select * from dxpaises");
                                        if (!isset($_REQUEST['pais'])) {
                                            $dt_paises = mysqli_fetch_array($resultado);
                                            $selPais = $dt_paises['cve_pais'];
                                            if (mysqli_num_rows($resultado) > 0)
                                                mysqli_data_seek($resultado, 0);
                                        } else {
                                            $selPais = $_REQUEST['pais'];
                                        }
                                        while ($registro = mysqli_fetch_array($resultado)) {
                                            if ($selPais == $registro['cve_pais']) {
                                                echo '<option value="' . $registro['cve_pais'] . '" selected>' . $registro['des_pais'] . '</option>';
                                            } else {
                                                echo '<option value="' . $registro['cve_pais'] . '">' . $registro['des_pais'] . '</option>';
                                            }
                                        }
                                        ?>
                                        </select>
                                    </span></td>
                                <td style="#000000"><span class="Estilo22"><strong>ESTADO</strong></span></td>
                                <td colspan="3" style="#66CCFF"><span class="Estilo18">
                                        <select name="estados" onChange="javascript: document.getElementById('frm1').submit()">
                                            <option  value="">-----Selecciona-----</option>
    <?php
    @$resultado = mysqli_query($con ,"select * from dxestado where cve_pais='$selPais'");
    if (!isset($_REQUEST['estados'])) {
        $dt_estado = mysqli_fetch_array($resultado);
        $selEnt = $dt_estado['cve_estado'];
        if (mysqli_num_rows($resultado) > 0)
            mysqli_data_seek($resultado, 0);
    } else {
        $selEnt = $_REQUEST['estados'];
    }
    while ($registro = mysqli_fetch_array($resultado)) {
        if ($selEnt == $registro['cve_estado']) {
            echo '<option value="' . $registro['cve_estado'] . '" selected>' . $registro['des_estado'] . '</option>';
        } else {
            echo '<option value="' . $registro['cve_estado'] . '">' . $registro['des_estado'] . '</option>';
        }
    }
    ?>
                                        </select>
                                    </span></td>
                                <td style="#000000"><span class="Estilo22"><strong>DELEGACION O MUNICIPIO</strong></span></td>
                                <td colspan="3" style="#66CCFF"><span class="Estilo18">
                                        <select name="tmun" id="tmun" >
                                            <option  value="">-----Selecciona-----</option>
                                               <?php
                                               @$resultado = mysqli_query($con ,"select * from dxdelmun where cve_estado='$selEnt' and cve_pais='$selPais'");
                                               if (!isset($_REQUEST['tmun'])) {
                                                   $dt_delmun = mysqli_fetch_array($resultado);
                                                   $selDelMun = $dt_delmun['cve_delmun'];
                                                   if (mysqli_num_rows($resultado) > 0)
                                                       mysqli_data_seek($resultado, 0);
                                               } else {
                                                   $selDelMun = $_REQUEST['tmun'];
                                               }
                                               while (@$registro = mysqli_fetch_array($resultado)) {
                                                   if ($selDelMun == $registro['cve_delmun']) {
                                                       echo '<option value="' . $registro['cve_delmun'] . '" selected>' . $registro['des_delmun'] . '</option>';
                                                   } else {
                                                       echo '<option value="' . $registro['cve_delmun'] . '">' . $registro['des_delmun'] . '</option>';
                                                   }
                                               }
                                               ?>
                                        </select>
                                    </span></td>
                            </tr>
                            <tr <?= $disabled ?>>
                                <td colspan="13" class="titulo"><div align="center" class="Estilo26">AGREGAR ARCHIVOS QUE RESPALDEN RESERVA </div></td>
                            </tr>
                            <tr <?= $disabled ?>>
                                <td colspan="13"> <iframe  src="reservas-ev/index.php?folio=<?php echo $_REQUEST['n_reg']; ?>" frameborder="0" scrolling="no"  style="width: 100%; height: 250px;" >
                                        <p>Your browser does not support iframes.</p>
                                    </iframe>
                                </td>
                            </tr>
                            <tr>
                                <th colspan="13"><div align="center"> 
    <?php if ($_GET['type'] == 'his' || $_GET['type'] == 'mod') { ?>      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input name="Submit" type="button" class="bot_WsW" tabindex="30" onClick="openpage('ger_cambios_PR.php', '_self')" value="Regresar"/>
                                            <?php } else { ?>
                                            <input name="Submit2" type="submit" class="original" tabindex="29" value="Modificar" id="btnModificar"/>
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input name="Submit" type="button" class="bot_WsW" tabindex="30" id="btnRegresar" onClick="openpage('res_registro_PR.php', '_self')" value="Regresar"/>
                                            <?php } ?>
                                    </div></th>
                            </tr>
                        </table>
                </form>
                                            <?php
                                            $fecha = (isset($dt_empres['fec_alta'])) ? $dt_empres['fec_alta'] : "0";
                                            $fechita = chfecha($fecha, 'Y-m-d', 'd/m/Y');
                                            if (!isset($_POST['ffecllegada']))
                                                $_POST['ffecllegada'] = "";
                                            $fecha_llegada = chfecha($_POST['ffecllegada'], 'd/m/Y', 'Y-m-d');
                                            if (isset($_POST['Submit2'])) {

                                                if ($fecha_llegada < $fecha) {
                                                    echo alert_JS("\A1\A1\A1FECHA DE LLEGADA INVALIDA!!! MENOR A LA FECHA ACTUAL");
                                                    return false;
                                                }
                                                if ($_POST['fnumctos'] <= 0) {
                                                    echo alert_JS("\A1\A1\A1FECHA DE SALIDA INVALIDA!!!");
                                                    return false;
                                                }if ($_POST['fnumadu'] == "") {
                                                    echo alert_JS("\A1\A1\A1COMPLETE EL NUMERO DE ADULTOS!!!");
                                                    return false;
                                                    /////////////////////////////////////MODIFICAR DATOS////////////////////////////////////////////////
                                                }if (empty($_POST['fcodmeca'])) { // 6
                                                    echo alert_JS("\A1\A1\A1SELECCIONE EL TIPO DE MERCADO!!!");
                                                    return false;
                                                }//if(empty($_POST['fplan'])){ // 7
                                                //echo alert_JS("\A1\A1\A1SELECCIONE EL TIPO DE PLAN!!!");
                                                //return false;  
                                                //}
                                                ///////////////////////////////////////MODIFICAR FORMA DE PAGO///////////////////////////////////////////////////
                                                if (empty($_POST['tex']) or empty($_POST['tex2'])) {  // 8
                                                    echo alert_JS("\A1\A1\A1COMPLETE LA TARIFA!!!");
                                                    return false;
                                                }

                                                $oahi = $_POST['tex4'] * $_POST['tex5'];

                                                if ($oahi != $_POST['tex6']) {
                                                    echo alert_JS("\A1\A1\A1TOTAL TARIFA INCORRECTA!!!");
                                                    return false;
                                                }

                                                //if(empty($_POST['fformpago'])){ // 15
                                                //echo alert_JS("\A1\A1\A1SELECCIONE LA FORMA DE PAGO!!!");
                                                //return false;  
                                                //}/////////////////////////////////MODIFICAR DIRECCION///////////////////////////////////////////////////////////////
                                                if ($_POST['fnombre'] == "") {
                                                    echo alert_JS("\A1\A1\A1COMPLETE EL NOMBRE!!!");
                                                    return false;
                                                }if ($_POST['fapellido'] == "") {
                                                    echo alert_JS("\A1\A1\A1COMPLETE EL APELLIDO!!!");
                                                    return false;
                                                }//if($_POST['ftelefono'] == "" ){
                                                //echo alert_JS ("\A1\A1\A1COMPLETE EL TELEFONO!!!");
                                                //return false;
                                                //}
                                                if ($_POST['fmail'] == "") {
                                                    echo alert_JS("\A1\A1\A1COMPLETE EL CORREO ELETRONICO!!!");
                                                    return false;
                                                }
                                                //if($_POST['ftelemp'] == "" ){
                                                //echo alert_JS ("\A1\A1\A1COMPLETE EL TELEFONO DE LA EMPRESA!!!");
                                                //return false;
                                                //}
                                                //7if($_POST['femail'] == "" ){
                                                //echo alert_JS ("\A1\A1\A1COMPLETE EL CORREO ELECTRONICO DE LA EMPRESA!!!");
                                                //return false;
                                                //}
                                                //if($_POST['fdireccion'] == "" ){
                                                //echo alert_JS ("\A1\A1\A1COMPLETE LA DIRECCION!!!");
                                                //return false;
                                                //}if(empty($_POST['ftiphuesped'])){ 
                                                //echo alert_JS("\A1\A1\A1SELECCIONE EL TIPO DE HUESPED!!!");
                                                //return false;
                                                //}

                                                include("DMMYSQLG.php");
                                                include("DMMYSQLG.php");
                                                if (isset($_POST['fnumcto'])) {
                                                    $usu = mysqli_real_escape_string($con,$_POST['fnumcto']);
                                                    $dt_user = mysqli_fetch_array(mysqli_query($con ,"SELECT   count(*) as numRows, ncto FROM valeryus08 WHERE ncto='$usu' "));
                                                    echo mysqli_error($con);

                                                    if ($dt_user['numRows'] == 0) {
                                                        echo alert_JS("\A1\A1\A1\A1LA HABITACION SELECCIONADA NO EXISTE!!!!");
                                                        return false;
                                                    }
                                                }
                                                $fec = $_POST['ffecllegada'];
                                                include('DF20000.php');
                                                $fecha_inicial = $f_m;
                                                $fec = $_POST['ffecsalida'];
                                                include('DF20000.php');
                                                $fecha_final = $f_m;
                                                $usu = mysqli_real_escape_string($con,$_POST['fnumcto']);

                                                $dt_user = mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='" . $usu . "' AND ffecllegada <= '" . $fecha_inicial . "' AND ffecsalida > '" . $fecha_inicial . "' AND n_reg <> '" . $bot . "' AND cancelado='0' "));
                                                $xox = mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='" . $usu . "' AND ffecllegada <= '" . $fecha_inicial . "' AND ffecsalida > '" . $fecha_inicial . "' AND n_reg <> '" . $bot . "' AND cancelado='0' ")); //ENTRADA ENTRE DOS FEHCAS
                                                echo mysqli_error($con);

                                                if ($dt_user['numRows'] != 0) {
                                                    echo alert_JS("\A1\A1\A1\A1LA HABITACION ESTA OCUPADA POR: " . $xox['fapellido'] . " " . $xox['fnombre'] . " !!!!");
                                                    return false;
                                                }

                                                $dt_uper = mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='" . $usu . "' AND ffecllegada < '" . $fecha_final . "' AND ffecsalida >= '" . $fecha_final . "' AND n_reg <> '" . $bot . "' AND cancelado='0' "));
                                                $yoy = mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='" . $usu . "' AND ffecllegada < '" . $fecha_final . "' AND ffecsalida >= '" . $fecha_final . "' AND n_reg <> '" . $bot . "' AND cancelado='0' ")); //SALIDA ENTRE DOS FECHAS
                                                echo mysqli_error($con);

                                                if ($dt_uper['numRows'] != 0) {
                                                    echo alert_JS("\A1\A1\A1\A1LA HABITACION ESTA OCUPADA POR: " . $yoy['fapellido'] . " " . $yoy['fnombre'] . " !!!!");
                                                    return false;
                                                }

                                                $dt_uwer = mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='" . $usu . "' AND ffecllegada > '" . $fecha_inicial . "' AND ffecsalida < '" . $fecha_final . "' AND n_reg <> '" . $bot . "' AND cancelado='0' "));
                                                $dod = mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='" . $usu . "' AND ffecllegada > '" . $fecha_inicial . "' AND ffecsalida < '" . $fecha_final . "' AND n_reg <> '" . $bot . "' AND cancelado='0' ")); //FECHA ENTRE DOS FECHAS
                                                echo mysqli_error($con);

                                                if ($dt_uwer['numRows'] != 0) {
                                                    echo alert_JS("\A1\A1\A1\A1LA HABITACION ESTA OCUPADA POR: " . $dod['fapellido'] . " " . $dod['fnombre'] . " !!!!");
                                                    return false;
                                                }

                                                if ($_REQUEST['fnumcto'] != $_POST['fnumcto']) {
                                                    ?>
                        <table width="430" height="117" align="center">
                            <tr>
                                <td height="21" colspan="2" style="#000000"><div align="center">
                                        <input name="One_R" type="button" class="original" tabindex="29" value="Guardar Motivo"/>
                                        &nbsp;</div></td>
                            </tr>
                            <tr>
                                <td width="191" height="49" style="#000000"><span class="Estilo1">ESPECIFIQUE EL MOTIVO DE CAMBIO DE CUARTO</span></td>
                                <td width="227"><textarea name="reason" cols="30" rows="3" id="reason" onBlur="may(this)"></textarea></td>
                            </tr>
                        </table>	
                        <?php
                        return false;
                    }
                    include ("res_registro_MC.php");
                }
                ?>
        </body>
                <?php
                mysqli_close($con);
            }
//961---->900 ultima actualizacion 23-junio-2011
//872---->800 ultima actualizacion 30-noviembre-2011
            ?>
</html>
