<?php
session_start();
include("DMMYSQLG.php");
include ("varfun.php");
include("JQUERY.inc");
require_once("DF80000.php");
$val2=0;
$val1=0;
$f_m=0;
$Segundos=0;
$cuenta=0;

?>
 <?php
        $reg = (isset($_POST['t66'])) ? $_POST['t66'] : "0";
        $gru_ocu = mysqli_query($con ,"SELECT n_reg FROM valeryus19 WHERE fcodgrupo='" . $reg . "' AND status='RESERVA GRUPO' AND cancelado='0'");
        $ocu = mysqli_num_rows($gru_ocu);
        if (isset($_POST['Submit'])) {
            if ($reg == "------------------SELECCIONE------------------") {
                echo alert_js("SELECCIONE EL GRUPO");
            } elseif ($ocu > '0') {
                echo alert_js("GRUPO EXISTENTE POR FAVOR SELECCIONE OTRO GRUPO!!");
            } elseif ($_POST['t25'] == "") {
                echo alert_js("COMPLETE EL NUMERO DE ADULTOS");
            } elseif ($_POST['t3'] == "") {
                echo alert_js("COMPLETE EL NOMBRE");
            } elseif ($_POST['t4'] == "") {
                echo alert_js("COMPLETE EL APELLIDO");
            } elseif ($_POST['t21'] == "-----SELECCIONE-----") {
                echo alert_js("SELECCIONE EL TIPO DE HUESPED");
            } elseif ($_POST['t33'] == "-----SELECCIONE-----") {

                echo alert_js("SELECCIONE EL TIPO DE MERCADO");
            } if ($_POST['t52'] == "AGENCIAS" and empty($_POST['t39'])) {

                echo alert_JS("POR FAVOR SELECCIONE EL NOMBRE DE LA AGENCIA");
            }if ($_POST['t52'] == "GRUPOS-AGENCIAS" and empty($_POST['t39'])) {
////
                echo alert_JS("POR FAVOR SELECCIONE EL NOMBRE DE LA  AGENCIA");
            }if ($_POST['t52'] == "ONLINE" and empty($_POST['t39'])) {
////
                echo alert_JS("POR FAVOR SELECCIONE EL NOMBRE DE LA  AGENCIA");

//}elseif($sqlAgen['n_reg']=="4" and $_POST['t39']==''){
//
//echo alert_js("POR FAVOR SELECCIONE AGENCIA");
            }//elseif($_POST['t33']=="GRUPOS EMPRESA" and $_POST['t39']==''){
//echo alert_js("POR FAVOR SELECCIONE AGENCIA");
//}
            elseif ($_POST['t53'] == "-----SELECCIONE-----") {
                echo alert_js("SELECCIONE EL TIPO DE PLAN");
            } elseif ($_POST['t52'] == "-----SELECCIONE-----") {
                echo alert_js("SELECCIONE EL TIPO DE SEGMENTO");
            } elseif ($_POST['t68'] == "-----SELECCIONE-----") {
                echo alert_js("SELECCIONE LA FORMA DE PAGO");
            } elseif($_POST['ingHab1'] == "0" && $_POST['ingHab2'] == "0"&& $_POST['ingHab3'] == "0" && $_POST['ingHab4'] == "0"  && $_POST['ingHab5'] == "0" && $_POST['ingHab6'] == "0" && $_POST['ingHab7'] == "0"){
       echo alert_js("DEBE HABER MAS DE UNA HABITACION SELECCIONADA");

}else{

include("res_grupos_AC.php");
exit;
}
//window.location.href="DZA11112.php";
        }
        ?>
<html>
    <title>CENTRO COSTOS</title>

    <link rel="stylesheet" href="css/estilo1.css?1" 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 type="text/javascript" language="JavaScript1.2" src="GRSCRIPT.js?4"></script>
<script type="text/javascript" language="JavaScript1.2" src="js/DireccionesCP.js"></script>


<script language="javascript">
function restaFecha()
 {
var d1 = $('#ffecllegada').val().split("/");
  var dat1 = new Date(d1[2], parseFloat(d1[1])-1, parseFloat(d1[0]));
 var d2 = $('#ffecsalida').val().split("/");
 var dat2 = new Date(d2[2], parseFloat(d2[1])-1, parseFloat(d2[0]));
 var fin = dat2.getTime() - dat1.getTime();
    var dias =  Math.abs(Math.ceil(fin / (1000 * 60 * 60 * 24))); 
//   //return dias
$("#fnumctos").val(dias);


   if(dias<1){
	   alert('fechas invalidas');
	   $('#ffecsalida').val('');
   }
 }
