<?php
 
session_start();
include("DMMYSQLG.php");
//include("DSA3000.php");  
include("DF30000.inc");
include("DF80000.php");
include("JQUERY.inc");
?>
<html>
<link rel="stylesheet" href="css/estilo1.css" type="text/css"/>
<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>

<?php

/*if ($_GET['ncto']==""){
	echo '<h2>!!! SELECCIONE UN REGISTRO !!!</h2>';
	echo '<meta content="1; url=ventana.php"  HTTP-EQUIV="REFRESH">';
}
else
{*/
	echo $cam=isset($_GET["ncto"])?$_GET["ncto"]:"";
	//include('FC60000_CL.php'); 
	//$varible_clase = new clase();
	//$res=$varible_clase->lista_busqueda($cam);
	$sql=mysqli_query($con ,"select * from valeryus19 WHERE fnumcto='$cam' ");
	echo mysqli_error($con);
	while ($reg=mysqli_fetch_array($sql)){
	///if(!isset($_POST['ffecllegada'])){
	$_REQUEST['ncto']=isset($_GET["ncto"])?$_GET["ncto"]:"";
	//$_REQUEST['ffecllegada']=$reg['ffecllegada'];
	$_REQUEST['ffecllegada']=chfecha($reg['ffecllegada'],'Y-m-d','d/m/Y');
	$_REQUEST['ffecsalida']=chfecha($reg['ffecsalida'],'Y-m-d','d/m/Y');
	//$_REQUEST['ffecsalida']=$reg['ffecsalida'];
	$_REQUEST['fnombre']=$reg['fnombre'];
	$_REQUEST['fapellido']=$reg['fapellido'];
	$_REQUEST['fhorallega']=$reg['fhorallega'];
	$_REQUEST['fcodtarifa']=$reg['fcodtarifa'];
	$_REQUEST['fnumadu']=$reg['fnumadu'];
	$_REQUEST['fhorasalid']=$reg['fhorasalid'];
	$_REQUEST['fsaldo']=$reg['fsaldo'];
	$_REQUEST['fnummenor']=$reg['fnummenor'];
	$_REQUEST['fnorasvip']=$reg['fnorasvip'];
}

//}
?>
<body>
<div align="center">
  <form name="frm" id="frm" method="post" action="">
  <input type="hidden" name="retPag" id="retPag" value="<?php
echo $_REQUEST['retPag'];?>">
	<table width="358" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr class="men">
        <td colspan="2"><div align="center" class="theli"><span>ROMM STATUS: <?php
 echo $_GET['tpo']; ?> </span></div></td>
      </tr>
      <tr class="men"> 
        <td colspan="2"><div align="center"><span class="theli">INGRESA LOS DATOS </span></div></td>
      </tr>
      <tr> 
        <td><span class="Estilo17">HABITACIONES</span></td>
        <td><input name="f1" type="text" size="5" id="f1" value="<?php
 echo $_GET['hb1']; ?>"/>
          <input name="f2" type="text" size="5" id="f2"value="<?php
 echo $_GET['hb2']; ?>"/></td>
      </tr>
      <tr>
        <td width="147"><span class="Estilo8"><strong>FECHA DE INICIO </strong> </span></td>
        <td width="195"><input name="fec" type="text" class="emplea datefrom" id="fec" size="9" maxlength="20"
			<?php

				if(isset($_POST['fec'])){ //este es el truco
					echo 'value="' . $_POST['fec'] .  '"';
				}else{
					echo 'value="'.date("d/m/Y").'"';
				}
			?>onkeypress="return soloNumeros(event)"
		/>
        
                </td>
      </tr>
      <tr>
        <td><span class="Estilo8"><strong>FECHA DE FINAL </strong> </span></td>
	        <td><input name="fec2" type="text" class="emplea dateto" id="fec2" size="9" maxlength="20"
			<?php

				if(isset($_POST['fec2'])){ //este es el truco
					echo 'value="' . $_POST['fec2'] .  '"';
				}else{
					echo 'value="'.date("d/m/Y").'"';
				}
			?>onkeypress="return soloNumeros(event)"
		/>
			</td>
      </tr>
      <tr>
        <td><span class="Estilo8"><strong>MOTIVO </strong></span></td>
        <td rowspan="3"><span class="Estilo7">
          <textarea name="motivo" cols="25" rows="5" id="motivo"><?php
$rm=isset($_REQUEST['motivo'])?$_REQUEST['motivo']:"";
          echo $rm;?></textarea>
		  </span></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr> 
        <td>&nbsp;</td>
      </tr>
    </table>
    </table>
    <p>
      <label>
      <input type="submit" name="close" id="close" class="form" value="TERMINAR">
      </label>
    </p>
  </form>
<?php
 $pl=isset($_POST['limpio'])?$_POST['limpio']:"";
if ($pl){
//window.opener.location.reload();

//		window.opener.location.submit();
	//	window.location.href ="valeryus60000_AL.php";	
}
$pc=isset($_POST['close'])?$_POST['close']:"";
if ($pc){
    
    //$res=$varible_clase->lista_busqueda($cam);
	$sql=mysqli_query($con ,"select * from valeryus08 WHERE ncto BETWEEN '".$_POST['f1']."' AND '".$_POST['f2']."'  and  nstaamalla='FUERA'");
	echo mysqli_error($con);
	while ($reg=mysqli_fetch_array($sql)){ 
              
echo '<script language="javascript">
    alert("no se permite bloquear habitaciones FUERA DE SERVICIO de forma masiva hagalo manual")
		window.close();
window.open("ama_chart.php","mainFrame","frm");		
	</script>';
exit();
        }
    
    
 if ($_GET['tpi']=='fuera'){
@$ss = mysqli_query($con ,"UPDATE valeryus08 SET ocupado = '#000000', nstaamalla='FUERA', acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto ='".$_POST['f1']."'  and ocupado <> '#FF00CC'");
@$ss = mysqli_query($con ,"UPDATE valeryus08 SET nstaamalla='FUERA', acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto ='".$_POST['f1']."'  and ocupado = '#FF00CC'");

}else if ($_GET['tpi']=='bloqueado'){
@$ss = mysqli_query($con ,"UPDATE valeryus08 SET ocupado = '#0000CC', nstaamalla='BLOQUEADO', acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['f1']."' AND '".$_POST['f2']."' and ocupado <> '#FF00CC'");

@$ss = mysqli_query($con ,"UPDATE valeryus08 SET  nstaamalla='BLOQUEADO', acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['f1']."' AND '".$_POST['f2']."' and ocupado = '#FF00CC'");

    echo mysqli_error($con);
}

for ( $i = $_POST['f1'] ; $i <= $_POST['f2'] ; $i ++) {
//echo $i.'-';
$fec1=chfecha($_POST['fec'],'d/m/Y','Y-m-d');
$fec2=chfecha($_POST['fec2'],'d/m/Y','Y-m-d');
mysqli_query($con ,"INSERT INTO valeryusst08 (fnumcto,fec_ini,fec_fin,motivo,status,acc_fec,acc_hor,usuario) VALUES ('".$i."','".$fec1."','".$fec2."','".$_POST['motivo']."','".$_GET['tpi']."','".date('Y-m-d')."','".date('H:i:s')."','".$_SESSION['usuario']."')");
echo mysqli_error($con);
}

echo '<script language="javascript">
		window.close();
window.open("ama_chart.php","mainFrame","frm");		
	</script>';
	
}
?>
</body>
</html>