<?php

session_start();
$com = "M";
include("DMMYSQLG.php");
include("DMMYSQLG.php");
include("DF80000.php");
include ("varfun.php");
$Segundos=0;
$cuenta=0;
$val1=0;
$val2=0;
?>
 <?php
 $bot=(isset($_GET['bot']))?$_GET['bot']:"";
$fecha = $dt_empres['fec_alta'];
	$fechita = chfecha($fecha,'Y-m-d','d/m/Y');
if (isset($_POST['Submit2'])){
    include("DMMYSQLG.php");
    if($_POST['ftipocto']=='MAESTRA'){
		$fecha_llegada = chfecha($_POST['ffecllegada'],'d/m/Y','Y-m-d');
	    $fecha_salida = chfecha($_POST['ffecsalida'],'d/m/Y','Y-m-d');
		$mensajes = '';
		$sql = mysqli_query($con ,"SELECT n_reg,fnumcto FROM valeryus19 WHERE status = 'RESERVA GRUPO' and fcodgrupo = '".$_POST['fcodgrupo']."' and cancelado = '0'");
		while($reg=mysqli_fetch_array($sql)){
			$mensaje = '';
			$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,$reg['fnumcto']);
			
			$dt_user=mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='".$reg['fnumcto']."' AND ffecllegada <= '$fecha_inicial' AND ffecsalida > '$fecha_inicial' AND n_reg != '".$reg['n_reg']."' "));
			$xox=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='$usu' AND ffecllegada <= '$fecha_inicial' AND ffecsalida > '$fecha_inicial' AND n_reg != '".$reg['n_reg']."' "));//ENTRADA ENTRE DOS FEHCAS
			echo mysqli_error($con);
	  
			if($dt_user['numRows']!=0)
				$mensaje = "LA HABITACION ".$reg['fnumcto']." ESTA OCUPADA POR: ".$xox['fapellido']." ".$xox['fnombre']." <br>";
					
			$dt_uper=mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='".$reg['fnumcto']."' AND ffecllegada < '$fecha_final' AND ffecsalida >= '$fecha_final' AND n_reg != '".$reg['n_reg']."' "));
			$yoy=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='$usu' AND ffecllegada < '$fecha_final' AND ffecsalida >= '$fecha_final' AND n_reg != '".$reg['n_reg']."' "));//SALIDA ENTRE DOS FECHAS
			echo mysqli_error($con);
	  
			if($dt_uper['numRows']!=0)
				$mensaje = "LA HABITACION ".$reg['fnumcto']." ESTA OCUPADA POR: ".$yoy['fapellido']." ".$yoy['fnombre']." <br>";
					
			$dt_uwer=mysqli_fetch_array(mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto FROM valeryus19 WHERE fnumcto='".$reg['fnumcto']."' AND ffecllegada > '$fecha_inicial' AND ffecsalida < '$fecha_final' AND n_reg != '".$reg['n_reg']."' "));
			$dod=mysqli_fetch_array(mysqli_query($con ,"SELECT * FROM valeryus19 WHERE fnumcto='$usu' AND ffecllegada > '$fecha_inicial' AND ffecsalida < '$fecha_final' AND n_reg != '".$reg['n_reg']."' "));//FECHA ENTRE DOS FECHAS
			echo mysqli_error($con);
	  
			if($dt_uwer['numRows']!=0)
				$mensaje = "LA HABITACION ".$reg['fnumcto']." ESTA OCUPADA POR: ".$dod['fapellido']." ".$dod['fnombre']." <br>";
			
			if(strlen($mensaje) == 0){
				$sql2 = mysqli_query($con ,"UPDATE valeryus19 SET  ffecllegada='$fecha_llegada', ffecsalida='$fecha_salida',  fnumctos='".$_POST['fnumctos']."', fnorasvip='".$_POST['fnorasvip']."', tex4 = '".$_POST['tex4']."', tex5 = '".$_POST['tex5']."', tex6 = '".$_POST['tex6']."', fnumres = '".$_POST['fnumres']."',fcodtarifa = '".$_POST['fcodtarifa']."',  ftelemp = '".$_POST['ftelemp']."',  fcodgrupo = '".$_POST['fcodgrupo']."', fcodagen = '".$_POST['fcodagen']."', smerf = '".$_POST['smerf']."', fcodmeca = '".$_POST['fcodmeca']."',  fplan = '".$_POST['fplan']."', fempresa = '".$_POST['fempresa']."', tex = '".$_POST['tex']."', tex2 = '".$_POST['tex2']."', tex3 = '".$_POST['tex3']."', tex6 = '".$_POST['tex6']."', text1 = '".$_POST['text1']."', text2 = '".$_POST['text2']."', text3 = '".$_POST['text3']."', text4 = '".$_POST['text4']."', text5 = '".$_POST['text5']."', text6 = '".$_POST['text6']."', fsaldo = '".$_POST['fsaldo']."', fformpago = '".$_POST['fformpago']."', fnumtar = '".$_POST['fnumtar']."', flimite = '".$_POST['flimite']."', fcodseg = '".$_POST['fcodseg']."', ftiphuesped = '".$_POST['ftiphuesped']."', ftelefono = '".$_POST['ftelefono']."', femail = '".$_POST['femail']."', fmail = '".$_POST['fmail']."', fdireccion = '".$_POST['fdireccion']."', fgntd = '".$_POST['tcol']."', fpais = '".$_POST['pais']."', fciudad = '".$_POST['tmun']."', festado = '".$_POST['estados']."', fcp = '".$_POST['tcp']."', codseg = '".$_POST['codseg']."', fusucamb = '".$_SESSION['usuario']."', ffeccam='".date('Y-m-d')."'	where n_reg='".$reg['n_reg']."' ");
			
			}else{
				$mensajes.= $mensaje;
			}
		}
			echo '<h2>!!! SE MODIFICO EL REGISTRO... <br>'.$mensajes.' ACTUALIZANDO en 5 segundos !!!</h2>';
			echo '<meta content="5; url=res_grupos_PR.php"  HTTP-EQUIV="REFRESH">';
    }else{
	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("LA 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("LA 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("LA 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("LA HABITACION ESTA OCUPADA POR: ".$dod['fapellido']." ".$dod['fnombre']." !!!!");
				return false;
			}
		
       // include ("valeryus40010_MC.php");
		$fecha_llegada = chfecha($_POST['ffecllegada'],'d/m/Y','Y-m-d');
	     $fecha_salida = chfecha($_POST['ffecsalida'],'d/m/Y','Y-m-d');
	
	      $sql = mysqli_query($con ,"UPDATE valeryus19 SET fnumadu='".$_POST['fnumadu']."', ffecllegada='$fecha_llegada', ffecsalida='$fecha_salida', fnummenor='".$_POST['fnummenor']."', fnumcto='".$_POST['fnumcto']."', ftipocto='".$_POST['ftipocto']."', fnumctos='".$_POST['fnumctos']."', fnombre= '".$_POST['fnombrea']."', fapellido='".$_POST['fapellido']."', fnorasvip='".$_POST['fnorasvip']."' , tex4 = '".$_POST['tex4']."', tex5 = '".$_POST['tex5']."', tex6 = '".$_POST['tex6']."', fformpago='".$_POST['fformpago']."'  where n_reg='".$_POST['bot']."' ");
		// fnumres = '".$_POST['fnumres']."',fcodtarifa = '".$_POST['fcodtarifa']."',  ftelemp = '".$_POST['ftelemp']."', , fcodgrupo = '".$_POST['fcodgrupo']."', fcodagen = '".$_POST['fcodagen']."', smerf = '".$_POST['smerf']."', fcodmeca = '".$_POST['fcodmeca']."',  fplan = '".$_POST['fplan']."', fempresa = '".$_POST['fempresa']."', tex = '".$_POST['tex']."', tex2 = '".$_POST['tex2']."', tex3 = '".$_POST['tex3']."', tex4 = '".$_POST['tex4']."', tex5 = '".$_POST['tex5']."', tex6 = '".$_POST['tex6']."', text1 = '".$_POST['text1']."', text2 = '".$_POST['text2']."', text3 = '".$_POST['text3']."', text4 = '".$_POST['text4']."', text5 = '".$_POST['text5']."', text6 = '".$_POST['text6']."', fsaldo = '".$_POST['fsaldo']."', fformpago = '".$_POST['fformpago']."', fnumtar = '".$_POST['fnumtar']."', flimite = '".$_POST['flimite']."', fcodseg = '".$_POST['fcodseg']."', ftiphuesped = '".$_POST['ftiphuesped']."', ftelefono = '".$_POST['ftelefono']."', femail = '".$_POST['femail']."', fmail = '".$_POST['fmail']."', fdireccion = '".$_POST['fdireccion']."', fgntd = '".$_POST['tcol']."', fpais = '".$_POST['pais']."', fciudad = '".$_POST['tmun']."', festado = '".$_POST['estados']."', fcp = '".$_POST['tcp']."', codseg = '".$_POST['codseg']."', fusucamb = '".$_SESSION['usuario']."', ffeccam='".date('Y-m-d')."',  
		
		
		
		 //ffecllegada= '$this->ffecllegada', , , ', , , , , , , , , flengua= '$this->flengua', , , fvip= '$this->fvip', , , , , , , , , , , , , , fnumctos= '$this->fnumctos', status= '$this->status', , , , , 
	//echo mysqli_error($con);
		  if(isset($_POST['json'])){
                 echo "ok";
                 return;
                 exit();
              }else{              
              
		echo '<h2>!!! SE MODIFICO EL REGISTRO... ACTUALIZANDO !!!</h2>';
	echo '<meta content="1; url=res_grupos_VER.php?grupo='.$_POST['fcodgrupo'].'"  HTTP-EQUIV="REFRESH">';
}
		}
}
include("JQUERY.inc");
		?>
<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 type="text/javascript" language="JavaScript1.2" src="js/DireccionesCP.js"></script>
<script language="javascript">
function openWindow2(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);
}