</script>
    <style type="text/css">
        .Estilo16{
            color:#ccc;
        }

    </style>	 
    <script language="javascript">
        function llenar()
        {
            if (document.getElementById("t66").value != '------------------SELECCIONE------------------') {
                document.getElementById("t3").value = document.getElementById("t66").value;
                document.getElementById("t4").value = document.getElementById("t66").value;
            }
        }
    </script>
    <body onLoad="llenar(); restaFecha(); clear();" onmousemove="restaFecha()">
        <section id="wrapper">
            <form name='frm1' id="frm1" method='post'>
                <?php
                for ($j = 0; $j <= 119; $j++) {
                    //$c[]= "t" . $j;
                    //echo '<input name="' . $c[$j] . '" type="hidden" value="' . $_POST[$c[$j]] .'">';
                    $c[$j] = "t" . $j;
                    $value = (isset($_POST[$c[$j]])) ? $_POST[$c[$j]] : "0";
                    echo '<input name="' . $c[$j]
                    . '" type="hidden" value="' . $value . '">';
                }
                ?>
                <fieldset class="personal-data">
                    <!--<table border="0" align="center">
                        <tr>
                            <td class="looo">NOMBRE DEL GRUPO-->
                                <!--<select name="t66" id="t66" required tabindex="1" onclick="llenar();" >
                                    <option value="">------------------SELECCIONE------------------</option>
                                    <?php
                                    /*$sql = mysqli_query($con ,"SELECT * FROM valeryus04  where gdescrip not in (SELECT fcodgrupo FROM valeryus19 WHERE status='RESERVA GRUPO' AND cancelado='0') and gfechallegada>=date(now())");
                                    while ($reg = mysqli_fetch_array($sql)) {
                                        if ($_POST['t66'] == $reg['gdescrip']) {
                                            echo '<option value="' . $reg['gdescrip'] . '" selected>' . $reg['gdescrip'] . '</option>';
                                        } else {
                                            echo '<option value="' . $reg['gdescrip'] . '">' . $reg['gdescrip'] . '</option>';
                                        }
                                    }*/
                                    ?>
                                </select>-->
                               <!-- <span class="Estilo18">
                                    <input name="tap2" type="text" placeholder="Nombre Grupo">-->
