<?php
session_start();
$com = "A";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DF80000.php");
include("DFJQUERY.inc");
//include("DIF_FECHAS.php");
include("JQUERY.inc");
include ("varfun.php"); 

$val1=0;
$val2=0;
$cuenta=0;
$Segundos=0;
if (isset($_POST['Submit2'])){
 include ("res_registro_AC.php");
}

if (isset($_GET['multiplo'])){
if ($_POST['bot']==""){
	echo '<h2>!!! SELECCIONE UN REGISTRO !!!</h2>';
	echo '<meta content="1; url=res_registro_PR.php"  HTTP-EQUIV="REFRESH">';

}else{
	
	include('rec_checkin_CL.php');
	$varible_clase = new clase();
	//echo $_POST["bot"];
	$res=$varible_clase->lista_busqueda($_POST["bot"]);
	$reg=mysqli_fetch_array($res);

	$_POST['fcodtarifa']=$reg['fcodtarifa'];
	$_POST['fnumres']=$reg['fnumres'];
//	$_POST['fnumcto']=$reg['fnumcto'];
	$_POST['fmuncto']=$reg['fmuncto'];
	$_POST['ffecllegada']=chfecha($reg['ffecllegada'],'Y-m-d','d/m/Y');
	$_POST['ffecsalida']=chfecha($reg['ffecsalida'],'Y-m-d','d/m/Y');
	$_POST['fnumadu']=$reg['fnumadu'];
	$_POST['fnummenor']=$reg['fnummenor'];
	$_POST['fhorallega']=$reg['fhorallega'];
	$_POST['fnumctos']=$reg['fnumctos'];
	$_POST['ffecalt']=chfecha($reg['ffecalt'],'Y-m-d','d/m/Y');
	//$_POST['ftipocto']=$reg['ftipocto'];
	$_POST['select1']=$reg['status'];
	$_POST['fusualta']=$reg['fusualta'];
	
	//forma de pago
	$_POST['fformpago']=$reg['fformpago'];
	$_POST['fnumtar']=$reg['fnumtar'];
	$_POST['fsaldo']=$reg['fsaldo'];
	$_POST['flimite']=$reg['flimite'];
	$_POST['fcodseg']=$reg['fcodseg'];
	$_POST['codseg']=$reg['codseg'];
	//datos
	$_POST['fcodgrupo']=$reg['fcodgrupo'];
	$_POST['fcodagen']=$reg['fcodagen'];
	$_POST['fcodmeca']=$reg['fcodmeca'];
	$_POST['fplan']=$reg['fplan'];
	$_POST['smerf']=$reg['smerf'];
	$_POST['fnorasvip']=$reg['fnorasvip'];
        $_POST['extra4']=$reg['extra4'];
	//direccion
	$_POST['fnombre']=$reg['fnombre'];
	$_POST['fapellido']=$reg['fapellido'];
	$_POST['flengua']=$reg['flengua'];
	$_POST['fempresa']=$reg['fempresa'];
	$_POST['ftelefono']=$reg['ftelefono'];
	$_POST['fvip']=$reg['fvip'];
	$_POST['tipo']=$reg['tipo'];
	$_POST['femail']=$reg['femail'];
	$_POST['fmail']=$reg['fmail'];
	$_POST['fdireccion']=$reg['fdireccion'];
	$_POST['tcol']=$reg['fgntd'];
	$_POST['tcp']=$reg['fcp'];
	$_POST['pais']=$reg['fpais'];
	$_POST['estados']=$reg['festado'];
	$_POST['tmun']=$reg['fciudad'];
	$_POST['fvehiculo']=$reg['fvehiculo'];
	$_POST['fplacas']=$reg['fplacas'];
	$_POST['ftelemp']=$reg['ftelemp'];
	$_POST['ftiphuesped']=$reg['ftiphuesped'];
	$_POST['cuarto_seguro']=$reg['cuarto_seguro'];
	$_POST['tex']=$reg['tex'];
	$_POST['tex2']=$reg['tex2'];
	$_POST['tex3']=$reg['tex3'];
	$_POST['tex4']=$reg['tex4'];
	$_POST['tex5']=$reg['tex5'];
	$_POST['tex6']=$reg['tex6'];
	$_POST['text1']=$reg['text1'];
	$_POST['text2']=$reg['text2'];
	$_POST['text3']=$reg['text3'];
	$_POST['text4']=$reg['text4'];
	$_POST['text5']=$reg['text5'];
	$_POST['text6']=$reg['text6'];
	$_POST['ftotal']=$reg['ftotal'];
	$_POST['fdeposito']=$reg['fdeposito'];
	$_POST['edades']=$reg['edades'];
	
	}
}