</script>
<?php

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

if($_POST['bot']==''){
$_POST['bot']=$_GET['n_reg'];
}
//print_r($_POST);
	include('res_grupos_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'];
	
	
	
?>
<?php


?>

<body onLoad="sumaTex();">
<form  name="frm1" method="post" id="frm1" action="" style="text-align: center;" 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 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');	
?>
<div id="width_wrapper" align="left">
<table width="980"  align="center" onMouseOver="sumaTex();">
  <tr>
    <td colspan="14" class="titulo">MODIFICAR REGISTRO DE RESERVACIONES DE GRUPO </td>
  </tr>
  <tr>
    <td colspan="2"><strong>ALTA</strong></td>
    <td width="99"><input name="ffecalt" type="text" id="ffecalt" class="datefrom"  class="styTabEspA" disabled="disabled" size="1"
	  <?php
 
		if(isset($_POST['bot'])){
		$fec1=$reg["ffecalt"];
		include('DF20000.php');
		echo 'value="'.$f_f.'"';
		}
		?>/>
      <input name="fusualta" type="text" disabled="disabled" id="fusualta" size="1"
	  <?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" class="dateto" 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="58"><strong>FOLIO.</strong></td>
    <td width="42" 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>
    </tr>
  <tr>
    <th colspan="2"><strong>FECHA DE LLEGADA </strong></th>
    <td>
	  <input name="ffecllegada" type="text" id="ffecllegada"  class="datefrom" size="10" onChange="javascript: document.getElementById('frm1').submit()" 
	  <?php

	  if(isset($_POST['ffecllegada']))
			  		echo 'value="'.$_POST['ffecllegada'].'"'; 
			  	else
			  		echo 'value="'.$_REQUEST['ffecllegada'].'"'; 
	  ?>
	  />
	  
       	  </td>
    <th colspan="2"><strong>NUMERO DE ADULTOS</strong></th>
    <td><input name="fnumadu" type="text" id="fnumadu" tabindex="1" onKeyPress="return validar(event)" size="5"  value="<?php echo $_REQUEST['fnumadu'];?>"></td>
	<td colspan="2"><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></label></td>
	<th colspan="5"><div align="center" class="Estilo18">NOTAS:</div></th>
	</tr>
  <tr>
    <th colspan="2"><strong>FECHA DE SALIDA</strong></th>
    <td><input name="ffecsalida" type="text" id="ffecsalida"  class="dateto" size="10" onChange="javascript: document.getElementById('frm1').submit()" 
	<?php

	 if(isset($_POST['ffecsalida']))
			  		echo 'value="'.$_POST['ffecsalida'].'"'; 
			  	else
			  		echo 'value="'.$_REQUEST['ffecsalida'].'"'; 
	?>
	/> 
  
      </td>
    <th colspan="2"><strong>NUMERO DE MENORES</strong></th>
    <td><input name="fnummenor" type="text" id="fnummenor" tabindex="2" onKeyPress="return validar(event)" size="5"  value="<?php echo $_REQUEST['fnummenor'];?>"></td>
    <th><strong>TIPO DE HABITACION</strong></th>
    <td width="152"><input name="ftipocto" type="text" id="ftipocto" value="<?php echo $_REQUEST['ftipocto'];?>" READONLY></td>
    <td colspan="5" 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>
    <th colspan="2"><strong>DIAS</strong></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><input name="fnumctos" type="text" id="fnumctos" tabindex="20" size="5" value="<?php
 echo  $dias; ?>" READONLY></td>
    <td colspan="3"><div align="center"><strong><span class="Estilo19">VIP.</span></strong><span class="Estilo18">
          <input name="fvip" type="checkbox" id="fvip" value="SI" <?php if($_REQUEST['fvip']=='SI') echo 'checked';?>>
    </span></div></td>
    <th><strong>NUMERO DE HABITACION</strong></th>
    <td><input name="fnumcto" type="text" id="fnumcto" tabindex="20" size="5"  value="<?php echo $_REQUEST['fnumcto'];?>" READONLY></td>
    </tr>
  <tr><td colspan="14" class="titulo">MODIFICAR DATOS</td></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><strong>EMPRESA:</strong></td>
    <td colspan="8"><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><strong>SEGMENTO:</strong></td>
    <td colspan="4"><span class="Estilo18">
      <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>
    </span></td>
    <td><span class="Estilo18"><strong>PLAN:</strong></span></td>
    <td colspan="8"><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>
    </tr>
  <tr>
    <td><strong>MERCADO:</strong></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><strong>AGENCIA:</strong></td>
    <td colspan="8"><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>
  </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><strong>TIPO DE HUESPED:</strong></td>
    <td colspan="8"><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>
    </tr>
  <tr>
    <td colspan="14" class="titulo">MODIFICAR FORMA DE PAGO</td></tr>
  <tr>
	      <th>
		<strong>TARIFA ALTA</strong>
		  <td colspan="6">          
	    <input name="tex" type="text" id="tex" size="3" value="<?php echo $_REQUEST['tex'];?>" />
        <input name="tex2" type="text" id="tex2" size="15" value="<?php echo $_REQUEST['tex2'];?>" READONLY>
        <input name="tex3" type="hidden" id="tex3" size="4" value="<?php echo $_REQUEST['tex3'];?>" READONLY>
        <span class="Estilo17"><strong>$</strong></span>
		<input name="tex4" type="text" id="tex4" size="4" value="<?php if ($_REQUEST['tex4']!='') { echo $_REQUEST['tex4']; } else { echo '0'; }?>" onMouseMove="sumaTex()" READONLY>
        <input name="tex5" type="text" id="tex5" size="2" value="<?php 
		if ($cant!=''){ echo "".$cant.""; }
		else {
		if ($_REQUEST['check'] == 1 && $_REQUEST['check_baja'] == 1){
			if ($sabd!=''){ 
			echo "".$sabd."";
			}else { echo '0'; }
		}else {
			if ($lkjsa!=''){
			echo "".$lkjsa."";}
			else { echo '0'; }
		}
		}
		
		?>" onMouseMove="sumaTex()" READONLY>
        =<span class="Estilo17"><strong>$</strong></span>
        <input name="tex6" type="text" id="tex6" size="6" onMouseMove="sumaTex()" value="<?php echo $_REQUEST['tex6'];?>" 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">		
        <input name="text4" type="hidden" id="text4" size="6" value="<?php if ($_REQUEST['text4']!='') { echo $_REQUEST['text4']; } else { echo '0'; }?>" onMouseOver="restaTex()" READONLY>
        <th><strong>LIMITE</strong>
        <td colspan="5"><input name="flimite" type="text" id="flimite" tabindex="16" size="15" value="<?php echo $_REQUEST['flimite'];?>">  </tr>
  
  <tr>
    <th><strong>FORMA DE PAGO</strong></th>
    <td colspan="4"><span class="Estilo1">
      <select name="fformpago" id="fformpago"  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>
    <th width="90"><strong>NUMERO DE TARJETA</strong></th>
      <td width="127"><strong>
        <input name="fnumtar" type="text" id="fnumtar" tabindex="15"
	  onBlur="may(this)" size="10"
	  		<?php

				if(isset($_REQUEST['fnumtar'])){ //este es el truco
					echo 'value="' . $_REQUEST['fnumtar'] .  '"';
				}
			?>/>
      </strong></td>
      <th><strong>CODIGO DE SEGURIDAD</strong></th>
      <td colspan="5"><input name="fcodseg" type="text" id="fcodseg" tabindex="15" size="12" value="<?php echo $_REQUEST['fcodseg'];?>"></td>
      </tr>
  <tr>
    <td colspan="14" class="titulo">MODIFICAR DIRECCION</td></tr>
  <tr>
    <th><strong>NOMBRE</strong></th>
    <td colspan="3">
	<!--textarea name="fnombre" id="fnombre" cols="20" rows="3" onBlur="may(this)" tabindex="18"><?php echo $_REQUEST['fnombre'];?></textarea-->
	<textarea name="fnombrea" cols="20" rows="3" id="fnombrea" onBlur="may(this)" tabindex="19"><?php echo $_REQUEST['fnombre'];?></textarea>
	</td>
    <th width="96"><strong>APELLIDO</strong></th>
    <td colspan="2">
	<textarea name="fapellido" cols="20" rows="3" id="fapellido" onBlur="may(this)" tabindex="19"><?php echo $_REQUEST['fapellido'];?></textarea>	</td>
    <td><strong>TELEFONO:</strong></td>
    <td colspan="6"><input name="ftelefono" type="text" id="ftelefono" tabindex="20" size="25" value="<?php echo $_REQUEST['ftelefono'];?>"></td>
    <tr>
    <td><strong>TELEFONO EMPRESA:</strong></td>
    <td colspan="3"><input name="ftelemp" type="text" id="ftelemp" tabindex="21" size="25" value="<?php echo $_REQUEST['ftelemp'];?>"></td>
    <td><strong>E-MAIL:</strong></td>
    <td colspan="2"><input name="fmail" type="text" id="fmail" tabindex="23" size="25" value="<?php echo $_REQUEST['fmail'];?>"></td>
    <td><strong>E-MAIL EMPRESA:</strong></td>
    <td colspan="5"><label>
    <input name="femail" type="text" id="femail" tabindex="24" size="25" value="<?php echo $_REQUEST['femail'];?>">
    </label></td>
    </tr>
  <tr>
    <td><strong>DIRECCION:</strong></td>
    <td colspan="3"><input name="fdireccion" type="text" id="fdireccion" tabindex="25" size="20" onBlur="may(this)" value="<?php echo $_REQUEST['fdireccion'];?>"></td>
    <td><strong>CODIGO POSTAL:</strong></td>
    <td colspan="2"><span class="Estilo18">
      <input name="tcp" type="text" onKeyPress="return validar(event)" value="<?php echo $_REQUEST['tcp'];?>" size="10" maxlength="5">
      <input type="hidden" name="tcol1" id="tcve" value="<?php echo $_REQUEST['tcve'];?>">
      <input name="?" type="button" class="tragre" tabindex="26" onClick="window.open('DX40000_AG1.php?retPag=res_grupos_MO.php','popuppage','width=750,height=300,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')" value="..." >
    </span></td><td><strong>COLONIA:</strong></td>
    <td colspan="5"><span class="Estilo18">
      <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" >
        <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>';
				}
				}	
				include("DMMYSQLG.php");	
		?>
      </select>
    </span></td>
    <td><strong>ESTADO:</strong></td>
    <td colspan="2"><span class="Estilo18">
      <select name="estados" id="estados" >
        <option  value="">-----Selecciona-----</option>
        <?php   
		include("DMMYSQLG.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="5"><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="Modificar"/>
      &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_grupos_VER.php?grupo=<?php echo $_REQUEST['fcodgrupo'];?>','_self')" value="Regresar"/>
    </div></td>
    </tr>
</table>
</div>
</form>
 
</body>
<?php
 
mysqli_close($con);

//918 --> 800 ultima actualizacion 18-enero-2012 866
?>