<!--                                    <input name="b1" type="text" value="Nuevo Grupo" class="bot_ZaZ" onClick="openpage('res_grupos_GR.php', '_self')">-->
                                <!--</span></td>
                        </tr>
                    </table>-->


                    <table width="652" border="0" align="center">
                        <tr>
                            <td colspan="4" class="titulo"><div align="center">AGREGAR REGISTRO DE RESERVACIONES DE GRUPO </div>    </tr>

                        <tr>
                            <th  ><span class="Estilo18">HORA DE LLEGADA</span></th>
                            <td colspan="1" style="#FFF"><input name="fhorallega" type="text" class="tdan" id="fhorallega" value="<?php echo date('H:i:s') ?>"size="9" ></td>
                            <th width="118"  ><span class="Estilo18">NOMBRE DEL GRUPO</span></th>
                            <td width="196" style="#FFF">
                                <input required name="tap2" id="tap2" 
                                          onBlur="may(this)"><?php
                                              if (isset($_POST['tap2'])) {
                                                  echo $_POST['tap2'];
                                              }
                                ?>	  </td>
                        </tr>
                        <tr>
                            <th  ><span class="Estilo18">NUMERO ADULTOS</span></th>
                            <td style="#FFF"><input required name="t25" id="t25" type="text" size="5"  maxlength="15" tabindex="2" 
                                <?php
                                if (isset($_POST['t25'])) {
                                    echo 'value="' . $_POST['t25'] . '"';
                                }
                                ?> onKeyPress="return soloNumeros(event)"/></td>
                            <th  ><span class="Estilo18">NUMERO MENORES</span></th>
                            <td width="200" style="#FFF"><input required name="t24" id="t24" type="text" size="5" maxlength="20" tabindex="3"
                                <?php
                                if (isset($_POST['t24'])) {
                                    echo 'value="' . $_POST['t24'] . '"';
                                }
                                ?> onKeyPress="return soloNumeros(event)"/></td>
                        </tr>
                        <tr>
                            <th width="118"  ><span class="Estilo18">NOMBRE</span></th>
                            <td width="196" style="#FFF">
                                <textarea required name="t3" cols="25" rows="3" id="t3" tabindex="4"
                                          onBlur="may(this)"><?php
                                              if (isset($_POST['t3'])) {
                                                  echo $_POST['t3'];
                                              }
                                              ?></textarea>	  </td>
                            <th width="120"  ><span class="Estilo18">APELLIDO</span></th>
                            <td style="#FFF">
                                <textarea required name="t4" cols="25" rows="3" id="t4" tabindex="5"
                                          onBlur="may(this)"><?php
                                              if (isset($_POST['t4'])) {
                                                  echo $_POST['t4'];
                                              }
                                              ?></textarea>	  </td>
                        </tr>
                        <tr>
                            <th  ><span class="Estilo18">TIPO DE HUESPED</span></th>
                            <td colspan="3" style="#FFF"><select required name="t21" tabindex="6">
                                    <option value=""  selected>-----SELECCIONE-----</option>
                                    <?php
                                    echo '<option></option>';
                                    @$resultado1 = mysqli_query($con ,"select * from tiphuesped");
                                    while ($registro1 = mysqli_fetch_array($resultado1)) {
                                        if ($_POST['t21'] == $registro1['tpdescrip']) {
                                            echo '<option value="' . $registro1['tpdescrip'] . '" selected>' . $registro1['tpdescrip'] . '</option>';
                                        } else {
                                            echo '<option value="' . $registro1['tpdescrip'] . '">' . $registro1['tpdescrip'] . '</option>';
                                        }
                                    }
                                    ?>
                                </select></td>
                        </tr>
                        <tr>
                            <th  ><span class="Estilo18">TELEFONO</span></th>
                            <td style="#FFF"><input  name="t16" type="text" size="28" maxlength="10" tabindex="7"
                                <?php
                                if (isset($_POST['t16'])) {
                                    echo 'value="' . $_POST['t16'] . '"';
                                }
                                ?>/></td>
                            <th  ><span class="Estilo18">TELEFONO EMPRESA</span></th>
                            <td style="#FFF"><input  name="t9" type="text" tabindex="8" size="28"
                                <?php
                                if (isset($_POST['t9'])) {
                                    echo 'value="' . $_POST['t9'] . '"';
                                }
                                ?>/></td>
                        </tr>
                        <tr>
                            <th  ><span class="Estilo18">E-MAIL</span></th>
                            <td style="#FFF"><input  name="t5" type="text" id="t5" size="28" tabindex="9"
                                <?php
                                if (isset($_POST['t5'])) {
                                    echo 'value="' . $_POST['t5'] . '"';
                                }
                                ?>/></td>
                            <th  ><span class="Estilo18">E-MAIL EMPRESA</span></th>
                            <td style="#FFF"><input  name="t30" type="text" tabindex="10" size="28"
                                <?php
                                if (isset($_POST['t30'])) {
                                    echo 'value="' . $_POST['t30'] . '"';
                                }
                                ?> /></td> 
                        </tr>


                        <tr> 
                            <td colspan="4" class="titulo">
                                <div align="center">

                                    <input name="Submit2" type="button" class="bot_WsW" onClick="openpage('res_grupos_PR.php', '_self')" value="Regresar" tabindex="12">
                                </div></td></tr>
                    </table>
                </fieldset>
                <fieldset class="personal-data">
                    <table width="722" border="0" align="center">
                        <tr>
                            <td colspan="6" class="titulo"><div align="center">AGREGAR SEGMENTOS </div></td>
                        </tr>
                        <tr>
                            <th width="85"  ><span >MERCADO</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo17">
                                    <select name="t33" required id="t33" tabindex="3">
                                        <option value="" selected>-----SELECCIONE-----</option>
                                        <?php
                                        @$resultado1 = mysqli_query($con ,"select * from tipmerca order by tdescrip");
                                        while ($registro1 = mysqli_fetch_array($resultado1)) {
                                            if ($_POST['t33'] == $registro1['tdescrip']) {
                                                echo '<option value="' . $registro1['tdescrip'] . '" selected>' . $registro1['tdescrip'] . '</option>';
                                            } else {
                                                echo '<option value="' . $registro1['tdescrip'] . '">' . $registro1['tdescrip'] . '</option>';
                                            }
                                        }
                                        ?>
                                    </select>  




                                </span></td>
                            <th width="101"  ><span >EMPRESA</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo18">
                                    <select name="t38" id="t38"  tabindex="2">
                                        <option value="">-----SELECCIONE-----</option>
                                        <?php
                                        @$resultado1 = mysqli_query($con ,"select * from fcompas");
                                        while ($registro1 = mysqli_fetch_array($resultado1)) {
                                            if ($_POST['t38'] == $registro1['pdesco']) {
                                                echo '<option value="' . $registro1['pdesco'] . '"selected>' . $registro1['pdesco'] . '</option>';
                                            } else {
                                                echo '<option value="' . $registro1['pdesco'] . '">' . $registro1['pdesco'] . '</option>';
                                            }
                                        }
                                        ?>
                                    </select>
                                </span></td>
                        </tr>
                        <tr>
                            <th  ><span >SEGMENTO</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo18">
                                    <select required name="t52" id="t52"  tabindex="6">
                                        <option value="">-----SELECCIONE-----</option>
                                        <?php
                                        @$resultado1 = mysqli_query($con ,"SELECT * FROM valeryus06 order by descripcion");
                                        while ($registro1 = mysqli_fetch_array($resultado1)) {
                                            if ($_POST['t52'] == $registro1['descripcion']) {
                                                echo '<option value="' . $registro1['descripcion'] . '"selected>' . $registro1['descripcion'] . '</option>';
                                            } else {
                                                echo '<option value="' . $registro1['descripcion'] . '">' . $registro1['descripcion'] . '</option>';
                                            }
                                        }
                                        ?>
                                    </select>
                                </span></td>
                            <th  ><span >PLAN</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo18">
                                    <select required name="t53" id="t53"  tabindex="4">
                                        <option value="">-----SELECCIONE-----</option>
                                        <?php
                                        @$resultado1 = mysqli_query($con ,"SELECT * FROM pplan");
                                        while ($registro1 = mysqli_fetch_array($resultado1)) {
                                            if ($_POST['t53'] == $registro1['pdescrip']) {
                                                echo '<option value="' . $registro1['pdescrip'] . '"selected>' . $registro1['pdescrip'] . '</option>';
                                            } else {
                                                echo '<option value="' . $registro1['pdescrip'] . '">' . $registro1['pdescrip'] . '</option>';
                                            }
                                        }
                                        ?>
                                    </select>
                                </span></td>
                        </tr>
                        <tr>
                            <th  ><span >SMERF</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo17">
                                    <select name="t56" id="t56" tabindex="5">
                                        <option selected>-----SELECCIONE-----</option>
                                        <?php
                                        @$resultado1 = mysqli_query($con ,"SELECT * FROM fsmerf");
                                        while ($registro1 = mysqli_fetch_array($resultado1)) {
                                            if ($_POST['t56'] == $registro1['descripcion']) {
                                                echo '<option value="' . $registro1['descripcion'] . '" selected>' . $registro1['descripcion'] . '</option>';
                                            } else {
                                                echo '<option value="' . $registro1['descripcion'] . '">' . $registro1['descripcion'] . '</option>';
                                            }
                                        }
                                        ?>
                                    </select>
                                </span></td>
                            <th  ><span >AGENCIA</span></th>
                            <td colspan="3"  ><span class="Estilo18">
                                    <select name="t39" id="t39"  tabindex="8">
                                        <option value="">--SELECCIONE--</option>
                                        <?php
                                        $sql = mysqli_query($con ,"SELECT * FROM valeryus07 order by agdescrip");
                                        while ($reg = mysqli_fetch_array($sql)) {
                                            if ($_POST['t39'] == $reg['agdescrip']) {
                                                echo '<option value="' . $reg['agdescrip'] . '" selected>' . $reg['agdescrip'] . '</option>';
                                            } else {
                                                echo '<option value="' . $reg['agdescrip'] . '">' . $reg['agdescrip'] . '</option>';
                                            }
                                        }
                                        ?>
                                    </select>
                                </span></td>
                          <!--      <th  ><span >AGENCIA</span></th>-->
                          <!--      <td colspan="2" style="#FFF"><span class="Estilo17">
                                  <input name="id_agen" type="hidden" id="id_agen" size="2" value="<?php
