<?php
 if(!isset($_SESSION)) {  session_start();  } 
//session_start();
$com = "A";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
include("DFJQUERY.inc");
include("DF30000.inc");
include("DF80000.php");
include("JQUERY.inc");
//include("DIF_FECHAS.php");
$val2=0;
$val1=0;
$cuanta=0;
?>
<html>
<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 checaDaatos(){
	var fnombre=document.getElementById('fnombre');
	if(fnombre.value==""){
		alert('Complete el Nombre!!');
		return false;
	}
	return true;
}
</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>
<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;
}
</script>	
<style type="text/css">
BODY {
SCROLLBAR-FACE-COLOR:#0000CC; SCROLLBAR-HIGHLIGHT-COLOR:#00CCFF; SCROLLBAR-SHADOW-COLOR:#0000CC; SCROLLBAR-3DLIGHT-COLOR:#0000CC; SCROLLBAR-ARROW-COLOR:#FFFFFF; SCROLLBAR-TRACK-COLOR:#FFFFFF; SCROLLBAR-DARKSHADOW-COLOR: #330000
}
<!--
.Estilo16 {	font-size: 14px;
	font-weight: bold;
}
.Estilo17 {font-size: 14px}
.Estilo18 {font-weight: bold}
#Layer2 {	position:absolute;
	 left:568px;
	top:310px; 
	width:174px;
	height:63px;
	z-index:1;
	overflow:auto;
	right:auto;
	 ;
}
.Estilo19 {
	font-size: 16px;
	font-weight: bold;
}
.pp {
background-color:#666666;
 ;
}
-->
</style>
<body onLoad="sumaTex();restaTex();totalTex();">
<form  name="frm1" id="frm1" method="post" action="" >
<?php
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////checar habitaciones
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (isset($_POST['Submit2'])){
 include ("res_registro_AC.php");
}
if (!isset($_POST['Submit2'])){
	if (isset($_POST['fnumcto'])&&$_POST['fnumcto']!=''){
//CHECA HABITACION OCUPADA O DESCUPADA EN EL MOMENTO DE ESTAR INGRESANDO DATOS
	$fec = $_POST['ffecllegada'];
		include('DF20000.php');
		 $fini = $f_m;
		$fec = $_POST['ffecsalida'];
		include('DF20000.php');
		$fsal = $f_m;
	
//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='".$_POST['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='".$_POST['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='".$_POST['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='".$_POST['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>';
		$_POST['fnumcto']='';
		$_POST['ftipocto']='';
				
		}
	}	
}
	?>


 <table width="984"  align="center" onMouseOver="sumaTex();restaTex();totalTex();">
    <tr>
      <th colspan="14" class=\"titulo\"><div align="center">AGREGAR REGISTRO DE RESERVACIONES INDIVIDUALES </div></th></tr>
    <tr>
      <td width="61"><strong>ALTA:</strong></td>
      <td width="48"><input name="ffecalt" type="text" class="styTabEspA" id="ffecalt"  value="<?php
echo date('d/m/Y') ?>"size="7" ></td>
      <td width="132"><input name="fusualta" type="text" id="fusualta" disabled="disabled" size="20" value=" <?php
 
		echo  $_SESSION['usuario']  ;?>"></td>
      <td>&nbsp;</td>
      <td width="32">&nbsp;</td>
      <td width="54">&nbsp;</td>
      <td width="97">&nbsp;</td>
      <td width="75">&nbsp;</td>
      <td width="72"><strong>STATUS:</strong></td>
      <td colspan="2"><select name="select1">
        <option value="RESERVA INDIVIDUAL"<?php
if(isset($_REQUEST['select1']) && $_REQUEST['select1']=="RESERVA INDIVIDUAL") echo 'selected';?>>RESERVA INDIVIDUAL</option>
        </select></td></tr>
    <tr>
      <td colspan="2"><label><strong>FECHA DE LLEGADA.</strong> </label></td>
      <td><span class="Estilo32">
	  <input name="ffecllegada" type="text" class="emplea datefrom" id="ffecllegada" size="10" value="<?=date("d/m/Y")?>"
	  <?php
 
				$fecha = (isset($dt_empres['fec_alta']))?$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.'"'; 
			?>>
       <!-- <input name="ffecllegada" id="bot3" value="Cal" type="image" src="logos/cal4.jpg" onBlur="javascript: document.getElementById('frm1').submit()"/>
      --></span></td>
      <td colspan="2"><strong>DIAS.</strong></td>
     
	  <td>
	  
	  <?php