?>
<html> 
<head> 
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>

<script type="text/javascript" language="JavaScript1.2" src="RSSCRIPT.js?d"></script>

   </head>
   <script language="javascript">
$(document).ready(function(){
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0];
	}
	var pagRes='valeryus51100_CPS.php';
	var idObjDes='ftarifaxa';
	var idObjCve='ia';//esto es num de adultos no id de tarifa
	var idObjTotal='fmonadu';
	//var idObjManual='manual';
	
	var nomObjRad='tip_bus_ope';
        
	
//ademas el autocomplete se va a ejecutar con la descripcion no con la clave

	$("#"+idObjDes).autocomplete({
            source:pagRes,
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		max:20,                      //maximo de resultados mostrados, se manda como limit en autosugestion
		                 //ancho del cuadro de despliegue
		 delay: 200,           //Resalta letras coincidentes
		autoFill: true,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 100,           //alto del cuadro para el scroll
		
                           select: function( event, ui ) {
                        
                     $("#"+idObjDes).val( ui.item.gdescrip);
		$("#"+idObjTotal).val(ui.item.gtotal);
         }
 //Parametros Extra a Mandar en autosugestion
	});	
	
});
<!--
$(document).ready(function(){
	function formatItem(row) {
		return " (<strong>" + row[1] + "</strong>)"+row[0];
	}
	var pagRes='valeryus51100_CPS.php';
	var idObjDes='ftarifaxm';
        var idObjCve='im';
	var idObjTotal='fmonmen';
	var nomObjRad='tip_bus_ope';
        
	
//ademas el autocomplete se va a ejecutar con la descripcion no con la clave

	$("#"+idObjCve).autocomplete( {
            source:pagRes,
		minChars: 1,                 //Caracteres Minimos antes de autocompletar
		max:20,                      //maximo de resultados mostrados, se manda como limit en autosugestion
		                 //ancho del cuadro de despliegue
		 delay: 200,           //Resalta letras coincidentes
		autoFill: true,             //autocompleta en texto la posible palabra
		scroll: true,				 //si cuadro tiene barra scroll
		scrollHeight: 100,           //alto del cuadro para el scroll
		
                           select: function( event, ui ) {
                        
                     $("#"+idObjDes).val( ui.item.gdescrip);
		$("#"+idObjTotal).val(ui.item.gtotal);
            }
    });	
    
}); 
-->
</script>
<style type="text/css">
.Estilo26 {color: #000}
-->
th {
    padding: 1px;
    padding-bottom: 1px;
    padding-left: 1px;
    padding-right: 1px;
    padding-top: 1px;
}

</style>
<body onLoad=" self.focus ();  restaFechas()">
<div align="center">
<form  name="frm1" id="frm1" method="post" action="" enctype="multipart/form-data">
<input name="bot" type="hidden" class="styTabEspA" id="bot"  value="<?php echo $_POST['bot'];?>" size="7" >  
    <?php
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////checar habitaciones
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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 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' and cancelado='0' group by fnumcto  "));
  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' and cancelado='0' group by fnumcto "));
  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' and cancelado='0' group by fnumcto "));
		$consul=mysqli_query($con ,"SELECT  count(*) as numRows, fnumcto,ffecllegada FROM valeryus19 WHERE fnumcto='".$_POST['fnumcto']."'  AND ffecllegada < '$fsal' AND ffecsalida >= '$fsal' and cancelado='0' group by fnumcto,ffecllegada ");
  echo mysqli_error($con);
  $dt_user2=mysqli_fetch_array($consul);
  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']='';
				
		}
	}	
}
	?>
 <div id="width_wrapper" align="left">
  <table width="984" align="center" >
    <tr>
      <td pading colspan="13" class="titulo"><div color="#000" align="center"> <span class="Estilo26">AGREGAR REGISTRO DE RESERVACIONES INDIVIDUALES </span></div></td></tr>
    <tr>
      <th width="61" ><div align="left"><strong>ALTA</strong></div></th>
      <td colspan="4" ><input name="ffecalt" type="text" class="styTabEspA" id="ffecalt"  value="<?php
 echo date('d/m/Y') ?>"size="7" >        <input name="fusualta" type="text" id="fusualta" disabled="disabled" size="15" value=" <?php
 
		echo  $_SESSION['usuario']  ;?>"></td>
      <th ><span class="Estilo20">ID OTA</span></th>
      <td colspan="2" ><span class="priDat">
        <input name="id_cli" type="text" id="id_cli" size="10" value="<?php
  echo (isset($_POST['id_cli']))?$_POST['id_cli']:"";?>">
      </span><span class="priDat">
     
      </span></td>