//se debe llenar este id desde el autocomplete obiamente no se manda a gurdar con la descripcion
                            //pon atencion pinche escrapo
//							if(isset($_POST['id_agen']))
//						echo $_POST['id_agen']; 
                            ?>" />
                                  <input name="t39" type="text" id="t39" size="40" value="<?php
//  echo  (isset($_POST['t39']))?$_POST['t39']:"";     
//echo trim((isset($_POST['t39']))?$_POST['t39']:"" );
                            ?>" />
                                </span></td>-->
                        </tr>

                        <tr>
                            <td colspan="6" class="titulo"><div align="center">AGREGAR TARIFAS Y FORMA DE PAGO</div></td>
                        </tr>
                        <tr>
                            <th  ><span >FORMA DE PAGO</span></th>
                            <td colspan="2" style="#FFF"><select required name="t68" id="t68" tabindex="7">
                                    <option value="">-----SELECCIONE-----</option>
                                    <?php
                                    $sql = mysqli_query($con ,"SELECT * FROM valeryus09 WHERE pmontomax = 'ABONO' AND ppago = 'SI'");
                                    while ($reg = mysqli_fetch_array($sql)) {
                                        if ($_POST['t68'] == $reg['descripcion']) {
                                            echo '<option value="' . $reg['descripcion'] . '" selected>' . $reg['descripcion'] . '</option>';
                                        } else {
                                            echo '<option value="' . $reg['descripcion'] . '">' . $reg['descripcion'] . '</option>';
                                        }
                                    }
                                    ?>
                                </select></td>
                            <th  ><span >NUMERO DE TARJETA</span></th>
                            <td colspan="2" style="#FFF"><input name="t43" type="text" tabindex="8" onKeyPress="return soloNumeros(event)" size="25"
                                <?php
                                if (isset($_POST['t43'])) {
                                    echo 'value="' . $_POST['t43'] . '"';
                                }
                                ?>/></td>
                        </tr>
                        <tr>
                            <th  ><span >CODIGO DE SEGURIDAD</span></th>
                            <td width="198" style="#FFF"><input name="t37" type="text" tabindex="9" onKeyPress="return soloNumeros(event)" size="15"
                                <?php
                                if (isset($_POST['t37'])) {
                                    echo 'value="' . $_POST['t37'] . '"';
                                }
                                ?>/></td>
                            <th width="52"  ><span >LIMITE</span></th>
                            <td style="#FFF"><input name="t58" type="text" tabindex="10" size="10" maxlength="10"
                                <?php
                                if (isset($_POST['t58'])) {
                                    echo 'value="' . $_POST['t58'] . '"';
                                }
                                ?> onKeyPress="return soloNumeros(event)"/></td>
                            <th width="65"  ><span >SALDO</span></th>
                            <td width="181" style="#FFF"><input name="t35" type="text" onKeyPress="return validar(event)" size="10" maxlength="5" tabindex="11"
                                <?php
                                if (isset($_POST['t33'])) {
                                    @$resultado1 = mysqli_query($con ,"select * from dxcoloni where cve_col='" . $_POST['t33'] . "'");
                                    while (@$registro1 = mysqli_fetch_array($resultado1)) {
                                        echo ' value="' . $registro1['cod_pos'] . '"';
                                    }
                                }
                                ?>/></td>
                        </tr>
                        <tr>
                            <td colspan="6" class="titulo">NOTAS</td>
                        </tr>
                        <tr>  
                            <td colspan="6" style="#FFF">
                                <div align="center">
                                    <textarea name="t60" cols="80" rows="4" id="t60" tabindex="12"
                                              onBlur="may(this)"><?php
                                                  if (isset($_POST['t60'])) { //este es el truco
                                                      echo $_POST['t60'];
                                                  }
                                                  ?>
                                    </textarea>
                                </div></td>
                        </tr>

                    </table>

                </fieldset>

                <fieldset class="personal-data">
                    <table width="774" border="0" align="center">
                        <tr>
                            <td colspan="6" class="titulo"><div align="center">AGREGAR DIRECCION DEL GRUPO. </div></td>
                        </tr>

                        <tr>
                            <th width="121" style="#000"><span >DIRECCION</span></th>
                            <td colspan="2" style="#FFF" class="Estilo18"><span class="Estilo18">
                                  
                                </span></td>
                            <th style="#000"><span >CODIGO POSTAL</span></th>
                            <td colspan="2" style="#FFF"><input name="tcp" id="tcp" type="text" onKeyPress="return validar(event)" value="<?php echo (isset($_REQUEST['tcp'])) ? $_REQUEST['tcp'] : "0"; ?>" size="8" maxlength="5" tabindex="27"></td>
                        </tr>
                        <tr>
                            <th style="#000"><span >COLONIA</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo1">
                                    <input type="hidden" name="tcol1" id="tcve" value="<?php echo (isset($_REQUEST['tcve'])) ? $_REQUEST['tcve'] : "0";
                                                  ;
                                                  ?>">
                                    <input name="tcol" type="text" id="tcol" value="<?php echo (isset($_REQUEST['tcol'])) ? $_REQUEST['tcol'] : "0"; ?>" size="25" tabindex="26">
                                </span></td>

                            <th style="#000"><span >PAIS</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo1">
                                    <select name="pais" id="pais"    onClick="clear()" tabindex="28">                                       
                                        <option value="">-----SELECCIONE-----</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>
                        </tr>
                        <tr>
                            <th style="#000"><span >ESTADO</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo1">
                                    <select name="estados" id="estados"  tabindex="29">
                                        <option  value="">-----SELECCIONE-----</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>
                            <th style="#000"><span >DELEGACION O MUNICIPIO</span></th>
                            <td colspan="2" style="#FFF"><span class="Estilo1">
                                    <select name="tmun" id="tmun" tabindex="30" >
                                        <option  value="">-----SELECCIONE-----</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>

                            <td colspan="6" class="titulo"><div align="center">AGREGAR TARIFA. </div></td>
                              <!--<th colspan="6" >AGREGAR TARIFA. </th>-->
                        </tr>
                        <tr>
                            <th style="#000"><span >FECHA DE LLEGADA </span></th>
                                <?php $fec = (isset($dt_alta['fec_alta'])) ? $dt_alta['fec_alta'] : date('d/m/Y'); ?>
                            <td colspan="2" style="#FFF"><input name="ffecllegada" type="text" class="emplea datefrom" id="ffecllegada" size="8" value="<?= $fec ?>"
                                <?php
                                $fecha = $dt_empres['fec_alta'];
                                $fechita = chfecha($fecha, 'Y-m-d', 'd/m/Y');
                                if (isset($$fechaInicial))
                                    echo 'value="' . $fechaInicial . '"';
                                else
                                    echo 'value="' . $fechita . '"';
                                ?>>
                            </td>
                            <th style="#000"><span ><strong>DIAS.</strong></span></th>
                            <td colspan="2" style="#FFF">
                                <input name="fnumctos" id="fnumctos" value="<?php echo (daydiff($varf2, $fechaInicial, 'd/m/Y')); ?>" type="text" size="5" READONLY></td>
                        </tr>
                        <tr>
                            <th style="#000"><span >FECHA DE SALIDA </span></th>
                            <td colspan="5" style="#FFF">
                                <input name="ffecsalida" type="text" class="emplea dateto" id="ffecsalida" size="8" onChange="restaFecha()"
                                <?php
                              	$fecha = $dt_empres['fec_alta'];
	          $fecha1 = date_create($fecha);