$lkjsa = daydiff (isset($_POST['ffecsalida'])?$_POST['ffecsalida']:date('Y-d-m'),(isset($_POST['ffecllegada']))?$_POST['ffecllegada']:date('Y-m-d'),'d/m/Y'); ?>

	  <input name="fnumctos" id="fnumctos" value="<?php
echo "".$lkjsa."";?>" type="text" size="5" readonly="readonly"></td>
	  <td colspan="3">&nbsp;</td>
	  <td colspan="5"><div align="center"><strong>NOTAS.</strong></div></td></tr>
    <tr>
      <td colspan="2"><strong>FECHA DE SALIDA.</strong> </td>
      <td><span class="Estilo32">
	  <input name="ffecsalida" type="text" class="emplea dateto" id="ffecsalida" size="10" value="<?=date("d/m/Y")?>"
	  <?php
 
				$fecha = (isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:date('Y-m-d');
                              //  echo $fecha;
 	            $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));
				}
				$wert = sumaDia($fecha,1);
				$lkj = chfecha($wert,'Y-m-d','d/m/Y');
				
				if(isset($_POST['ffecsalida']))
			  		echo 'value="'.$_POST['ffecsalida'].'"'; 
			  	else
			  		echo 'value="'.$lkj.'"'; 
			?>
	  >
     <!--   <input name="ffecsalida" id="bot2" value="Cal" type="image" src="logos/cal4.jpg" onBlur="javascript: document.getElementById('frm1').submit()"/>
      --></span></td>
      <td colspan="2"><strong>NUMERO DE ADULTOS.</strong></td>
      
      <td><input name="fnumadu" type="text" id="fnumadu" tabindex="1"
	  onBlur="may(this)" size="5"
	  		<?php

				if(isset($_POST['fnumadu'])){ //este es el truco
					echo 'value="' . $_POST['fnumadu'] .  '"';
				}
			?>/></td>
	  <?php
$aut_hab=mysqli_fetch_array(mysqli_query($con ,"select * from valeryus08 where ncto='".$_GET['cuarto']."'")); ?>		
      <td><strong>TIPO DE HABITACION.</strong></td>
      <td colspan="2"><input name="ftipocto" type="text" id="ftipocto" size="20" value="<?php
echo $aut_hab['ntipo'];?>" READONLY></td>
      <td colspan="5" rowspan="2"><div align="center"><span class="Estilo18">
		<textarea name="fnorasvip" cols="30" rows="3" id="fnorasvip" tabindex="4"
	  onBlur="may(this)"><?php

				if(isset($_POST['fnorasvip'])){ //este es el truco
					echo $_POST['fnorasvip'];
				}
			?></textarea></span></div></td></tr>
    <tr>
      <td colspan="2"><strong>HORA DE LLEGADA.</strong></td>
     
      <input name="fhorallega" type="text" class="tdan" id="fhorallega" value="<?php
echo date('H:i:s') ?>"size="9" ></td>
      <td colspan="2"><strong>NUMERO DE MENORES. </strong></td>
      <td><input name="fnummenor" type="text" id="fnummenor" tabindex="2"
	  onBlur="may(this)" size="5"
	  		<?php

				if(isset($_POST['fnummenor'])){ //este es el truco
					echo 'value="' . $_POST['fnummenor'] .  '"';
				}
			?>/></td>
      <td>
      <label><strong>NUMERO DE HABITACION.</strong></label></td>
      <td colspan="2"><input name="fnumcto" type="text" id="fnumcto" value="<?php
