<?php
 
session_start();
include("DMMYSQLG.php");

//include("DMMYSQLG.php");
include("DF30000.inc");
include("DF80000.php");
include("JQUERY.inc");
    


?>

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

<head>   
<style type="text/css">
#Estilocupada{width:100px;  border:1; }
.Estilop{width:100px; height:88px; border:1; overflow:hidden; cursor: pointer;text-shadow: 1px 1px #ccc;}
table tr td {
  padding: 0px;
  border: 1px dotted #000;
  border-right: 3px;
  margin: 0px;
  width: 88px;
  overflow: hidden;
}

.Estilop h5{ margin:2px;}
.Estilop img{position:absolute;left: 7px;}
</style>
<script type="text/javascript" language="JavaScript1.2" src="js/searchtable.js"></script>
<script>
    $(function() {
		  theTable = $("#latabla");
		  $("#q").keyup(function() {
			$.uiTableFilter(theTable, this.value);
		  });
		});
</script>
</head>
<?php

$nofuera=(isset($_POST['limpio'])||isset($_POST['sucio'])||isset($_POST['checar'])); 

if($nofuera){
  //  print_r((isset($_POST['limpio']))?$_POST['l1']:((isset($_POST['sucio']))?$_POST['s1']:$_POST['c1']));
    
   $uno=(isset($_POST['limpio']))?$_POST['l1']:((isset($_POST['sucio']))?$_POST['s1']:$_POST['c1']);
   $dos=(isset($_POST['limpio']))?$_POST['l2']:((isset($_POST['sucio']))?$_POST['s2']:$_POST['c2']); 
   //echo $uno."jjj".$dos;
    $sql=mysqli_query($con ,"select * from valeryus08 WHERE ncto BETWEEN '".$uno."' AND '".$dos."'  and  nstaamalla='FUERA'");
	echo mysqli_error($con); 
	while ($reg=mysqli_fetch_array($sql)){
              
echo '<script language="javascript">
    alert("no se permite cambiar habitaciones FUERA DE SERVICIO de forma masiva hagalo manual")
		window.close();
window.open("ama_chart.php","mainFrame","frm");		
	</script>';
exit();
        }
}


//echo '<meta content="7; url=FA2000_CH.php" HTTP-EQUIV="REFRESH">';
if (isset($_POST['limpio'])){
   @$ss = mysqli_query($con ,"UPDATE valeryus08 SET ocupado='#00CC00', nstaamalla='LIMPIO', status='LIMPIO',  acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['l1']."' AND '".$_POST['l2']."' and ocupado <> '#FF00CC'");
 mysqli_query($con ,"UPDATE valeryus08 SET  nstaamalla='LIMPIO', status='LIMPIO',  acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['l1']."' AND '".$_POST['l2']."' and ocupado = '#FF00CC'");
 
   mysqli_query($con ,"DELETE from valeryusst08 WHERE fnumcto BETWEEN '".$_POST['l1']."' AND '".$_POST['l2']."' and  fec_ini<='".date('Y-m-d')."'");
echo mysqli_error($con);
}
if (isset($_POST['sucio'])){
    
@$ss = mysqli_query($con ,"UPDATE valeryus08 SET ocupado='#FF0000', nstaamalla='SUCIO', acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['s1']."' AND '".$_POST['s2']."' and ocupado <> '#FF00CC'");
@$ss = mysqli_query($con ,"UPDATE valeryus08 SET  nstaamalla='SUCIO', acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['s1']."' AND '".$_POST['s2']."' and ocupado = '#FF00CC'");

echo mysqli_error($con);
}
if (isset($_POST['checar'])){
@$ss = mysqli_query($con ,"UPDATE valeryus08 SET ocupado = '#FFFF00', nstaamalla='CHECAR',  acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['c1']."' AND '".$_POST['c2']."' and ocupado <> '#FF00CC'");
@$ss = mysqli_query($con ,"UPDATE valeryus08 SET  nstaamalla='CHECAR',  acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['c1']."' AND '".$_POST['c2']."' and ocupado = '#FF00CC'");

}
if (isset($_POST['fuera'])){

echo "<script language='javascript'>
		window.open('valeryus60001_AL.php?hb1=".$_POST['f1']."&hb2=".$_POST['f2']."&tpo=FUERA DE SERVICIO&tpi=fuera','STATUS','width=400,height=300')
			</script>";


}
if (isset($_POST['bloqueado'])){
echo "<script language='javascript'>
		window.open('valeryus60001_AL.php?hb1=".$_POST['b1']."&hb2=".$_POST['b2']."&tpo=BLOQUEADO&tpi=bloqueado', 'STATUS', 'width=400, height=300')
			</script>";
}
if (isset($_POST['asignado'])){
@$ss = mysqli_query($con ,"UPDATE valeryus08 SET ocupado = '#FF00CC',  acc_fec='".date('Y-m-d')."', acc_hor='".date('H:i:s')."', usuario= '".$_SESSION['usuario']."' WHERE ncto BETWEEN '".$_POST['a1']."' AND '".$_POST['a2']."'");
echo mysqli_error($con);
}
$fecha= (isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:"";

$sqd=mysqli_query($con ,"UPDATE valeryus08 a JOIN  (
select fnumcto from valeryus19 
where (status='RESERVA INDIVIDUAL' or status='RESERVA GRUPO')
 AND ffecllegada='$fecha' and cancelado='0' ORDER BY fnumcto
)as b   ON a.ncto = b.fnumcto SET  a.nstarecep='RESERVADO'
where  a.nstarecep!='RESERVADO'
");

//<input name="asignado" type="submit" style="background:#FF00CC" value=" ASIGNADO " size="50"/>
?>


<script type="text/javascript" language="JavaScript1.2" src="DSSCRIPT.js"></script>
  	 	

<body>
<div align="left">

</div>
<div align="center">
<form name="frm1" id="frm1" method="post" action="" >
 <table width="250" >
      <tr>
        <td colspan="3"><div align="center"><span class="men">Vista Del Hotel</span> </div></td>
      </tr>
      <tr class="men">
        <td width="152"><div align="center" class="men Estilo17">ROOM STATUS </div></td>
        <td width="32" class="men Estilo18"><div align="center"><strong>PISO.</strong></div></td>
        <td width="44" class="men Estilo18 Estilo27"><div align="center">TOTAL.</div>          <div align="center"></div></td>
	  </tr>
      <tr>
        <td><div align="center">
          <input name="limpio" type="submit" style="background:#00CC33" size="50" value="     LIMPIO    "/>
        </div></td>
        <td>
          <div align="left">
            <input name="l1" type="text" size="5" id="l1"/>		
          </div></td>
         <td>
           <div align="left">
             <input name="l2" type="text" size="5" id="l2"/>		
           </div>
         <div align="center"></div></td>
	  </tr>
      <tr>
        <td><div align="center">
          <input name="sucio" type="submit" style="background:#FF0000" size="50" value="     SUCIO     "/>
        </div></td>
        <td><input name="s1" type="text" size="5" id="s1"/></td>
        <td><input name="s2" type="text" size="5" id="s2"/></td>
      </tr>
      <tr>
        <td><div align="center">
          <input name="checar" type="submit" style="background:#FFFF00" size="50" value="  CHECAR  "/>
        </div></td>
        <td><input name="c1" type="text" size="5" id="c1"/></td>
        <td><input name="c2" type="text" size="5" id="c2"/></td>
	  </tr>
      <tr>
        <td><input name="fuera" type="submit" class="error" style="background:#000000" value="FUERA DE SERVICIO"/></td>
        <td><input name="f1" type="text" size="5" id="f1"/></td>
        <td><input name="f2" type="text" size="5" id="f2"/></td>
	  </tr>
      <tr>
        <td><div align="center">
          <input name="bloqueado" type="submit" class="error" style="background:#0000CC" value=" BLOQUEADO " size="50"/>
        </div></td>
        <td><input name="b1" type="text" size="5" id="b1"/></td>
        <td><input name="b2" type="text" size="5" id="b2"/></td>
	  </tr>
	  <tr>
	    
        <!--input name="asignado" type="submit" style="background:#FF00CC" value=" ASIGNADO " size="50"/-->
		<td><div align="center">
		<input name="asignado" type="submit" style="background:#FF00CC" value=" ASIGNADO " size="50"/></div></td>
        <td><input name="a1" type="text" size="5" id="a1"/></td>
        <td><input name="a2" type="text" size="5" id="a2"/></td>
	  </tr>
    </table>
    <input type="button" name="Submit" value="Mostrar todo" onClick="openpage('ama_chart.php','_self')" class="bot_WsW"/>
    </table>
  </form>
      <div id="busqueda" style="color:#000">
		Busqueda Rapida <input type="text" style="width: 70%" id="q" name="q" value="" />
		</div>
<?php 

echo '<table  style="background-color:#0000CC;" cellspacing="2" cellpadding="0" id="latabla">';   
$proXlin=8;
$auxNumLin=-1;
$fecha=(isset($dt_empres['fec_alta']))?$dt_empres['fec_alta']:date('Y-m-d');
$sq1 = mysqli_query($con ,"SELECT f08.ncto,f08.ntipo, f08.status as fstat, f19.status, f19.ffecllegada, f08.ocupado, f08.nstaamalla, 
    IF(f19.fapellido IS NULL or f19.fapellido = '', f19.fnombre, f19.fapellido) as fapellido, frec19.status as reserv,frec19.fvip,frec19.tipo AS nomove  FROM valeryus08 as f08
   left  join (select * from valeryus19
	 where  
	  (status='HUESPED' and  '$fecha'>=ffecllegada and  '$fecha'<=ffecsalida ) )as f19
	  on f08.ncto=f19.fnumcto	 
	left join (
	     select status,fnumcto,tipo,fvip from valeryus19 where  ((status='RESERVA INDIVIDUAL' or status='RESERVA GRUPO') and ffecllegada='$fecha' AND cancelado=0)
	  ) as frec19
	  
	  on f08.ncto=frec19.fnumcto
	 where trim(f08.ntipo)<>'MAESTRA'
	   order by ncto, ffecllegada
	  asc  ");
// and  '$fecha'>=ffecllegada and '$fecha'<=ffecsalida

echo mysqli_error($con);
while($dt_invent=mysqli_fetch_array($sq1)){

	$auxNumLin++;
	if($auxNumLin==-1 || $auxNumLin%$proXlin==0){
		if($auxNumLin==-1){
			echo "<tr>";
		}else{
			echo "</tr><tr>";
		}
	}
if ($dt_invent['fstat']=='OCO'){
$oco=$dt_invent['fstat']; 
}else 
{	$oco='';
}
	//if ($dt_invent['nstarecep']=='OCUPADO'){
	//echo "<td  style=\" \" onclick=\"openWindow({action:'ventana.php'},{ncto:'".$dt_invent['ncto']."'})\"><div class=\"Estilocupada\" style='background-color:".$dt_invent["ocupado"].";' align='center'>
//".$reb['fapellido']."<br>
//<br><h5>".$oco.'</h5> '.substr($dt_invent['ncto'],0,5)."<br>".$dt_invent['ntipo']."</div></td>";

	echo "<td  style=\" \" onclick=\"openWindow({action:'ventana.php'},{ncto:'".$dt_invent['ncto']."'})\">"
                . "<div class=\"Estilop\" style='position:relative;background-color:".$dt_invent["ocupado"].";' align='center'>";
                    if($dt_invent["ocupado"]=='#FF00CC'){
                        $real=$dt_invent["ocupado"];
                        switch ($dt_invent['nstaamalla']){
                            case "SUCIO":
                                $real="#FF0000";
                                break;
                             case "LIMPIO":
                                 $real="#00CC00";
                                break;
                             case "BLOQUEADO":
                                 $real="#0000CC";
                                break;
                             case "FUERA":
                                 $real="#000000";
                                break;
                        }
                        echo "<div style='position:absolute;top:2px;left:2px;width:15px;height:15px;background:$real'></div>";
                        
                    }
                    if($dt_invent['status']=='HUESPED'){ 
echo "".$dt_invent['fapellido']."<br>";
      if($dt_invent['reserv']=='RESERVA INDIVIDUAL' || $dt_invent['reserv']=='RESERVA GRUPO'){
          echo "<img src=\"img/ico.png\" height='20' width='20'>";
      }
      
}else{

//echo "<br>";
      if($dt_invent['reserv']=='RESERVA INDIVIDUAL' || $dt_invent['reserv']=='RESERVA GRUPO'){
          echo "<img src=\"img/ico.png\" height='20' width='20'>";
      }
      
}
      if($dt_invent['nomove']==1){
		  
          echo "<img src='../hotel1/imgmenu/bloqueado.png' style='left: 70%;top: 66%;opacity: 0.7;z-index: 1;' width='15'>";
      }

echo "<h5>".$oco.'</h5>'.substr($dt_invent['ncto'],0,5)."<br><p>".$dt_invent['ntipo']."</p></div></td>";
	
}

?>
</div>
</body>
</html>