date_add($fecha1, date_interval_create_from_date_string('2 day'));
 echo 'value="' .date_format($fecha1, 'd/m/Y').'"';
                                ?>
                                       >
                            </td>
                        </tr>
                        <tr>
<?php $lkjsa = daydiff($varf2, $fechaInicial, 'd/m/Y'); ?>
                            <th style="#000"><span >


                                    <strong> TARIFA </strong> </span></th>
                            <td colspan="6" style="#FFF">        
                                <input name="tex" type="text" required="" id="tex" size="3" value="<?php echo (isset($_REQUEST['tex'])) ? $_REQUEST['tex'] : "0"; ?>" />
                                <input name="tex2" type="text" id="tex2" size="20" value="<?php echo (isset($_REQUEST['tex2'])) ? $_REQUEST['tex2'] : "0"; ?>" 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'] == 'SI' and $reg['manual'] == '1') {
                                    ?>
                                    <input name="tex4" type="text" id="tex4" size="5" value="<?php
                                    if ($_REQUEST['tex4'] != '') {
                                        echo $_REQUEST['tex4'];
                                    } else {
                                        echo '0';
                                    }
                                    ?>" onMouseOver="restaTex()" />
                                <?php } else {
                                    ?>
                                    <input name="tex4" type="text" id="tex4" size="5" value="<?php
                                           if (isset($_REQUEST['tex4']) && $_REQUEST['tex4'] != '') {
                                               echo $_REQUEST['tex4'];
                                           } else {
                                               echo '0';
                                           }
                                           ?>" onMouseOver="restaTex()" READONLY>
                                <?php }
                                ?>



                                <input name="tex5" type="text" id="tex5" size="3" value="<?php
                                if (isset($_POST['check']) && $_POST['check'] == 1 && $_POST['check_baja'] == 1) {
                                    if ($sabd != '') {
                                        echo "" . $sabd . "";
                                    } else {
                                        echo '0';
                                    }
                                } else {
                                    if ($lkjsa != '') {
                                        echo "" . $lkjsa . "";
                                    } else {
                                        echo '0';
                                    }
                                }
                                ?>" onMouseMove="restaTex()" READONLY>
                                =<span class="Estilo17"><strong>$</strong></span>
                                <input name="tex6" type="text" id="tex6" size="8" onMouseMove="restaTex()" value="<?php echo (isset($_REQUEST['tex6'])) ? $_REQUEST['tex6'] : "0";
                                ;
                                ?>" READONLY>
                                <!--input name="?322" type="button" class="pp" tabindex="12" onClick="
                                        openWindow(
                                        {
                                                action:'rec_chin_AG2.php',
                                                width:700,
                                                height:350
                                        },{
                                                val:'tex',
                                                des:'tex2',
                                                jio:'tex3',
                                                kji:'tex4'
                                        })" value="Buscar"-->        </td>    

                        </tr>



                        <?php