echo $aut_hab['ncto'];?>" READONLY
	  onBlur="may(this)" size="8"/></td>
    <tr>
      <th colspan="14" class="titulo"><div align="center" class="Estilo18">AGREGAR SEGMENTOS </div></th></tr>
    <tr>
      <td height="28"><span class="Estilo18">GRUPO.</span></td>
      <td colspan="3"><span class="Estilo18">
        <select name="fcodgrupo" id="fcodgrupo" onChange="javascript: document.getElementById('frm1').submit()" tabindex="5">
        <option value="">---------SELECCIONE---------</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM valeryus04");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['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"><strong>MERCADO.</strong></td>
      <td colspan="3"><span class="Estilo18">
        <select name="fcodmeca" id="fcodmeca" onChange="javascript: document.getElementById('frm1').submit()" tabindex="6">
          <option value="">-----SELECCIONE-----</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM tipmerca");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['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="69"><strong>EMPRESA.</strong></td>
      <td width="196"><select name="fempresa" id="fempresa" onChange="javascript: document.getElementById('frm1').submit()" tabindex="7">
        <option value="">-----SELECCIONE-----</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM fcompas");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['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 height="26"><span class="Estilo18">AGENCIA.</span></td>
      <td colspan="3"><span class="Estilo18">
        <select name="fcodagen" id="fcodagen" onChange="javascript: document.getElementById('frm1').submit()" tabindex="8">
        <option value="">--SELECCIONE--</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM valeryus07");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['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"><strong>PLAN.</strong></td>
      <td colspan="3"><span class="Estilo18">
        <select name="fplan" id="fplan" onChange="javascript: document.getElementById('frm1').submit()" tabindex="9">
          <option value="">--SELECCIONE--</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM pplan");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['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" onChange="javascript: document.getElementById('frm1').submit()" tabindex="10">
          <option value="">--SELECCIONE--</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM valeryus06");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['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 height="26"><strong>SMERF.</strong></td>
      <td height="26" colspan="11"><span class="Estilo1">
        <select name="smerf" id="smerf" onChange="javascript: document.getElementById('frm1').submit()" tabindex="11">
          <option value="">--SELECCIONE--</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM fsmerf");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['smerf']==$reg['descripcion'] ){
		echo '<option value="' . $reg['descripcion'] . '" selected>' . $reg['descripcion'] . '</option>';
	}else{
		echo '<option value="' . $reg['descripcion'] . '">' . $reg['descripcion'] . '</option>';
	}
}
?>
        </select>
      </span></td>
	  </tr>
	<?php

	$fechaInicial = (isset($_POST['ffecllegada']))?$_POST['ffecllegada']:"";    
     $fecha = daydiff (isset($_POST['ffecsalida'])?$_POST['ffecsalida']:"",(isset($_POST['ffecllegada']))?$_POST['ffecllegada']:"",'d/m/Y');
//	      $fecha = daydiff ('javascript.document.frm1.ffecsalida','javascript.document.frm1.ffecllegada','d/m/Y');
     //$MaxDias = 6;   
         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 (isset($_POST['ffecsalida'])?$_POST['ffecsalida']:"",(isset($_POST['ffecllegada']))?$_POST['ffecllegada']:"",'d/m/Y');
	?>
	<tr>
      <th colspan="14" class="titulo"><div align="center" class="Estilo18">AGREGAR FORMA DE PAGO </div></th></tr>
    <tr>
      <td>
		<strong>TARIFA ALTA</strong>
		<td colspan="8">        
	    <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
