<?php
 
session_start();
include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
include ("varfun.php");
INCLUDE("JQUERY.inc");
?>
<html>
<head>
<title>CENTRO COSTOS</title>

</head>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
<script language="javascript">
function act_checkbox(va)
{
	if(va == true){
		document.frm1.campo1.disabled = 0;
		//document.getElementById("ftipocto").style.visibility='visible';
	}else{
		document.frm1.campo1.disabled = 1;
		//document.getElementById("ftipocto").style.visibility='hidden';
	}
}
function act_funcion(va)
{
	if(va == true){
		document.frm1.campo2.disabled = 0;
		//document.getElementById("ftipocto").style.visibility='visible';
	}else{
		document.frm1.campo2.disabled = 1;
		//document.getElementById("ftipocto").style.visibility='hidden';
	}
}
function act_ghy(va)
{
	if(va == true){
		document.frm1.campo3.disabled = 0;
	}else{
		document.frm1.campo3.disabled = 1;
	}
}
function act_dfg(va)
{
	if(va == true){
		document.frm1.campo4.disabled = 0;
	}else{
		document.frm1.campo4.disabled = 1;
	}
}
function act_fib(va)
{
	if(va == true){
		document.frm1.campo5.disabled = 0;
	}else{
		document.frm1.campo5.disabled = 1;
	}
}
function act_oxl(va)
{
	if(va == true){
		document.frm1.campo6.disabled = 0;
	}else{
		document.frm1.campo6.disabled = 1;
	}
}
function act_owk(va)
{
	if(va == true){
		document.frm1.campo7.disabled = 0;
	}else{
		document.frm1.campo7.disabled = 1;
	}
}
function act_poi(va)
{
	if(va == true){
		document.frm1.campo8.disabled = 0;
	}else{
		document.frm1.campo8.disabled = 1;
	}
}
function act_osy(va)
{
	if(va == true){
		document.frm1.campo9.disabled = 0;
	}else{
		document.frm1.campo9.disabled = 1;
	}
}
function act_oqg(va)
{
	if(va == true){
		document.frm1.campo10.disabled = 0;
	}else{
		document.frm1.campo10.disabled = 1;
	}
}
function act_wke(va)
{
	if(va == true){
		document.frm1.campo11.disabled = 0;
	}else{
		document.frm1.campo11.disabled = 1;
	}
}
function act_aij(va)
{
	if(va == true){
		document.frm1.campo12.disabled = 0;
	}else{
		document.frm1.campo12.disabled = 1;
	}
}
function act_udh(va)
{
	if(va == true){
		document.frm1.campo13.disabled = 0;
	}else{
		document.frm1.campo13.disabled = 1;
	}
}
function act_iej(va)
{
	if(va == true){
		document.frm1.campo14.disabled = 0;
	}else{
		document.frm1.campo14.disabled = 1;
	}
}
function act_ssk(va)
{
	if(va == true){
		document.frm1.campo15.disabled = 0;
	}else{
		document.frm1.campo15.disabled = 1;
	}
}
function act_psh(va)
{
	if(va == true){
		document.frm1.campo16.disabled = 0;
	}else{
		document.frm1.campo16.disabled = 1;
	}
}
function act_qld(va)
{
	if(va == true){
		document.frm1.campo17.disabled = 0;
	}else{
		document.frm1.campo17.disabled = 1;
	}
}
function act_ijs(va)
{
	if(va == true){
		document.frm1.campo18.disabled = 0;
	}else{
		document.frm1.campo18.disabled = 1;
	}
}
function act_wlz(va)
{
	if(va == true){
		document.frm1.campo19.disabled = 0;
	}else{
		document.frm1.campo19.disabled = 1;
	}
}
function act_vrf(va)
{
	if(va == true){
		document.frm1.campo20.disabled = 0;
	}else{
		document.frm1.campo20.disabled = 1;
	}
}
function act_skl(va)
{
	if(va == true){
		document.frm1.campo21.disabled = 0;
	}else{
		document.frm1.campo21.disabled = 1;
	}
}
function act_xsp(va)
{
	if(va == true){
		document.frm1.campo22.disabled = 0;
	}else{
		document.frm1.campo22.disabled = 1;
	}
}
function act_qhz(va)
{
	if(va == true){
		document.frm1.campo23.disabled = 0;
	}else{
		document.frm1.campo23.disabled = 1;
	}
}
function act_rit(va)
{
	if(va == true){
		document.frm1.campo24.disabled = 0;
	}else{
		document.frm1.campo24.disabled = 1;
	}
}
function act_lad(va)
{
	if(va == true){
		document.frm1.campo25.disabled = 0;
	}else{
		document.frm1.campo25.disabled = 1;
	}
}
function act_aos(va)
{
	if(va == true){
		document.frm1.campo26.disabled = 0;
	}else{
		document.frm1.campo26.disabled = 1;
	}
}
function act_sij(va)
{
	if(va == true){
		document.frm1.campo27.disabled = 0;
	}else{
		document.frm1.campo27.disabled = 1;
	}
}
function act_btl(va)
{
	if(va == true){
		document.frm1.campo28.disabled = 0;
	}else{
		document.frm1.campo28.disabled = 1;
	}
}
function act_zpy(va)
{
	if(va == true){
		document.frm1.campo29.disabled = 0;
	}else{
		document.frm1.campo29.disabled = 1;
	}
}
function act_qmh(va)
{
	if(va == true){
		document.frm1.campo30.disabled = 0;
	}else{
		document.frm1.campo30.disabled = 1;
	}
}
function act_pzj(va)
{
	if(va == true){
		document.frm1.campo31.disabled = 0;
	}else{
		document.frm1.campo31.disabled = 1;
	}
}
function act_kjd(va)
{
	if(va == true){
		document.frm1.campo32.disabled = 0;
	}else{
		document.frm1.campo32.disabled = 1;
	}
}
function act_lhd(va)
{
	if(va == true){
		document.frm1.campo33.disabled = 0;
	}else{
		document.frm1.campo33.disabled = 1;
	}
}
function act_yhn(va)
{
	if(va == true){
		document.frm1.campo34.disabled = 0;
	}else{
		document.frm1.campo34.disabled = 1;
	}
}
function act_azx(va)
{
	if(va == true){
		document.frm1.campo35.disabled = 0;
	}else{
		document.frm1.campo35.disabled = 1;
	}
}
function suma_campo(){
	var objTex1=document.getElementById('campo1'),
		objTex2=document.getElementById('campo2'),
		objTex3=document.getElementById('campo3'),
		objTex4=document.getElementById('campo4'),
		//objTex5=document.getElementById('campo5'),
		//objTex6=document.getElementById('campo6'),
		//objTex7=document.getElementById('campo7'),
		//objTex8=document.getElementById('campo8'),
		//objTex9=document.getElementById('campo9'),
		//objTex10=document.getElementById('campo10'),
		//objTex11=document.getElementById('campo11'),
		//objTex12=document.getElementById('campo12'),
		//objTex13=document.getElementById('campo13'),
		//objTex14=document.getElementById('campo14'),
		//objTex15=document.getElementById('campo15'),
		//objTex16=document.getElementById('campo16'),
		//objTex17=document.getElementById('campo17'),
		//objTex18=document.getElementById('campo18'),
		//objTex19=document.getElementById('campo19'),
		//objTex20=document.getElementById('campo20'),
		//objTex21=document.getElementById('campo21'),
		//objTex22=document.getElementById('campo22'),
		//objTex23=document.getElementById('campo23'),
		//objTex24=document.getElementById('campo24'),
		//objTex25=document.getElementById('campo25'),
		//objTex26=document.getElementById('campo26'),
		//objTex27=document.getElementById('campo27'),
		//objTex28=document.getElementById('campo28'),
		//objTex29=document.getElementById('campo29'),
		//objTex30=document.getElementById('campo30'),
		//objTex31=document.getElementById('campo31'),
		//objTex32=document.getElementById('campo32'),
		//objTex33=document.getElementById('campo33'),
		//objTex34=document.getElementById('campo34'),
		//objTex35=document.getElementById('campo35'),
		objTex90=document.getElementById('campo90');
		objTex90.value=(parseFloat(objTex1.value)+parseFloat(objTex2.value)+parseFloat(objTex3.value)+parseFloat(objTex4.value));}
		//+parseFloat(objTex5.value)+parseFloat(objTex6.value)+parseFloat(objTex7.value)+parseFloat(objTex8.value)+parseFloat(objTex9.value)+parseFloat(objTex10.value)+parseFloat(objTex11.value)+parseFloat(objTex12.value)+parseFloat(objTex13.value)+parseFloat(objTex14.value)+parseFloat(objTex15.value)+parseFloat(objTex16.value)+parseFloat(objTex17.value)+parseFloat(objTex18.value)+parseFloat(objTex19.value)+parseFloat(objTex20.value)+parseFloat(objTex21.value)+parseFloat(objTex22.value)+parseFloat(objTex23.value)+parseFloat(objTex24.value)+parseFloat(objTex25.value)+parseFloat(objTex26.value)+parseFloat(objTex27.value)+parseFloat(objTex28.value)+parseFloat(objTex29.value)+parseFloat(objTex30.value)+parseFloat(objTex31.value)+parseFloat(objTex32.value)+parseFloat(objTex33.value)+parseFloat(objTex34.value)+parseFloat(objTex35.value));
		
