<?php
 
session_start();
$com = "M";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DF30000.inc");
include("DF80000.php");
include ("varfun.php");
include("JQUERY.inc");
//include("DIF_FECHAS.php");
$Segundos=0;
$val1=0;
$val2=0;
$f_f="";
$cuenta=0;
?>
<html>
    <head>


<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="RSSCRIPT.js"></script>
<script language="javascript">
//function openWindow(dataGen,valores){
//	var objDate=document.getElementById('ffecllegada');
//	var objDate2=document.getElementById('ffecsalida');	
//	var getVars,getVarsAux,distPage;
//	var idVentana;
//	for(getVarsAux in valores){
//		getVars +='&'+getVarsAux+'='+valores['getVarsAux'];
//	}
//	if(typeof dataGen.width=='undefined') dataGen.width='800';
//	if(typeof dataGen.height=='undefined') dataGen.height='600';
//	distPage='&feclle='+objDate.value;
//	distPage2='?fecsal='+objDate2.value;
//	idVentana=window.open(dataGen.action+distPage2+distPage+'&'+getVars,dataGen.name,'width='+dataGen.width+',height='+dataGen.height+',top=100,left=50,scrollbars=yes,menubar=yes,status=yes');
//	return idVentana;
//}

function sumaTex(){
	var objTex1=document.getElementById('tex4'),
		objTex2=document.getElementById('tex5'),
		objTex3=document.getElementById('tex6');
	objTex3.value=(parseFloat(objTex1.value)*parseFloat(objTex2.value)).toFixed(2);
}
function restaTex(){
	var objTex1=document.getElementById('text4'),
		objTex2=document.getElementById('text5'),
		objTex3=document.getElementById('text6');
	objTex3.value=(parseFloat(objTex1.value)*parseFloat(objTex2.value)).toFixed(2);
}
function totalTex(){
	var objTex1=document.getElementById('tex6'),
		objTex2=document.getElementById('text6'),
		objTex3=document.getElementById('ftotal');
	objTex3.value=(parseFloat(objTex1.value)+parseFloat(objTex2.value)).toFixed(2);
}
</script>
    </head>
<?php

if(isset($_POST["fnumctos"]) && $_POST["fnumctos"] == ""){		
		"<script languaje=\"javascript\"> javascript:document.getElementById('frm1').submit();</script>";
	
	}