<td colspan="2" >

<span class="priDat">
        <input name="id_cli" type="text" placeholder="GUEST" id="id_cli" size="10" value="<?php
  echo (isset($_REQUEST['id_cli']))?$_REQUEST['id_cli']:"";?>">
      </span><span class="priDat">
      <input name="nom_cli" type="text" placeholder="HISTORY" id="nom_cli" size="50" value="<?php
  echo (isset($_REQUEST['nom_cli']))?$_REQUEST['nom_cli']:""; ?>">
      </span>
</td>
      </tr>
    <tr>
      <th ><span class="Estilo21"><label>
        <div align="left"><strong>FECHA DE LLEGADA</strong> </div>
        </label>
      </span></th>
      <td ><span class="Estilo32">
              <?php $fec_alta=(isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:date('Y-m-d');?>
	  <input name="ffecllegada" type="text" class="emplea datefrom" id="ffecllegada" size="10" tabindex="1"  onBlur="valFecha(this); " onChange="valFecha(this)"
	  <?php 
 
				//if(!isset($dt_empres['fec_alta']))$dt_empres['fec_alta']="";
				$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.'"'; 
			?> />
        
      </span></td>
      <th colspan="2" ><div align="left"><span class="Estilo21"><strong>NUMERO DE ADULTOS</strong></span></div></th>
   
	  <td width="54" ><input name="fnumadu" type="text" id="fnumadu" tabindex="3"
	  onBlur="may(this)" size="5"
	  		<?php

				if(isset($_POST['fnumadu'])){ //este es el truco
					echo 'value="' . $_POST['fnumadu'] .  '"';
				}
			?>/>	  </td>
          <label>
	 <td colspan="3" >  <div align="center"><span class="Estilo1">
          <input name="?323" type="button" class="tragre" tabindex="6" onClick="
	  	openWindow(
		{ 
			action:'FRGC20000.php',
			width:700,
			height:350
		},{
			val:'fnumcto',
			des:'ftipocto'
		})" value="Buscar Habitacion" >
                             </span></div></td>
        </label>
      <th colspan="5" ><div align="center" class="Estilo21"><strong>NOTAS</strong></div></th></tr>
    <tr>
      <th ><div align="left"><span class="Estilo21"><strong>FECHA DE SALIDA</strong></span></div></th>
      <td ><span class="Estilo32">
              <?php $fec_alta=(isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:date('Y-m-d');?>
              <input name="ffecsalida" type="text" class="emplea dateto" id="ffecsalida" size="10" tabindex="2"  onBlur="valFecha(this);restaFechas();" onChange="valFecha(this);"
	  <?php
 
				$fecha = (isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:date("Y-m-d");
 	            $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.'"'; 
			?>
	  />
          </span>  
   </td>
      <th colspan="2" ><div align="left"><span class="Estilo21"><strong>NUMERO DE MENORES</strong></span></div></th>
     
      <td ><input name="fnummenor" type="text" id="fnummenor" tabindex="4"
	  onBlur="may(this)" size="5"
	  		<?php

				if(isset($_POST['fnummenor'])){ //este es el truco
					echo 'value="' . $_POST['fnummenor'] .  '"';
				}
			?>/></td>
      <th width="97" ><div align="left"><strong>TIPO DE HABITACION</strong></div></th>
      <td colspan="2" ><input name="ftipocto" type="text" id="ftipocto" size="20" READONLY
	  <?php

				if(isset($_POST['ftipocto'])){ //este es el truco
					echo 'value="' . $_POST['ftipocto'] .  '"';
				}
			?>></td>
      <td colspan="5" rowspan="1">, 
        <div align="center"><span class="Estilo1">
          <textarea name="fnorasvip" cols="30" rows="3" id="fnorasvip" tabindex="7"
	  onBlur="may(this)"><?php

				if(isset($_POST['fnorasvip'])){ //este es el truco
					echo $_POST['fnorasvip'];
				}
			?>
        </textarea>
        </span></div></td>
    </tr>
    <tr>
      <th ><div align="left"><span class="Estilo21"><strong>NOCHES</strong></span></div></th>
      <td ><?php
$varfs=(isset($_POST['ffecsalida']))?$_POST['ffecsalida']:"";
$vare=(isset($_POST['ffecllegada']))?$_POST['ffecllegada']:"";
      $lkjsa = daydiff ($varfs,$vare,'d/m/Y'); ?>

	    <input name="fnumctos" id="fnumctos" value="<?php
 echo "".$lkjsa."";?>" type="text" size="5" readonly="readonly"></td>
      <th colspan="2" ><div align="left"><span class="Estilo21"><strong>EDADES DE MENORES</strong></span></div></th>
      <td ><input name="edades" type="text" id="edades" tabindex="5"
	  onBlur="may(this)" size="5"
	  		<?php

				if(isset($_POST['edades'])){ //este es el truco
					echo 'value="' . $_POST['edades'] .  '"';
				}
			?>/></td>
      <th ><span class="Estilo21"><label></label>
        <div align="left"><strong>NUMERO DE HABITACION</strong></div>
        </span></th>
      <td colspan="2" ><input name="fnumcto" type="text" id="fnumcto" READONLY
	  onBlur="may(this)" size="8"
	  		<?php

				if(isset($_POST['fnumcto'])){ //este es el truco
					echo 'value="' . $_POST['fnumcto'] .  '"';
				}
			?>/></td>
      <th ><span class="Estilo21"><label></label>
        <div align="center"><strong>NOTAS INTERNAS</strong></div>
        </span></th>
        <td colspan="2" rowspan="1">, 
        <div align="center"><span class="Estilo1">
          <textarea name="extra4" cols="30" rows="3" id="extra4" tabindex="7"
	  onBlur="may(this)"><?php

				if(isset($_POST['extra4'])){ //este es el truco
					echo $_POST['extra4'];
				}
			?>
        </textarea>
        </span></div></td>

      
      
    </tr>
      <tr>
      <td colspan="13" class="titulo"><div align="center" class="Estilo26">AGREGAR FORMA DE PAGO </div></td></tr>
    <tr>
      <th ><div align="left"><span class="Estilo21"><strong>TARIFA</strong></span>
      </div>
      <td colspan="5" >
      
              <input name="tex" type="text" autocomplete="OFF" id="tex" size="5" value="<?php
          echo (isset($_POST['tex']))?$_POST['tex']:""; ?>" tabindex="8" /> 
         
	  <input name="tex2" type="text" id="tex2" size="40" value="<?php
 echo (isset($_POST['tex2']))?$_POST['tex2']:""; ?>"  READONLY/> 
	  <!--input name="text3" type="text" id="text3" size="4" value="<?php
 //echo $_POST['text3']; ?>" READONLY-->
        <span class="Estilo17"><strong>$</strong></span>
        <input name="manual" type="hidden" id="manual" size="3" value="<?php
 echo $_POST['manual'];?>"/>
		<?php

		@$sql = mysqli_query($con ,"select * from dxopemaex where nombre like '".$_SESSION['usuario']."'");
        @$reg = mysqli_fetch_array($sql);
		if(!isset($_POST['manual']))$_POST['manual']="";
		if ($_POST['manual']=='SI' and $reg['manual']=='1'){?>
		<input name="tex4" type="text" id="tex4" size="5" value="<?php
 if (isset($_POST['tex4'])&&$_POST['tex4']!='') { echo $_POST['tex4']; } else { echo '0'; }?>" onMouseOver="restaTex()" />
		<?php
 }else{ ?>
		<input name="tex4" type="text" id="tex4" size="5" value="<?php
  if (isset($_POST['tex4'])&&$_POST['tex4']!='')  { echo $_POST['tex4']; } else { echo '0'; }?>" onMouseOver="restaTex()" READONLY>
		<?php
 } ?>
        <?php
//<input name="tex5" type="text" id="tex5" size="3" value="<?php
if (isset($cuenta)&&$cuenta==''){ echo '0';	}else{ echo "".$cuenta.""; } ?>
		


		<?php

		//<input name="tex6" type="text" id="tex6" size="8" onMouseOver="restaTex()" value="<?php
//echo $_POST['tex6']; ?k>" READONLY>
		//elimar rec_chin_AG3.php
		?>
      <th><div align="left"><span class="Estilo21"><strong>FORMA DE PAGO</br></br>FOLIO DE PAGO</strong></span>    
      </div>
      <td colspan="4" ><span class="Estilo1">
      <select name="fformpago" id="fformpago" tabindex="9">
        <option value="">---SELECCIONE---</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM valeryus09 WHERE pmontomax = 'ABONO' AND ppago = 'SI' order by descripcion");
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> 
        
<!--      </br> <span class="Estilo21"><strong><span class="Estilo20">Folio</span>-->
        </br></br><label class="Estilo20"><span class="Estilo24">
        <input name="folio_pago" size="5" placeholder="Folio de pago" type="number" id="folio_pago" onBlur="may(this)"value="<?php
                                                                                               echo (isset($_POST['folio_pago']))?$_POST['folio_pago']:"";?>" /></span></label></strong></span>
        </td>
      
          <!--<th ><div align="left"><span class="Estilo21"><strong><span class="Estilo20">Folio</span></strong></span></div></th>
        <td colspan="5" ><label class="Estilo20"><span class="Estilo24">
        <input name="folio_pago" type="text" id="folio_pago" onBlur="may(this)"value="--><?php
                                                                                      /*echo (isset($_POST['folio_pago']))?$_POST['folio_pago']:"";*/?>" <!--/></span></label></td>-->
      </tr>
    
    <tr>
      <th ><div align="left"><span class="Estilo21"><strong><span class="Estilo20">NoADULTO  EXTRA</span></strong></span></div></th>
      <td colspan="5" ><label class="Estilo20"><span class="Estilo24">
        <input name="fnumadulx" type="text" id="fnumadulx" onBlur="may(this)" size="5" value="<?php
  echo (isset($_POST['fnumadulx']))?$_POST['fnumadulx']:"";?>" />
      </span><span class="Estilo24">
      <input name="ftarifaxa" type="text" id="ftarifaxa" size="40" value="<?php
 echo (isset( $_POST['ftarifaxa']))? $_POST['ftarifaxa']:"";?>" />
      </span><span class="Estilo24">
      <input name="fmonadu" type="text" id="fmonadu" size="5" value="<?php
      $varfm=(isset($_POST['fmonadu']))?$_POST['fmonadu']:"";
 if ($varfm!='') { echo $varfm ; } else { echo '0'; }?>" READONLY />
      </span></label></td>
      <th ><div align="left"><span class="Estilo21"><strong>NUMERO DE TARJETA</strong></span></div></th>
      <td colspan="3" ><input name="fnumtar" type="text" id="fnumtar" tabindex="10"
	  onBlur="may(this)" size="26"
	  		<?php

				if(isset($_POST['fnumtar'])){ //este es el truco
					echo 'value="' . $_POST['fnumtar'] .  '"';
				}
			?>/></td>
      </tr>
    <tr>
      <th ><div align="left"><span class="Estilo20">NoMENOR EXTRA</span></div></th>
      <td colspan="5" ><span class="Estilo24">
        <input name="fnummenorx" type="text" id="fnummenorx" onBlur="may(this)" size="5" value="<?php
  echo (isset($_POST['fnummenorx']))?$_POST['fnummenorx']:"";?>" />
      </span><span class="Estilo22">
      <input name="ftarifaxm" type="text" id="ftarifaxm" size="40" value="<?php
 echo (isset($_POST['ftarifaxm']))?$_POST['ftarifaxm']:"";?>" />
      </span><span class="Estilo22">
      <input name="fmonmen" type="text" id="fmonmen" size="5" value="<?php
      $varfn=(isset($_POST['fmonmen']))?$_POST['fmonmen']:"";
 if ($varfn!='') { echo $varfn; } else { echo '0'; }?>" READONLY />
      </span></td>
      <th ><div align="left"><span class="Estilo21"><strong>EXPIRA</strong></span></div></th>
      <td width="72" ><input name="flimite" type="text" id="flimite" tabindex="11"
	  onBlur="may(this)" size="10"
	  		<?php

				if(isset($_POST['flimite'])){ //este es el truco
					echo 'value="' . $_POST['flimite'] .  '"';
				}
			?>/></td>
      <th width="69" ><strong class="Estilo20">CODIGO DE SEGURIDAD</strong></th>
      <td width="196" ><input name="fcodseg" type="text" id="fcodseg" tabindex="12"
	  onBlur="may(this)" size="10"
	  		<?php

				if(isset($_POST['fcodseg'])){ //este es el truco
					echo 'value="' . $_POST['fcodseg'] .  '"';
				}
			?>/><?php

	 $fechaInicial = (isset($_POST['ffecllegada']))?$_POST['ffecllegada']:""; 
         
     //$fecha = daydiff ($_POST['ffecsalida'],$_POST['ffecllegada'],'d/m/Y');
     $fecha = daydiff ($varfs,$vare,'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 ($varfs,$vare,'d/m/Y');
	?></td>
    </tr>
	<tr>
      <td colspan="13" class="titulo"><div align="center" class="Estilo26">AGREGAR SEGMENTOS </div></td></tr>
    <tr>
      <th height="28" ><div align="left"><span class="Estilo20">AGENCIA</span></div></th>
      <td colspan="4" ><span class="Estilo1">
        <select name="fcodagen" id="fcodagen" tabindex="13">
          <option value="">--SELECCIONE--</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM valeryus07 order by agdescrip");
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>
      <th ><div align="left"><span class="Estilo21"><strong>PLAN</strong></span></div></th>
      <td colspan="4" ><span class="Estilo1">
        <select name="fplan" id="fplan" tabindex="14">
          <option value="">--SELECCIONE--</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM pplan order by pdescrip");
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>
    </tr>
    <tr>
      <th height="26" ><div align="left"><strong>EMPRESA</strong></div></th>
      <td colspan="4" ><select name="fempresa" id="fempresa" tabindex="15">
        <option value="">-----SELECCIONE-----</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM fcompas order by pdesco");
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>';
	}
}
          ?> 
          
          
          
          <th height="26" ><div align="left"><strong>MERCADO</strong></div></th>
      <td height="26" ><select name="fcodmeca" id="fcodmeca" tabindex="17">
	   <option value="">--SELECCIONE--</option>
          <?php
 
$sql = mysqli_query($con ,"SELECT * FROM tipmerca order by tdescrip");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['fcodmeca']==$reg['tdescrip'] ){
		echo '<option style="background-color:'.$reg["color"].'" value="' . $reg['tdescrip'] . '" selected>' . $reg['tdescrip'] . '</option>';
	}else{
		echo '<option style="background-color:'.$reg["color"].'" value="' . $reg['tdescrip'] . '">' . $reg['tdescrip'] . '</option>';
	}
}
?>
        </select>       </td>
          
          
          </tr>
          
   <!---  SMERFS     
          
      </select></td>
      <th ><div align="left"><strong>SMERF</strong></div></th>
      <td colspan="5" ><span class="Estilo1">
        <!---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 ORDER BY gdescrip");
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-->
 <!--       <select name="smerf" id="smerf"  tabindex="16">
          <option value="">--SELECCIONE--</option>
          <?php/*
 
$sql = mysqli_query($con ,"SELECT * FROM fsmerf order by descripcion");
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>
    
    
    -->
    
    
    <tr>
      <!--<th height="26" ><div align="left"><strong>MERCADO</strong></div></th>
      <td height="26" ><select name="fcodmeca" id="fcodmeca" tabindex="17">
	   <option value="">--SELECCIONE--</option>
          <?php
/* 
$sql = mysqli_query($con ,"SELECT * FROM tipmerca order by tdescrip");
while($reg=mysqli_fetch_array($sql)){
	if($_POST['fcodmeca']==$reg['tdescrip'] ){
		echo '<option style="background-color:'.$reg["color"].'" value="' . $reg['tdescrip'] . '" selected>' . $reg['tdescrip'] . '</option>';
	}else{
		echo '<option style="background-color:'.$reg["color"].'" value="' . $reg['tdescrip'] . '">' . $reg['tdescrip'] . '</option>';
	}
}*/
?>
        </select>       </td>-->
        
    
        <!--
        
	  <th height="26" ><div align="left"><strong>SEGMENTO</strong></div></th>
	  <td height="26" colspan="3" ><select name="codseg" id="codseg"  tabindex="18" >
        <option value="">--SELECCIONE--</option>
        <?php
 /*
$sql_seg = mysqli_query($con ,"SELECT descripcion FROM valeryus06 order by descripcion");
while($reg_seg=mysqli_fetch_array($sql_seg)){
	if($_POST['codseg']==$reg_seg['descripcion'] ){
		
		echo '<option value="' . $reg_seg['descripcion'] . '" selected>' . $reg_seg['descripcion'] . '</option>';     
	}else{
		echo '<option value="' . $reg_seg['descripcion'] . '">' . $reg_seg['descripcion'] . '</option>';
	    //echo '<input name="asd" id="asd" value="'.$reg_seg['stipodaily'].'" />';
	}
	 //echo '<input name="asd" id="asd" value="'.$reg_seg['stipodaily'].'" />';
}
*/
?>
      </select>
	    <?php
 //$olkkjd = mysqli_query($con ,"select stipodaily from valeryus06 where descripcion='".$_POST['codseg']."' order by descripcion");
		 //$rfgty = mysqli_fetch_array($olkkjd);
		 ?>
		 
		  <!--input name="fcodmeca" type="text" id="fcodmeca" value="<?php
 //echo $rfgty["stipodaily"];?>" readonly=""/--><!--</td> -->
        
        
        
        
        
	  <th height="26" ><div align="left"><strong>COMO SE ENTERO? </strong></div></th>
	  <td height="26" colspan="4" ><select name="ftiphuesped" id="ftiphuesped" tabindex="19">
        <option value="">--SELECCIONE--</option>
        <?php
 