//CHECAR CONEXION A LA BASE DE DATOS
//include("DMMYSQLG.php");
//FECHAS DEL CALENDARIO
                        $fec = $fechaInicial;
                        include('DF20000.php');
                        $fecha_inicial = $f_m;
                        $fec = $varf2;
                        include('DF20000.php');
                        $fecha_final = $f_m;


                        $proXlin = 2;
                        $auxNumLin = -1;
                        @$resultado = mysqli_query($con ,"SELECT * FROM valeryus05 where clavetp <> 'MTA' order by n_reg");
                        echo mysqli_error($con);
                        $g = 1;
                        $count = mysqli_num_rows($resultado);
                        while (@$registro = mysqli_fetch_array(@$resultado)) {
                            if (!isset($dt_invent['ncto']))
                                $dt_invent['ncto'] = "";
                            $sqb = mysqli_query($con ,"SELECT * FROM valeryus19 where status='HUESPED' and fnumcto= '" . $dt_invent['ncto'] . "'");
                            $reb = mysqli_fetch_array($sqb);

                            $auxNumLin++;
                            if ($auxNumLin == -1 || $auxNumLin % $proXlin == 0) {
                                if ($auxNumLin == -1) {
                                    echo "<tr>";
                                } else {
                                    echo "</tr><tr>";
                                }
                            }

                            $ToT = $registro['totalcuartos'];
                            $TiPo = $registro['descripcion'];

                            $XoXo = mysqli_query($con ,"SELECT * FROM valeryus19 WHERE (ffecllegada <= '" . $fecha_inicial . "' AND ffecsalida > '" . $fecha_inicial . "' and ftipocto = '" . $TiPo . "' and status <> 'HISTORICO' and cancelado = '0') or (ffecllegada < '" . $fecha_final . "' AND ffecsalida >= '" . $fecha_final . "' and ftipocto = '" . $TiPo . "' and status <> 'HISTORICO' and cancelado = '0') or (ffecllegada > '" . $fecha_inicial . "' AND ffecsalida < '" . $fecha_final . "' and ftipocto = '" . $TiPo . "' and status <> 'HISTORICO' and cancelado = '0') ");
                            $i = 0;
                            while ($as = mysqli_fetch_array($XoXo)) {
                                $OCU = $as['fnumcto'];
                                $i++;
                            }

                            $aMa = mysqli_query($con ,"SELECT * FROM valeryusst08 WHERE (fec_ini <= '" . $fecha_inicial . "' AND fec_fin > '" . $fecha_inicial . "' and ftipocto = '" . $TiPo . "' ) or (fec_ini < '" . $fecha_final . "' AND fec_fin >= '" . $fecha_final . "' and ftipocto = '" . $TiPo . "' ) or (fec_ini > '" . $fecha_inicial . "' AND fec_fin < '" . $fecha_final . "' and ftipocto = '" . $TiPo . "') ");
                            $a = 0;
                            while ($status = mysqli_fetch_array($aMa)) {
                                $desocupadas = $status['fnumcto'];
                                //echo "-".$BLOQUEADAS."";
                                $a++;
                            }

                            $rEs = $ToT - $i - $a;

                            echo '<input name="ver1" type="hidden" value="' . $registro['descripcion'] . '">';

                            echo "<th style='#000'><span class='Estilo19'>";

//		echo "<input name='box$g' type='checkbox' value='1' onClick='openhab(this,$g)'"; 
//	 //  if(!isset($_REQUEST['box']))$_REQUEST['box']="";
//		echo 'checked';
//		
//		echo " />";

                            echo "<input name='nreg$g' id='nreg$g' value='" . $registro['n_reg'] . "' type='hidden' size='5'/>";
                            echo "<input name='tipo$g' id='tipo$g' value='" . $registro['descripcion'] . "' type='hidden' size='20'/>";

                            echo "<em> Hay " . $rEs . " Habitaciones " . $registro['descripcion'] . " desocupadas </em></th>";

                            echo "<td width='130' style='#FFF'><span class='Estilo19'>";

                            //echo "<input name='ingHab$g' type='text' tabindex='1' size='25' maxlength='10' value='" . $_POST["ingHab" . $g] .  "' /> ";
                            echo $_POST['ingHab' . $g];
                            echo "<input onClick='openhabinput($g)' class='txthab' readonly name='ingHab$g' id='ingHab$g' type='text' tabindex='1'   onKeyPress='return soloNumeros(event)' ";

                            if (isset($_POST['ingHab' . $g]) && $_POST['ingHab' . $g] != "0") {
                                echo 'value="' . $_POST["ingHab" . $g] . '" />';
                            } else {
                                echo 'value="0"  />';
                            }
                            echo "</span></td>";

                            $g++;
                        }

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
                        ?>				

                        <tr>
                            <th width="154" style="#000"><span class="Estilo19"><strong>CANTIDAD DE HABITACIONES</strong> </span></th>
                            <td colspan="3"><input name="campo90" id="campo90" type="text" size="10" maxlength="5" id="campo90" 