//}
</script>
<script language="javascript">
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>

<body>
<form name="frm1" method="post">
<?php
 
for($j=0;$j<=119;$j++)
{
	$c[]= "t" . $j;
	echo '<input name="' . $c[$j-1] . '" type="hidden" value="' . $_POST[$c[$j-1]] .'">';
}

$fechaInicial = $_POST['ffecllegada'];    
     $fecha = daydiff ($_POST['ffecsalida'],$_POST['ffecllegada'],'d/m/Y');
     //$MaxDias = 6;   
         for ($i=0; $i<$fecha; $i++)   
    {   
        $Segundos = $Segundos + 86400;         
        $caduca = date("D",time()+$Segundos);     
            if ($caduca == "Sat")   
            {   
                //$i--; 
				$val1=$val1+1;  
            }   
            else if ($caduca == "Sun")   
            {   
                //$i--;   
				$val2=$val2+1;
            }   
            else  
            {   
                $FechaFinal = date("Y-m-d",time()+$Segundos);  
				$cuenta=$cuenta+1;
				//echo $FechaFinal; 
            }   
    }  
	//echo $cuenta;
	$sabd=$val1+$val2;
	//echo "sd";
	//echo $sabd;

?>
  <table width="774" border="0" align="center">
    <tr>
      <th colspan="6" class="titulo"><div align="center">AGREGAR DIRECCION DEL GRUPO. </div></th>
    </tr>
    <tr>
      <td width="121"  ><span class="Estilo18">DIRECCION</span></td>
      <td colspan="2" style="#66CCFF"><span class="Estilo1">
        <input name="?3" type="button" class="pp" onClick="window.open('DX40000_AG1.php?retPag=valeryus40000_AG3.php','popuppage','width=750,height=300,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')" value="...." >
      </span></td>
      <td  ><span class="Estilo18">CODIGO POSTAL</span></td>
      <td colspan="2" style="#66CCFF"><input name="tcp" type="text" onKeyPress="return validar(event)" value="<? echo $_REQUEST['tcp'];?>" size="8" maxlength="5" tabindex="27"></td>
    </tr>
    <tr>
      <td  ><span class="Estilo18">COLONIA</span></td>
      <td colspan="2" style="#66CCFF"><span class="Estilo1">
        <input type="hidden" name="tcol1" id="tcve" value="<? echo $_REQUEST['tcve'];?>">
        <input name="tcol" type="text" id="tcol" value="<? echo $_REQUEST['tcol'];?>" size="25" tabindex="26">
      </span></td>
      <td  ><span class="Estilo18">PAIS</span></td>
      <td colspan="2" style="#66CCFF"><span class="Estilo1">
        <select name="pais" id="pais" onChange="javascript: document.getElementById('frm1').submit()" 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>
      <td  ><span class="Estilo18">ESTADO</span></td>
      <td colspan="2" style="#66CCFF"><span class="Estilo1">
        <select name="estados" onChange="javascript: document.getElementById('frm1').submit()" 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>
      <td  ><span class="Estilo18">DELEGACION O MUNICIPIO</span></td>
      <td colspan="2" style="#66CCFF"><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>
      <th colspan="6"  >AGREGAR TARIFA. </th>
    </tr>
    <tr>
      <td  ><span class="Estilo18">FECHA DE LLEGADA </span></td>
      <td colspan="2" style="#66CCFF"><input name="ffecllegada" type="text" class="emplea datefrom" id="ffecllegada" size="8" onChange="javascript: document.getElementById('frm1').submit()"
	  <?php
 
				$fecha = $dt_empres['fec_alta'];
	            $fechita = chfecha($fecha,'Y-m-d','d/m/Y');
				if(isset($_POST['ffecllegada']))
			  		echo 'value="'.$_POST['ffecllegada'].'"'; 
			  	else
			  		echo 'value="'.$fechita.'"'; 
			?>>
       </td>
      <td  ><span class="Estilo19"><strong>DIAS.</strong></span></td>
      <td colspan="2" style="#66CCFF"><input name="fnumctos" id="fnumctos" value="<? echo (daydiff ($_POST['ffecsalida'],$_POST['ffecllegada'],'d/m/Y'));?>" type="text" size="5" READONLY></td>
    </tr>
    <tr>
      <td  ><span class="Estilo18">FECHA DE SALIDA </span></td>
      <td colspan="5" style="#66CCFF"><input name="ffecsalida" type="text" class="emplea dateto" id="ffecsalida" size="8" onChange="javascript: document.getElementById('frm1').submit()"
	  <?php
 
				$fecha = $dt_empres['fec_alta'];
	            $fechita = chfecha($fecha,'Y-m-d','d/m/Y');
				function sumaDia($fecha,$dia){	
	            list($year,$mon,$day) = explode('-',$fecha);	
	            return date('Y-m-d',mktime(0,0,0,$mon,$day+$dia,$year));		
	            } 
				$mas1 = sumaDia($fecha,1);//salida: 2008-02-04 
	            $nueva = chfecha($mas1,'Y-m-d','d/m/Y');
				if(isset($_POST['ffecsalida']))
			  		echo 'value="'.$_POST['ffecsalida'].'"'; 
			  	else
			  		echo 'value="'.$nueva.'"'; 
			?>
	  >
        	</td>
    </tr>
    <tr>
	<?php $lkjsa = daydiff ($_POST['ffecsalida'],$_POST['ffecllegada'],'d/m/Y'); ?>
      <td  ><span class="Estilo19">
        <input type="checkbox" name="check" value="1" onClick="javascript: document.getElementById('frm1').submit()" id="check"
		<?php if($_REQUEST['check']) echo 'checked';?>>
        <?php

		if ($_POST['check'] == 1){
		?>
		<strong>DESACTIVAR TARIFA ALTA</strong> </span></td>
	  <td colspan="6" style="#66CCFF">        
		<input name="tex" type="text" id="tex" size="3" value="<?php echo $_REQUEST['tex'];?>" READONLY>
        <input name="tex2" type="text" id="tex2" size="20" value="<?php echo $_REQUEST['tex2'];?>" READONLY>
        <input name="tex3" type="text" id="tex3" size="4" value="<?php echo $_REQUEST['tex3'];?>" 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()" READONLY>
        <input name="tex5" type="text" id="tex5" size="3" value=" <?php 
		if ($_POST['check'] == 1 && $_POST['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="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>    
		<?php

	}else{
	?>
	  <strong>ACTIVAR TARIFA ALTA.</strong>
      <?php

}
?>
    </tr>
    <tr>
      <td  ><span class="Estilo19">
        <input type="checkbox" name="check_baja" value="1" onClick="javascript: document.getElementById('frm1').submit()" id="check_baja"
		<?php if($_REQUEST['check_baja']) echo 'checked';?>>
		<?php

		if ($_POST['check_baja'] == 1){
	    ?>
	    <strong> DESACTIVAR TARIFA BAJA</strong>        
	    <label></label>
      </span></td>
      <td colspan="6" style="#66CCFF"><label>
      <input name="text1" type="text" id="text1" size="3" value="<?php echo $_REQUEST['text1'];?>" READONLY>
      <input name="text2" type="text" id="text2" size="20" value="<?php echo $_REQUEST['text2'];?>" READONLY>
      <input name="text3" type="text" id="text3" size="4" value="<?php echo $_REQUEST['text3'];?>" 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()" READONLY>
      <input name="text5" type="text" id="text5" size="3" value="<?php 
	  if ($_POST['check'] == 1 && $_POST['check_baja'] == 1){
		     if ($cuenta==''){
			 echo '0';
	 		}else{	
			echo "".$cuenta."";
			}
		}else{
			if ($lkjsa==''){
			 echo '0';
	 		}else{	
			echo "".$lkjsa."";
			}
		}
	  ?>" onMouseOver="restaTex()">
      =<span class="Estilo17"><strong> $</strong></span><input name="text6" type="text" id="text6" size="8" onMouseOver="restaTex()" value="<? 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>
      <?php

		}else{
		?>
    <strong>ACTIVAR TARIFA BAJA.</strong>
	
		
      
    <?php

	  }
	  	?>	</tr>
    <tr>
      <td  ><span class="Estilo19"><strong>TOTAL</strong></span></td>
      <td colspan="5" style="#66CCFF"><span class="Estilo17"><strong>$</strong></span>
      <input name="ftotal" type="text" id="ftotal" size="15" onMouseMove="totalTex()" value="<? echo $_REQUEST['ftotal'];?>"/></td>
    </tr>
    <tr>
      <th colspan="6">AGREGAR NUMERO Y TIPO DE HABITACIONES.</th>
    </tr>
    <tr>
      <td  ><span class="Estilo19">
        
		<?php 
		//CHECAR CONEXION A LA BASE DE DATOS
		include("DMMYSQLG.php");
		//FECHAS DEL CALENDARIO
		$fec = $_POST['ffecllegada'];
		include('DF20000.php');
		$fecha_inicial = $f_m;
		$fec = $_POST['ffecsalida'];
		include('DF20000.php');
		$fecha_final = $f_m;
        //SELECCIONO TIPO Y NUMEROS DE CUARTOS ---> KING SIZE
		$ErEr = mysqli_query($con ,"select * from valeryus05 where n_reg = '1'");
		while ($TyTy = mysqli_fetch_array($ErEr)){
		//echo "".$TyTy['totalcuartos'].""; TOTAL DE CUARTOS
		$ToT = $TyTy['totalcuartos'];
		$TiPo = $TyTy['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)){
		//echo "<tr>"; 
        //echo "<td><h5 align='center'>" . $as["n_reg"] . "</h5></td>";
		//echo "<td><h5 align='center'>" . $as["fnumcto"] . "</h5></td>";
		//echo "<td><h5 align='center'>" . $as["status"] . "</h5></td>";
		//echo "<td><h5 align='center'>" . $as["cancelado"] . "</h5></td>"; 
		//$reg['cancelado'] == 1
		$OCU = $as['fnumcto'];
		$i++;
		}
		//LA $i RESTA EL TOTAL 
		//echo "".$i.""; 
		//$suma = $as['total'];
		$rEs =$ToT -$i;
		//echo "".$rEs.""; 
		
		@$resultado=mysqli_query($con ,"select * from valeryus05 where n_reg = '1'");
			  @$registro=mysqli_fetch_array($resultado);
			  echo '<input name="ver1" type="hidden" value="'.$registro['descripcion'].'">';
	          if ($registro['n_reg']==1){ ?>
	    <input name="oij" type="checkbox" value="1" onClick="act_checkbox(oij.checked)">
	    <?php }
			  echo $registro ['n_reg']; 
			  if ($registro['n_reg']==1){
			  echo ".-";
			  }
			  echo "".$registro['descripcion']. "<br/>" ; 
			  echo "<em> (Hay ".$rEs." KING SIZE desocupadas)</em>"; ?>
      </span></td>
      <td width="130" style="#66CCFF"><? if ($registro['n_reg']==1){ ?>
      <input name="campo1" type="text" tabindex="1" size="4" maxlength="10" onKeyPress="return soloNumeros(event)" disabled="disabled" onKeyUp="suma_campo()" value="0"
		<?php if(isset($_POST['campo1'])){ 
			echo 'value="' . $_POST['campo1'] .  '"';
			} ?> /> <? }?></td>
      
	  <td width="154"  > <span class="Estilo19">
	    <?php 
		
		$ErEr = mysqli_query($con ,"select * from valeryus05 where n_reg = '2'");//QUEEN SIZE
		while ($TyTy = mysqli_fetch_array($ErEr)){
		//echo "".$TyTy['totalcuartos']."";
		$ToT = $TyTy['totalcuartos'];
		$TiPo = $TyTy['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)){
     
		$i++;
		}
		//echo "".$i.""; 
		
		$qUE =$ToT -$i;
		
		//echo "".$qUE.""; 
		
		@$resultado=mysqli_query($con ,"select * from valeryus05 where n_reg = '2'");
			 @$registro=mysqli_fetch_array($resultado);
			 echo '<input name="ver1" type="hidden" value="'.$registro['descripcion'].'">';
	         if ($registro['n_reg']==2){ ?>
	    <input type="checkbox" name="con_1" value="1" onClick="act_funcion(con_1.checked)">
	    <?php }
			 echo $registro ['n_reg']; 
			 if ($registro['n_reg']==2){
			 echo ".-";
			 }
			 echo "".$registro['descripcion']. "<br/>" ;
			 echo "<em> (Hay ".$qUE." QUEEN SIZE desocupadas)</em>"; ?>      
      </span></td>
      <td width="84" style="#66CCFF"><?php if ($registro['n_reg']==2){ ?>
      <input name="campo2" type="text" tabindex="2" onKeyPress="return soloNumeros(event)" size="4" disabled="disabled" value="0" onKeyUp="suma_campo()"
		<?php if(isset($_POST['campo2'])){ 
			echo 'value="' . $_POST['campo2'] .  '"';
			} ?> /> <?php } ?> </td>

	  <td width="138"  ><span class="Estilo19">
	    <?php 
		
		$ErEr = mysqli_query($con ,"select * from valeryus05 where n_reg = '3'");//SUITE
		while ($TyTy = mysqli_fetch_array($ErEr)){
		//echo "".$TyTy['totalcuartos']."";
		$ToT = $TyTy['totalcuartos'];
		$TiPo = $TyTy['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++;
		}
		//echo "".$i.""; 
		
		$Sui =$ToT -$i;
		
		//echo "".$Sui."";
		
		@$resultado=mysqli_query($con ,"select * from valeryus05 where n_reg = '3'");
			 @$registro=mysqli_fetch_array($resultado);
			 echo '<input name="ver1" type="hidden" value="'.$registro['descripcion'].'">';
	         if ($registro['n_reg']==3){ ?>
        <input type="checkbox" name="ghy" value="1" onClick="act_ghy(ghy.checked)">
        <?php }
			 echo $registro ['n_reg']; 
			 if ($registro['n_reg']==3){
			 echo ".-";
			 }
			 echo "".$registro['descripcion']. "<br/>" ; 
			 echo "<em> (Hay ".$Sui." SUITE desocupadas)</em>";?>
	  </span></td>
	  <td width="121" colspan="2" style="#66CCFF"><?php if ($registro['n_reg']==3){ ?>
        <input name="campo3" type="text" onKeyUp="suma_campo()" tabindex="3" size="4" maxlength="10" onKeyPress="return soloNumeros(event)" value="0" disabled="disabled"
	  <?php if(isset($_POST['campo3'])){ 
			echo 'value="' . $_POST['campo3'] .  '"';
			} ?> />
      <?php } ?></td>
    </tr>
    <tr>
      <td  ><span class="Estilo19">
        <?php 
		
		$ErEr = mysqli_query($con ,"select * from valeryus05 where n_reg = '4'");//INDIVIDUAL
		while ($TyTy = mysqli_fetch_array($ErEr)){
		//echo "".$TyTy['totalcuartos']."";
		$ToT = $TyTy['totalcuartos'];
		$TiPo = $TyTy['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++;
		}
		//echo "".$i.""; 
		
		$Ind =$ToT -$i;
		
		//echo "".$Ind."";
		
		@$resultado=mysqli_query($con ,"select * from valeryus05 where n_reg = '4'");
			 @$registro=mysqli_fetch_array($resultado);
			 echo '<input name="ver1" type="hidden" value="'.$registro['descripcion'].'">';
	         if ($registro['n_reg']==4){ ?>
	    <input type="checkbox" name="dfg" value="1" onClick="act_dfg(dfg.checked)">
	    <?php }
			 echo $registro ['n_reg']; 
			 if ($registro['n_reg']==4){
			 echo ".-";
			 }
			 echo "".$registro['descripcion']. "<br/>" ; 
			 echo "<em> (Hay ".$Ind." INDIVIDUALES desocupadas)</em>";?>      
      </span></td>
      <td style="#66CCFF"><?php if ($registro['n_reg']==4){ ?>
        <input name="campo4" type="text" tabindex="4" size="4" onKeyUp="suma_campo()" maxlength="10" onKeyPress="return soloNumeros(event)" disabled="disabled" value="0"
	  <?php if(isset($_POST['campo4'])){ 
			echo 'value="' . $_POST['campo4'] .  '"';
			} ?> />
        <?php } ?></td>
      <!--td  ><span class="Estilo19">
        <? //@$resultado=mysqli_query($con ,"select * from valeryus05 where n_reg = '5'");
			 //@$registro=mysqli_fetch_array($resultado);
			 //echo '<input name="ver1" type="hidden" value="'.$registro['descripcion'].'">';
			 //if ($registro['n_reg']==5){ ?>
        <input type="checkbox" name="fib" value="1" onClick="act_fib(fib.checked)">
        <? //}
			 //echo $registro ['n_reg']; 
			 //if ($registro['n_reg']==5){
			 //echo ".-";
			 //}
			 //echo $registro['descripcion']; ?>
      </span></td>
      <td style="#66CCFF"><? //if ($registro['n_reg']==5){ ?>
        <input name="campo5" type="text" tabindex="5" size="4" maxlength="10" onKeyUp="suma_campo()" onKeyPress="return soloNumeros(event)" disabled="disabled" value="0"
		<? //if(isset($_POST['campo5'])){ 
			//echo 'value="' . $_POST['campo5'] .  '"';
			//} ?> />
        <? //} ?>      </td-->            
    </tr>
    
    <tr>
      <td colspan="2">&nbsp;</td>
      <td width="154"  ><span class="Estilo19"><strong>CANTIDAD DE HABITACIONES</strong> </span></td>
      <td colspan="3"><input name="campo90" type="text" size="10" maxlength="5" id="campo90" value="0"/></td>
    </tr>
    <tr>
      <td colspan="6"><div align="center">
        <input type="submit" name="Submit" value="Agregar Grupo"> 
    
		<input type="button" name="Submit2" value="Regresar al Principio" onClick="openpage('valeryus40000_PR.php','_self')">
      </div></td>
    </tr>
  </table>
</form>
<?php

if (isset($_POST["Submit"])){
if($_POST['fnumctos'] == 0){
   echo alert_js("FECHA DE SALIDA INVALIDA");
}
elseif($_POST['campo1'] == 0 && $_POST['campo2'] == 0 && $_POST['campo3'] == 0 && $_POST['campo4'] == 0){
       echo alert_js("DEBE HABER MAS DE UNA HABITACION SELECCIONADA");
}
elseif ($_POST['check'] == 0 && $_POST['check_baja'] == 0 && $_POST['tex6'] == 0 && $_POST['text6'] == 0){
        echo alert_JS("SELECCIONE UNA DE LAS DOS TARIFAS");
}
elseif ($_POST['campo1'] > $rEs ){
        echo alert_JS("NO HAY HABITACIONES KING SIZE DISPONIBLES");
}
elseif ($_POST['campo2'] > $qUE ){
        echo alert_JS("NO HAY HABITACIONES QUEEN SIZE DISPONIBLES");
}
elseif ($_POST['campo3'] > $Sui ){
        echo alert_JS("NO HAY HABITACIONES SUITE DISPONIBLES");
}
elseif ($_POST['campo4'] > $Ind ){
        echo alert_JS("NO HAY HABITACIONES INDIVIDUAL DISPONIBLES");
	
// }
//elseif ($_POST['check'] == 1 && $_POST['check_baja'] == 0){
	//  $dfk = $_POST['tex4'] * $_POST['tex5'];
	  //  if ($dfk != $_POST['tex6']){
	    //  echo alert_JS ("ĦĦĦTOTAL TARIFA ALTA INCORRECTA!!!");
	      //   }
	 // $iei = $dfk + 0;
	   // if ($iei != $_POST['ftotal']){
	     // echo alert_JS ("ĦĦĦTOTAL INCORRECTO!!!");
	        
	
	 // }
	   // }
//elseif ($_POST['check_baja'] == 1 && $_POST['check'] == 0){
   //	$kai = $_POST['text4'] * $_POST['text5']; // 7
	 // if ($kai != $_POST['text6']){
	   // echo alert_JS ("ĦĦĦTOTAL TARIFA BAJA INCORRECTA!!!");
	     //  }
   //	$iei = 0 + $kai; // 8
	 // if ($iei != $_POST['ftotal']){
	   // echo alert_JS ("ĦĦĦTOTAL INCORRECTO!!!");
	      
	
	 // }	
	    }else{
include("valeryus40000_AC.php");
}
}
?>
</body>
</html>