$sql = mysqli_query($con ,"SELECT * FROM tiphuesped order by tpdescrip");
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>
	  </tr>
	
	
	<tr>
      <td colspan="13" class="titulo"><div align="center" class="Estilo26">AGREGAR DATOS</div></td></tr>
    <tr>
      <th ><div align="left"><span class="Estilo20">NOMBRE</span></div></th>
      <td ><p><span class="Estilo1">
	  <textarea name="fnombre" cols="29" rows="3" id="fnombre" tabindex="20"
	  onBlur="may(this)"><?php

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

				if(isset($_POST['fapellido'])){ //este es el truco
					echo $_POST['fapellido'];
				}
			?></textarea></span></td>
    <th width="75" ><div align="left"><span class="Estilo20">TELEFONO</span></div></th>
    <td colspan="4" ><input name="ftelefono" type="text" id="ftelefono" tabindex="22"
	  onBlur="may(this)" size="25"
	  		<?php

				if(isset($_POST['ftelefono'])){ //este es el truco
					echo 'value="' . $_POST['ftelefono'] .  '"';
				}
			?>/></td>
      </tr>
    <tr>
      <th ><div align="left"><span class="Estilo20">TELEFONO EMPRESA</span></div></th>
      <td ><input name="ftelemp" type="text" id="ftelemp" tabindex="23"
	  onBlur="may(this)" size="25"
	  		<?php

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

				if(isset($_POST['fmail'])){ //este es el truco
					echo 'value="' . $_POST['fmail'] .  '"';
				}
			?>/></td>
      <th ><div align="left"><span class="Estilo1 Estilo21">E-MAIL EMPRESA</span></div></th>
      <td colspan="3" ><input name="femail" type="text" id="femail" tabindex="25" size="27"
	  		<?php

				if(isset($_POST['femail'])){ //este es el truco
					echo 'value="' . $_POST['femail'] .  '"';
				}
			?>/></td>
    </tr>
    <tr>
      <th ><div align="left"><span class="Estilo20">DIRECCION</span></div></th>
      <td ><input name="fdireccion" type="text" id="fdireccion" tabindex="26"
	  onBlur="may(this)" size="25"
	  		<?php

				if(isset($_POST['fdireccion'])){ //este es el truco
					echo 'value="' . $_POST['fdireccion'] .  '"';
				}
			?>/></td>
	  <th ><div align="left"><strong>COLONIA</strong></div></th>
      <td colspan="3" ><span class="Estilo1">
        <input type="hidden" name="tcol1" id="tcve" value="<?php
 echo $_POST['tcve'];?>">
        <input name="tcol" type="text" id="tcol" value="<?php
 echo (isset($_POST['tcol']))?$_POST['tcol']:"";?>" size="20" tabindex="27">
      </span></td>
      <th ><div align="left"><span class="Estilo1 Estilo21">CODIGO POSTAL</span></div></th>
      <td colspan="2" ><input name="tcp" type="text" onKeyPress="return validar(event)" value="<?php
 echo (isset($_POST['tcp']))?$_POST['tcp']:"";?>" size="10" maxlength="5" tabindex="28" id="tcp">
        <span class="Estilo1">
        <input name="?3" type="button" class="original" 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>
      
        
        
        
        <th colspan="2" ><div align="center"><span class="Estilo19">V.I.P.</span><span class="Estilo1">
        <input name="fvip" type="checkbox" id="fvip" value="SI"<?php
  if(isset($_POST['fvip'])&&$_POST['fvip']) echo 'checked';?>>
            
      </span><span class="Estilo19">Serv. Esp.</span>
            <input name="con_1" type="checkbox" id="con_1" value="1"<?php
  if(isset($_POST['con_1'])&&$_POST['con_1']) echo 'checked';?>>
  
  <span class="Estilo19">No Mover.</span>
            <input name="tipo" type="checkbox" id="tipo" value="1"<?php
  if(isset($_POST['tipo'])&&$_POST['tipo']) echo 'checked';?>></div>
  
  
  </th>
        
        
        
    </tr>
    <tr>
      <th ><div align="left"><span class="Estilo21"><strong>PAIS</strong></span></div></th>
      <td ><span class="Estilo1">
        <select name="pais" id="pais" onChange="getEstados(this.value)" >
          <option value="">-----SELECCIONE-----</option>
          <?php
   
		  include("DMMYSQLG.php");
			@$resultado=mysqli_query($con ,"select * from dxpaises");
			if(!isset($_POST['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=$_POST['pais'];
			}
			while($registrop=mysqli_fetch_array($resultado)){
				if($selPais==$registrop['cve_pais']){
					echo '<option value="' . $registrop['cve_pais'] . '" selected>' . $registrop['des_pais'] . '</option>';
				}else{
					echo '<option value="' . $registrop['cve_pais'] . '">' . $registrop['des_pais'] . '</option>';
				}
				}			
		?>
      </select></span></td>
      <th ><div align="left"><span class="Estilo20">ESTADO</span></div></th>
      <td colspan="3" ><span class="Estilo1">
        <select name="estados" id="estados" onChange="getMunicipios(this.value)" >
          <option  value="">-----SELECCIONE-----</option>
          <?php
          
		@$resultado=mysqli_query($con ,"select * from dxestado where cve_pais='$selPais'");
                
		if(!isset($_POST['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=$_POST['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>';
			
                            if(mysqli_num_rows($resultado)==0){
                               @$resultadop=mysqli_query($con ,"select * from dxpaises"); 
                                $estp=  mysqli_num_rows($resultadop);
                                while($registrop=mysqli_fetch_array($resultado)){
                                  if($POST_['pais']==$registrop['cve_pais']){                  
                                echo '<option value="' . $estp['cve_pais'] . '" selected>' .  $estp['des_pais'] . '</option>';
			}else{
				echo '<option value="' . $estp['cve_pais'] . '">' . $estp['des_pais'] . '</option>';
                            }
                                }
                } } }
			
?>
      </select></span></td>
      <th ><div align="left"><span class="Estilo1 Estilo21">DELEGACION MUNICIPIO</span></div></th>
      <td colspan="4" ><span class="Estilo1">
       <input name="tmun2" id="tmun2" type="hidden" />	  
       
	    <select name="tmun" id="tmun">
          <option  value="">-----SELECCIONE-----</option>
          <?php
 $_POST['tmun']=$_GET['tmun'];
		@$resultado=mysqli_query($con ,"select * from dxdelmun where cve_estado='$selEnt' and cve_pais='$selPais'");
		if(!isset($_POST['tmun'])){
			
			$dt_delmun=mysqli_fetch_array($resultado);
			$selDelMun=$dt_delmun['cve_delmun'];
			if(mysqli_num_rows($resultado)>0)
				mysqli_data_seek($resultado,0);
				$tr='1';		
		}elseif($_POST['tmun2']=='' || $_POST['tmun2']=='0'){
			$selDelMun=$_POST['tmun'];
		$tr='2';   
		}else{
		    $selDelMun=$_POST['tmun2'];
		$tr='3';
		}
		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>
	  <?php

	//  echo $tr;
	  ?>
	  </td>
    </tr>
	<tr>
      <td colspan="13" class="titulo"><div align="center">
       <input name="Submit2" type="submit" class="original" tabindex="29" value="Guardar" /> &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="pp" tabindex="33" onClick="openpage('res_registro_PR.php','_self')" value="Regresar"/>
      </div></td>
          </tr></td>
  </table>
  </div>
</form>
</div>
</body>
</html>
<script>  
    $( ".date" ).datepicker({dateFormat: 'dd/mm/yy'});
   
   $( ".datefrom" ).datepicker({
       dateFormat: 'dd/mm/yy',
      onSelect: function( selectedDate ) {
             var minDate = $(this).datepicker('getDate');    
            var dmy =selectedDate;      // "24/06/2011" should be pulled from $("#DatePicker").val() instead
            var joindate = $(this).datepicker('getDate');

              joindate.setDate(joindate.getDate()+1); //add two days
              $( ".dateto").datepicker('setDate', joindate);
        $( ".dateto" ).datepicker( "option", "minDate", joindate );
           restaFechas();
      }
    });
    $( ".dateto" ).datepicker({
        dateFormat: 'dd/mm/yy',
       onSelect: function( selectedDate ) {
        $( ".datefrom" ).datepicker( "option", "maxDate", selectedDate );
           restaFechas();
      }
    });
    
    function getEstados(p){
    var form={};
    form.pais=p;
     $.ajax({ 
            data: form,
            url: 'paises.php',
            type: 'post',
            
     
      success: function(data){
        $("#estados").html(data);
            },
       error: function()
                {
                    alert('Ocurrio un error en el servidor ..');
                    alumnos.prop('disabled', false);
                }
        });
    }
    function getMunicipios(s){
    var form={};
    form.estados=s;
     $.ajax({ 
            data: form,
            url: 'paises.php',
            type: 'post',
            
     
      success: function(data){
        $("#tmun").html(data);
            },
       error: function()
                {
                    alert('Ocurrio un error en el servidor ..');
                    alumnos.prop('disabled', false);
                }
        });
    }
</script>