echo $aut_hab['ntfa_senc']; ?>"onMouseMove="sumaTex()" READONLY>
        <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>
		<td><strong>FORMA DE PAGO.</strong></td>
		<td><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($_POST['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="8"><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
echo $aut_hab['ntfa_doble'];?>" onMouseOver="restaTex()" READONLY>
      <input name="text5" type="text" id="text5" size="3" value="<?php
 if (isset($cuenta) && $cuenta==''){ echo '0'; }else{	echo "".(isset($$cuenta))?$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>
      </label></td>
      <td><strong>NUMERO D TARJETA.</strong></td>
		<td><input name="fnumtar" type="text" id="fnumtar" tabindex="15"
	  onBlur="may(this)" size="10"
	  		<?php

				if(isset($_POST['fnumtar'])){ //este es el truco
					echo 'value="' . $_POST['fnumtar'] .  '"';
				}
			?>/></td>
    </tr>
    <tr>
      <td><label><span class="Estilo16">TOTAL.</span></label></td>
      <td colspan="2"><span class="Estilo19">$</span>
        <input name="ftotal" type="text" id="ftotal" tabindex="18"	
		onBlur="may(this)" onMouseMove="totalTex()" size="15" READONLY
			<?php

				if(isset($_POST['ftotal'])){ //este es el truco
					echo 'value="' . $_POST['ftotal'] .  '"';
				}
			?>/></td><td><strong>DEPOSITO.</strong><strong></strong></td>
      <td colspan="2"><label><span class="Estilo17"><strong>$</strong></span>
          <input name="fsaldo" type="text" id="fsaldo" tabindex="15" size="5"
	  		<?php

				if(isset($_POST['fsaldo'])){ //este es el truco
					echo 'value="' . $_POST['fsaldo'] .  '"';
				}
			?>/>
      </label></td>
      <td><strong>CODIGO DE SEGURIDAD.</strong></td>
      <td colspan="2"><input name="fcodseg" type="text" id="fcodseg" tabindex="16"
	  onBlur="may(this)" size="15"
	  		<?php

				if(isset($_POST['fcodseg'])){ //este es el truco
					echo 'value="' . $_POST['fcodseg'] .  '"';
				}
			?>/></td>
      <td><strong>LIMITE.</strong></td>
      <td><input name="flimite" type="text" id="flimite" tabindex="17"
	  onBlur="may(this)" size="15"
	  		<?php

				if(isset($_POST['flimite'])){ //este es el truco
					echo 'value="' . $_POST['flimite'] .  '"';
				}
			?>/></td></tr>
	<tr>
      <th colspan="14" class="titulo"><div align="center" class="Estilo18">AGREGAR DATOS</div></th></tr>
    <tr>
      <td><strong>NOMBRE.</strong></td>
      <td colspan="2"><p><span class="Estilo1">
		  <textarea name="fnombre" cols="29" rows="3" id="fnombre" tabindex="4"
	  onBlur="may(this)"><?php

				if(isset($_POST['fnombre'])){ //este es el truco
					echo $_POST['fnombre'];
				}
			?></textarea></span> </p></td>
      <td width="78"><strong>APELLIDO.</strong></td>
      <td colspan="3"><span class="Estilo1">
		  <textarea name="fapellido" cols="25" rows="3" id="fapellido" tabindex="4"
	  onBlur="may(this)"><?php

				if(isset($_POST['fapellido'])){ //este es el truco
					echo $_POST['fapellido'];
				}
			?></textarea></span></td>
    <td><strong>TIPO DE HUESPED.</strong></td>
    <td colspan="2"><select name="ftiphuesped" id="ftiphuesped" onChange="javascript: document.getElementById('frm1').submit()" tabindex="22">
        <option value="">--SELECCIONE--</option>
      <?php
 
$sql = mysqli_query($con ,"SELECT * FROM tiphuesped");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['ftiphuesped']==$reg['tpdescrip'] ){
		echo '<option value="' . $reg['tpdescrip'] . '" selected>' . $reg['tpdescrip'] . '</option>';
	}else{
		echo '<option value="' . $reg['tpdescrip'] . '">' . $reg['tpdescrip'] . '</option>';
	}
}
?></select></td>
      <td colspan="2"><div align="center"><span class="Estilo19">VIP.</span><span class="Estilo1">
        <input name="fvip" type="checkbox" id="fvip" value="SI"<?php
if(isset($_REQUEST['fvip']) &&$_REQUEST['fvip']) echo 'checked';?>></span></div></td></tr>
    <tr>
      <td><strong>TELEFONO.</strong></td>
      <td colspan="2"><input name="ftelefono" type="text" id="ftelefono" tabindex="20"
	  onBlur="may(this)" size="30"
	  		<?php

				if(isset($_POST['ftelefono'])){ //este es el truco
					echo 'value="' . $_POST['ftelefono'] .  '"';
				}
			?>/></td>
      <td><strong>TELEFONO EMPRESA.</strong></td>
      <td colspan="3"><input name="ftelemp" type="text" id="ftelemp" tabindex="21"
	  onBlur="may(this)" size="28"
	  		<?php

				if(isset($_POST['ftelemp'])){ //este es el truco
					echo 'value="' . $_POST['ftelemp'] .  '"';
				}
			?>/></td>
      <td><strong>E-MAIL.</strong></td>
      <td colspan="3"><input name="fmail" type="text" id="fmail" tabindex="23" size="35"
	  		<?php

				if(isset($_POST['fmail'])){ //este es el truco
					echo 'value="' . $_POST['fmail'] .  '"';
				}
			?>/></td></tr>
    <tr>
      <td><span class="Estilo1">E-MAIL EMPRESA.</span></td>
      <td colspan="2"><input name="femail" type="text" id="femail" tabindex="24" size="30"
	  		<?php

				if(isset($_POST['femail'])){ //este es el truco
					echo 'value="' . $_POST['femail'] .  '"';
				}
			?>/></td>
	  <td><strong>DIRECCION.</strong></td>
      <td colspan="3"><input name="fdireccion" type="text" id="fdireccion" tabindex="25"
	  onBlur="may(this)" size="25"
	  		<?php

				if(isset($_POST['fdireccion'])){ //este es el truco
					echo 'value="' . $_POST['fdireccion'] .  '"';
				}
			?>/>
        <span class="Estilo1">
        <input name="?3" type="button" class="pp" onClick="window.open('DX40000_AG1.php?retPag=res_registro_AG.php','popuppage','width=750,height=300,top=100,left=50,scrollbars=yes,menubar=yes,status=yes')" value="...." >
        </span></td>
      <td><span class="Estilo1">CODIGO POSTAL.</span></td>
      <td><input name="tcp" type="text" onKeyPress="return validar(event)" value="<?php
echo (isset($_REQUEST['tcp'])?$_REQUEST['tcp']:"" );?>" size="8" maxlength="5" tabindex="27"></td>
      <td><strong>COLONIA.</strong></td>
      <td colspan="2"><span class="Estilo1">
        <input type="hidden" name="tcol1" id="tcve" value="<?php
echo $_REQUEST['tcve'];?>">
        <input name="tcol" type="text" id="tcol" value="<?php
echo (isset($_REQUEST['tcol'])?$_REQUEST['tcol']:"" );?>" size="25" tabindex="26"></span></td></tr>
    <tr>
      <td><strong>PAIS.</strong></td>
      <td colspan="2"><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>
      <td><strong>ESTADO.</strong></td>
      <td colspan="3"><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="Estilo1">DELEGACION MUNICIPIO.</span></td>
      <td colspan="4"><span class="Estilo1">
        <select name="tmun" id="tmun" tabindex="30" >
          <option  value="">-----SELECCIONE-----</option>
          <?php
 
		@$resultado=mysqli_query($con ,"select * from dxdelmun where cve_estado='$selEnt' and cve_pais='$selPais'");
		if(!isset($_REQUEST['tmun'])){
			$dt_delmun=mysqli_fetch_array($resultado);
			$selDelMun=$dt_delmun['cve_delmun'];
			if(mysqli_num_rows($resultado)>0)
				mysqli_data_seek($resultado,0);		
		}else{
			$selDelMun=$_REQUEST['tmun'];
		}
		while(@$registro=mysqli_fetch_array($resultado)){
			if($selDelMun==$registro['cve_delmun']){ 
				echo '<option value="' . $registro['cve_delmun'] . '" selected>' .$registro['des_delmun'] . '</option>';
			}else{
				echo '<option value="' . $registro['cve_delmun'] . '">' . $registro['des_delmun'] . '</option>';
			}
		}
?>
        </select></span></td></tr>
	<tr>
      <td colspan="14"><div align="center">
        <input name="Submit2" type="submit" class="pp" tabindex="31" value="Guardar" />
        &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="Submit2" type="button" class="pp" tabindex="32" onClick="openpage('ger_mapeo_PR.php','_self')" value="Regresar"/>
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>
<?php

//781 --> 500 ultima actualizacion 13/FEBRERO/2012 
?>