<?php
if (isset($_POST['campo90'])) { //este es el truco
    echo 'value="' . $_POST['campo90'] . '"';
}
?>/></td>
                        </tr>
                        <tr>
                            <td colspan="6"><div align="center">
                                    <!--input type="button" name="Submit2" value="Regresar al Principio" onClick="openpage('valeryus40010_PR.php','_self')"-->
                                </div></td>
                        </tr>
                    </table>
                </fieldset>
            </form> 
        </section>
       
    </body>
</html>
<script language="javascript">
    $("#frm1").simpleform({
        speed: 1000,
        transition: 'other',
        progressBar: true,
        showProgressText: true,
        validate: true
    });

$( "#tap2" ).keypress(function() {
	$( "#t3" ).val($("#tap2").val());
	$( "#t4" ).val($("#tap2").val());
});
    function validateForm(formID, Obj) {

        // If the form is invalid, submit it. The form won't actually submit;
        // this will just cause the browser to display the native HTML5 error messages.
       
        switch (formID) {
            case 'frm1' :
                segmento=$('#t52').val();
                     if (segmento == "AGENCIAS" || segmento== "GRUPOS-AGENCIAS"|| segmento== "ONLINE"  ) {
                           $('#t39').attr("required","required") 
                     }else{
                          $('#t39').removeAttr("required");
                     }
                      document.forms["frm1"].checkValidity()
                return Obj.valid() ;
                break;
        }
    }

</script>