if ($_POST['bot']==""){
	echo '<div align="center"><h2>!!! SELECCIONE UN REGISTRO !!!</h2></div>';
	echo '<meta content="1; url=res_consulta_PR.php"  HTTP-EQUIV="REFRESH">';

}else{
	//$sql="UPDATE valeryus19 SET ffecllegada='', ffecsalida='' WHERE n_reg ='".$_POST['bot']."'";
	//if (!mysqli_query($con ,$sql)){
		//die('Error: ' . mysqli_error($con));
		//exit();
//	}
	include('rec_checkin_CL.php');
	$varible_clase = new clase();
	$res=$varible_clase->lista_busqueda($_POST["bot"]);
	$reg=mysqli_fetch_array($res);
	if(!isset($_POST['fnombre'])){
	$_REQUEST['fcodtarifa']=$reg['fcodtarifa'];
	$_REQUEST['fnumres']=$reg['fnumres'];
	$_REQUEST['fnumcto']=$reg['fnumcto'];
	$_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'];
	//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['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['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'];
	}
?>
<?php


?>

<body onLoad="sumaTex();restaTex();totalTex();">
<form  name="frm1" method="post" id="frm1" action="" enctype="multipart/form-data">
<input name="bot" type="hidden" value="<?php
 echo $_POST["bot"]?>">
<?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 rec_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');	
?>
<table width="1059"  align="center" onMouseOver="sumaTex();restaTex();totalTex();">
  <tr><th colspan="14" class=\"titulo\"><div align="center"> MODIFICAR REGISTRO DE RESERVACIONES INDIVIDUALES. </div></th></tr>
  <tr>
    <td width="60"><strong>ALTA:</strong></td>
    <td width="48"><!--input name="ffecalt" type="text" id="ffecalt" size="7" disabled="disabled" value="<?php //echo $_REQUEST['ffecalt'];?>"-->
	  <input name="ffecalt" type="text" id="ffecalt"  class="styTabEspA" disabled="disabled" size="7"
	  <?php
 
		if(isset($_POST['bot'])){
		$fec1=$reg["ffecalt"];
		include('DF20000.php');
		echo 'value="'.$f_f.'"';
		}
		?>/></td>
    <td width="114"><input name="fusualta" type="text" disabled="disabled" id="fusualta" size="16"
	  <?php
 
		if(isset($_POST['bot'])){
		echo 'value="'.$reg['fusualta'].'"';
		}
		?>></td>
    <td colspan="2"><strong>ULTIMO CAMBIO:</strong></td>
    <td colspan="4"><input name="ffeccam" type="text" class="styTabEspA" id="ffeccam" size="7" disabled="disabled"
	<?php
 
		if(isset($_POST['bot'])){
		$fec1=$reg["ffeccam"];
		include('DF20000.php');
		echo 'value="'.$f_f.'"';
		}
		?>>      
	<input name="fusucamb" type="text" id="fusucamb" disabled="disabled" size="12"
	<?php
 
		if(isset($_POST['bot'])){
		echo 'value="'.$reg['fusucamb'].'"';
		}
		?>></td>
    <td width="97"><strong>FOLIO.</strong></td>
    <td colspan="3"><input name="ffecalt2" type="text" id="ffecalt2"  class="styTabEspA" disabled="disabled" size="7"
	  <?php
 
		if(isset($_POST['bot'])){
		echo 'value="'.$reg['n_reg'].'"';
		}
		?>/></td>
    <td width="106"></td>
  </tr>
  <tr><td colspan="2"><strong>FECHA DE LLEGADA: </strong></td>
    <td>
	  <input name="ffecllegada" type="text" id="ffecllegada" class="emplea datefrom" size="10"  value="<?php echo $_REQUEST['ffecllegada'];?>" >
	  
       	  </td>
    <td colspan="2"><strong>DIAS:</strong></td>
    <td colspan="2"><input name="fnumctos" type="text" id="fnumctos" tabindex="20" size="15" value="<?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); 
$dias = ($fecha - $hoy )/(60 * 60 * 24) ; 
echo  $dias; 
	?>" READONLY></td>
	<td colspan="4">
        <label>
        <div align="center"><span class="Estilo1">
          <input name="?323" type="button" class="tragre" 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"><div align="center" class="Estilo18">NOTAS:</div></td>
  </tr>
  <tr>
    <td colspan="2"><strong>FECHA DE SALIDA: </strong></td>
    <td><input name="ffecsalida" type="text" id="ffecsalida" class="emplea dateto" size="10"  value="<?php echo $_REQUEST['ffecsalida'];?>" >
        </td>
    <td colspan="2"><strong>NUMERO DE ADULTOS: </strong></td>
    <td colspan="2"><input name="fnumadu" type="text" id="fnumadu" tabindex="1" onKeyPress="return validar(event)" size="5"  value="<?php echo $_REQUEST['fnumadu'];?>"></td>
    <td colspan="2"><strong>TIPO DE HABITACION: </strong></td>
    <td colspan="2"><input name="ftipocto" type="text" id="ftipocto" value="<?php echo $_REQUEST['ftipocto'];?>" READONLY></td>
    <td colspan="2" rowspan="2"><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>
    <td colspan="2"><strong>HORA DE LLEGADA: </strong></td><?php
   $varfh=(isset($_REQUEST['fhorallega']))?$_REQUEST['fhorallega']:""; ?>
    <td><input name="fhorallega" type="text" disabled="disabled" class="styTabEspA" id="fhorallega" onKeyPress="return validar(event)"  value="<?php
    echo $varfh ;?>" size="6"></td>
    <td colspan="2"><strong>NUMERO DE MENORES: </strong></td>
    <td colspan="2"><input name="fnummenor" type="text" id="fnummenor" tabindex="2" onKeyPress="return validar(event)" size="5"  value="<?php echo $_REQUEST['fnummenor'];?>"></td>
    <td colspan="2"><strong>NUMERO DE HABITACION: </strong></td>
    <td colspan="2"><input name="fnumcto" type="text" id="fnumcto" tabindex="20" size="5"  value="<?php echo $_REQUEST['fnumcto'];?>" READONLY></td></tr>
  <tr><th colspan="14" class="titulo"><div align="center" class="Estilo18">MODIFICAR DATOS </div></th></tr>
  <tr>
    <td><span class="Estilo18"><strong>GRUPO:</strong></span></td>
    <td colspan="4"><span class="Estilo18">
      <select name="fcodgrupo" id="fcodgrupo" tabindex="5">
        <option value="">----------SELECCIONE----------</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM valeryus04");
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 colspan="2"><span class="Estilo18"><strong>MERCADO:</strong></span></td>
    <td colspan="4"><span class="Estilo18">
      <select name="fcodmeca" id="fcodmeca" tabindex="6">
        <option value="">-----SELECCIONE-----</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM tipmerca");
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 width="165"><strong>EMPRESA:</strong></td>
    <td colspan="2"><select name="fempresa" id="fempresa" tabindex="7">
      <option value="">-----SELECCIONE-----</option>
      <?php
 
$sql = mysqli_query($con ,"SELECT * FROM fcompas");
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>
    <td><span class="Estilo18"><strong>AGENCIA:</strong></span></td>
    <td colspan="4"><span class="Estilo18">
      <select name="fcodagen" id="fcodagen" tabindex="8">
        <option value="">--SELECCIONE--</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM valeryus07");
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 colspan="2"><span class="Estilo18"><strong>PLAN:</strong></span></td>
    <td colspan="4"><span class="Estilo18">
      <select name="fplan" id="fplan" tabindex="9">
        <option value="">--SELECCIONE--</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM pplan");
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><strong>SEGMENTO:</strong></td>
    <td colspan="2"><select name="codseg" id="codseg">
      <option value="">--SELECCIONE--</option>
      <?php
 
$sql = mysqli_query($con ,"SELECT * FROM valeryus06");
while($reg=mysqli_fetch_array($sql)){
	if($_REQUEST['codseg']==$reg['descripcion'] ){
		echo '<option value="' . $reg['descripcion'] . '" selected>' . $reg['descripcion'] . '</option>';
	}else{
		echo '<option value="' . $reg['descripcion'] . '">' . $reg['descripcion'] . '</option>';
	}
}
?>
    </select></td>
    </tr>
  <tr>
    <td><span class="Estilo18"><strong>SMERF:</strong></span></td>
    <td colspan="4"><span class="Estilo18">
      <select name="smerf" id="smerf" tabindex="11">
        <option value="">--SELECCIONE--</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM fsmerf");
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></td>
    <td colspan="9"><div align="center"><input type="submit" name="Submit3" value="EXTRAS"></div></td></tr>
  <tr>
    <th colspan="14" class="titulo"><div align="center" class="Estilo18">MODIFICAR FORMA DE PAGO </div></th></tr>
  <tr>
    
	      <td>
			
		
		<strong> TARIFA ALTA.</strong>
		  <td colspan="9">          
	    <input name="tex" type="text" id="tex" size="3" value="AUT. V/S" READONLY>
        <input name="tex2" type="text" id="tex2" size="20" value="AUTOMATICA VIE/SAB" READONLY>
        <input name="tex3" type="text" id="tex3" size="4" value="ALTA" READONLY>
        <span class="Estilo17"><strong>$</strong></span>
		<input name="tex4" type="text" id="tex4" size="6" value="<?php if ($_REQUEST['tex4']!='') { echo $_REQUEST['tex4']; } else { echo '0'; }?>" onMouseMove="sumaTex()">
        <input name="tex5" type="text" id="tex5" size="3" value="<?php 
		
			if ($sabd!=''){
			echo "".$sabd."";
			}else { echo '0'; }
		
		?>" onMouseMove="sumaTex()" READONLY>
        =<span class="Estilo17"><strong>$</strong></span>
        <input name="tex6" type="text" id="tex6" size="8" onMouseMove="sumaTex()" value="<?php echo $_REQUEST['tex6'];?>" READONLY>
        <input name="?322" type="button" class="pp" tabindex="12" onClick="
	  	openWindow(
		{
			action:'rec_checkin_AG2.php',
			width:700,
			height:350
		},{
			val:'tex',
			des:'tex2',
			jio:'tex3',
			kji:'tex4'
		})" value="Buscar">		
	    <td width="80"><strong>FORMA DE PAGO.</strong></td>
		<td colspan="2"><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'");
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></td>
  </tr>
  <tr>
             <td>
	  <strong>  TARIFA BAJA.</strong>        <label></label></td>
             <td colspan="9"><label>
      <input name="text1" type="text" id="text1" size="3" value="AUT. D/J" READONLY>
      <input name="text2" type="text" id="text2" size="20" value="AUTOMATICA DOM/JUE" READONLY>
      <input name="text3" type="text" id="text3" size="4" value="BAJA" READONLY>
      <span class="Estilo17"><strong>$</strong></span>
      <input name="text4" type="text" id="text4" size="6" value="<?php  if ($_REQUEST['text4']!='') { echo $_REQUEST['text4']; } else { echo '0'; }?>" onMouseOver="restaTex()">
      <input name="text5" type="text" id="text5" size="3" value="<?php 
	  
		     if (isset($cuenta) && $cuenta==''){
			 echo '0';
	 		}else{	
                            
			echo ".$cuenta.";
			}
		
	  ?>" onMouseOver="restaTex()">
      =<span class="Estilo17"><strong> $</strong></span><input name="text6" type="text" id="text6" size="8" onMouseOver="restaTex()" value="<?php echo $_REQUEST['text6']; ?>" READONLY>
      
      <input name="?3222" type="button" class="pp" tabindex="13"onClick="
	  	openWindow(
		{
			action:'rec_checkin_AG3.php',
			width:700,
			height:350
		},{
			val:'text1',
			des:'text2',
			jio:'text3',
			kji:'text4'
		})" value="Buscar" >
             </label></td>
      <td><strong>NUMERO D TARJETA.</strong></td>
		<td colspan="2"><input name="fnumtar" type="text" id="fnumtar" tabindex="15"
	  onBlur="may(this)" size="20"
	  		<?php

				if(isset($_REQUEST['fnumtar'])){ //este es el truco
					echo 'value="' . $_REQUEST['fnumtar'] .  '"';
				}
			?>/>		  </td></td>
	</tr>
  <tr>
    <td><span class="Estilo16">TOTAL.</span></td>
    <td colspan="3"><span class="Estilo19">$</span>
      <label>
        <input name="ftotal" type="text" id="ftotal" value="<?php echo $_REQUEST['ftotal'];?>" size="15" onMouseMove="totalTex()" READONLY>
      </label></td>
    <td><strong>SALDO: 
      
    </strong></td>
      <td width="92"><strong>
        <input name="fsaldo" type="text" id="fsaldo" tabindex="14" size="15" value="<?php echo $_REQUEST['fsaldo'];?>">
      </strong></td>
      <td width="100"><strong>CODIGO DE SEGURIDAD: </strong></td>
      <td colspan="3"><input name="fcodseg" type="text" id="fcodseg" tabindex="15" size="12" value="<?php echo $_REQUEST['fcodseg'];?>"></td>
    <td><strong>LIMITE:</strong></td>
    <td><input name="flimite" type="text" id="flimite" tabindex="16" size="15" value="<?php echo $_REQUEST['flimite'];?>"></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th colspan="14" class="titulo"><div align="center" class="Estilo18">MODIFICAR DIRECCION</div></th></tr>
  <tr>
    <td><strong>NOMBRE:</strong></td>
    <td colspan="3">
	<textarea name="fnombre" cols="25" rows="3" id="fnombre" onBlur="may(this)" tabindex="4"><?php echo $_REQUEST['fnombre'];?></textarea>
    <td width="95"><strong>APELLIDO:</strong></td>
    <td colspan="4">
	<textarea name="fapellido" cols="20" rows="3" id="fapellido" onBlur="may(this)"tabindex="4"><?php echo $_REQUEST['fapellido'];?></textarea>	</td>
    <td><strong>TIPO DE HUESPED: </strong></td>
	<td colspan="2"><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");
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><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></div></td>
  <tr>
    <td><strong>TELEFONO:</strong></td>
    <td colspan="3"><input name="ftelefono" type="text" id="ftelefono" tabindex="20" size="25" value="<?php echo $_REQUEST['ftelefono'];?>"></td>
    <td><strong>TELEFONO EMPRESA:</strong></td>
    <td colspan="4"><input name="ftelemp" type="text" id="ftelemp" tabindex="21" size="25" value="<?php echo $_REQUEST['ftelemp'];?>"></td>
    <td><label><strong>E-MAIL:</strong></label></td>
    <td colspan="3"><input name="fmail" type="text" id="fmail" tabindex="23" size="25" value="<?php echo $_REQUEST['fmail'];?>"></td>
    </tr>
  <tr>
    <td><strong>E-MAIL EMPRESA:</strong></td>
    <td colspan="3"><input name="femail" type="text" id="femail" tabindex="24" size="25" value="<?php echo $_REQUEST['femail'];?>"></td>
    <td><strong>DIRECCION:</strong></td>
    <td colspan="4"><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="tragre" tabindex="26" 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><strong>CODIGO POSTAL:</strong></td>
 <td><input name="tcp" type="text" onKeyPress="return validar(event)" value="<?php echo $_REQUEST['tcp'];?>" size="10" maxlength="5"></td>
 <td><strong>COLONIA:</strong></td>
 <td><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">
 </span></td>
  </tr>
  <tr>
    <td><strong>PAIS:</strong></td>
    <td colspan="3"><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><strong>ESTADO:</strong></td>
    <td colspan="4"><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><strong>DELEGACION O MUNICIPIO.</strong></td>
    <td colspan="3"><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>
    <td colspan="14"><div align="center">
      <input name="Submit2" type="submit" class="tragre" tabindex="29" value="Revivir"/>
      &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="tragre" tabindex="30" onClick="openpage('res_consulta_PR.php','_self')" value="Regresar"/>
    </div></td>
    </tr>
</table>
</form>
  <?php
 
$fecha = (isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";
	$fechita = chfecha($fecha,'Y-m-d','d/m/Y');
	$fecha_llegada = chfecha(isset($_POST['ffecllegada'])?$_POST['ffecllegada']:"",'d/m/Y','Y-m-d');
if (isset($_POST['Submit2'])){
if(empty($_POST['tex']) or empty($_POST['tex2'])){  // 8
     echo alert_JS("¡¡¡COMPLETE LA TARIFA!!!");
	 return false;  
    }
     
	 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;  
    
	}if(empty($_POST['codseg'])){  // 8
     echo alert_JS("\A1\A1\A1SELECCIONE EL TIPO DE SEGMENTO!!!");
	 return false;  
    }
	///////////////////////////////////////MODIFICAR FORMA DE PAGO///////////////////////////////////////////////////
	$dkuh = $_POST['tex4'] * $_POST['tex5']; // 9
	if($dkuh != $_POST['tex6']){
	echo alert_JS ("\A1\A1\A1TOTAL TARIFA ALTA INCORRECTA!!!");
	return false;
	
	}$oahi = $_POST['text4'] * $_POST['text5'];  // 10
	if($oahi != $_POST['text6']){
	echo alert_JS ("\A1\A1\A1TOTAL TARIFA BAJA INCORRECTA!!!");
	return false;
	
	}$nslt = $dkuh + $oahi;  // 11
	if($nslt != $_POST['ftotal']){
	echo alert_JS ("\A1\A1\A1TOTAL INCORRECTO!!!");
	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;
		
	}if($_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;
	 
	}if($_POST['tcol'] == "" ){
		echo alert_JS ("\A1\A1\A1COMPLETE LA COLONIA!!!");
		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 != '".$_POST['bot']."' "));
        $xox=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='$usu' AND ffecllegada <= '$fecha_inicial' AND ffecsalida > '$fecha_inicial' AND n_reg != '".$_POST['bot']."' "));//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 != '".$_POST['bot']."' "));
        $yoy=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='$usu' AND ffecllegada < '$fecha_final' AND ffecsalida >= '$fecha_final' AND n_reg != '".$_POST['bot']."' "));//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 != '".$_POST['bot']."' "));
		 $dod=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='$usu' AND ffecllegada > '$fecha_inicial' AND ffecsalida < '$fecha_final' AND n_reg != '".$_POST['bot']."' "));//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;
				}
		
        include ("res_consulta_MC.php");
		}
		?>
</body>
<?php
 
mysqli_close($con);
}
?>
</html>
