<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
$com = "I";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
include('DF80000.php');
$p1=0;
$p2=0;
 
class PDF extends FPDF{
	//Cabecera de Página
	function Header(){
	    //Logotipo
	    include("DYIM_VER.php");
	    //Arial Bold (14)
	    $this->SetFont('Arial','B',12);
	    //Espacio
		
	    //Título		
	    $this->Cell(190,3,'STATUS ACTUAL DEL HOTEL',0,1,'C');
		$this->SetFont('Arial','B',8);
		$this->Cell(190,3,'',0,1,'L');		
		$this->Cell(190,3,'FECHA '.$_POST['fecha'].'',0,1,'C');
				
	
	    //Salto de línea
	    $this->Ln(3);
	}
	//Pie de Página
	function Footer()
	{
	    //Posición: 1,5 cm del Final
	    $this->SetY(-15);
	    //Arial Italic 8
	    $this->SetFont('Arial','I',8);
	    //Número de página
	    $this->Cell(0,0, $this->PageNo().'/{nb}',0,0,'C');
	}
}
$pdf;
$pdf=new PDF('P','mm','Letter');
$pdf->AddPage();
$pdf->AliasNbPages();
$binit=-1;
$fecha=$_POST['fecha'];
	$pdf->SetFont('ARIAL','B',7);
	$pdf->SetFillColor(230,230,230);
	$pdf->Cell(5,3,'',0,1,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',1);
	$pdf->Cell(35,3,'PRONOSTICO',0,0,'C',1);
	$pdf->Cell(15,3,'',0,0,'C',1);
	$pdf->Cell(35,3,'ACTUAL',0,0,'C',1);
	$pdf->Cell(15,3,'',0,1,'C',1);

$sqer=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where status='RESERVA INDIVIDUAL' and ffecllegada='".$fecha."' and cancelado=0"); 
 echo mysqli_error($GLOBALS['con']);
 $ei=0;
 while ($reg=mysqli_fetch_array($sqer)){ 
	 $ei ++;
 }
$sqer2=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where status='RESERVA GRUPO' and ffecllegada='".$fecha."' and cancelado=0"); 
 echo mysqli_error($GLOBALS['con']);
 $eg=0;
 while ($reg=mysqli_fetch_array($sqer2)){ 
	 $eg ++;
 }
$sqoh=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where status='HUESPED' and ffecllegada='".$fecha."' and tiporh='R' and cancelado=0");
 echo mysqli_error($GLOBALS['con']);
 $er=0;
 while ($reg=mysqli_fetch_array($sqoh)){ 
	 $er ++;
 }
	$pdf->SetFont('ARIAL','B',7);
	$pdf->Cell(5,3,'',0,1,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',0);
	$pdf->Cell(35,3,'ENTRADA',0,0,'L',0);
 	$pdf->Cell(35,3,$res=$ei+$eg+$er,0,0,'C',0);
	$pdf->Cell(15,3,'',0,0,'C',0);
	$pdf->Cell(35,3,$er,0,0,'C',0);
	$pdf->Cell(15,3,'',0,1,'C',0);

$sqh=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where status='HUESPED' and ffecllegada='".$fecha."' and tiporh='' and cancelado=0");
 echo mysqli_error($GLOBALS['con']);
 $eh=0;
 while ($reg=mysqli_fetch_array($sqh)){ 
	 $eh ++;
 }		
		
	$pdf->SetFont('ARIAL','B',7);
	$pdf->Cell(5,3,'',0,1,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',0);
	$pdf->Cell(35,3,'WALKING',0,0,'L',0);
	$pdf->Cell(35,3,'0',0,0,'C',0);
	$pdf->Cell(15,3,'',0,0,'C',0);
	$pdf->Cell(35,3,$eh,0,0,'C',0);
	$pdf->Cell(15,3,'',0,1,'C',0);
	
		
		$sqsa=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where  ffecsalida='".$fecha."' and (status='HUESPED' OR status='RESERVA INDIVIDUAL' OR status='RESERVA GRUPO') and cancelado=0");
		$sq_fr=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where ffecsalida='".$fecha."' and cancelado='0' and status='HUESPED'");
 	$s12=mysqli_num_rows($sq_fr); 
 $s1=mysqli_num_rows($sqsa);
 		 $s1=$s12;

	$sqsa=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where  fecha_real='".$fecha."' and status='HISTORICO' and cancelado=0"); 
 echo mysqli_error($GLOBALS['con']);
 $s2=mysqli_num_rows($sqsa);
 		 $s2;

	
	$pdf->SetFont('ARIAL','B',7);
	$pdf->Cell(5,3,'',0,1,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',0);
	$pdf->Cell(35,3,'SALIDAS',0,0,'L',0);
	$pdf->Cell(35,3,$s1,0,0,'C',0);
	$pdf->Cell(15,3,' ',0,0,'C',0);
	$pdf->Cell(35,3,$s2,0,0,'C',0);
	$pdf->Cell(15,3,' ',0,1,'C',0);
	

 $sqsa=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19  where  (fecha_real='".$fecha."' and ffecsalida!='".$fecha."') and status='HISTORICO' and cancelado=0 "); 
 echo mysqli_error($GLOBALS['con']);
 $si=mysqli_num_rows($sqsa);

	$pdf->SetFont('ARIAL','B',7);
	$pdf->Cell(5,3,'',0,1,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',0);
	$pdf->Cell(35,3,'SALIDAS INESPERADAS',0,0,'L',0);
	$pdf->Cell(35,3,'0',0,0,'C',0);
	$pdf->Cell(15,3,' ',0,0,'C',0);
	$pdf->Cell(35,3,$si,0,0,'C',0);
	$pdf->Cell(15,3,' ',0,1,'C',0);


		$sqocu=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where status='HUESPED' and '".$fecha."'>ffecllegada and '".$fecha."'<=ffecsalida and cancelado=0");
		echo mysqli_error($GLOBALS['con']);
		$ocu=0;
		while ($reg=mysqli_fetch_array($sqocu)){ 
			 $ocu ++;
 		}
		 $oc1=$ocu+$eh+$res;
	   $sqtc=mysqli_query($GLOBALS['con'] ,"select count(*) as cantid from valeryus08 WHERE ntipo!='MAESTRA'");
		 $tc=mysqli_fetch_array($sqtc);
		 if($tc['cantid']>0){
		  	$p1=(($oc1*100)/$tc['cantid']);
 			 $p1;
	  $sqocu=mysqli_query($GLOBALS['con'] ,"select n_reg from valeryus19 where status='HUESPED' and '".$fecha."'>ffecllegada and '".$fecha."'<=ffecsalida and cancelado=0"); 
		echo mysqli_error($GLOBALS['con']);
		$ocu=0;
		while ($reg=mysqli_fetch_array($sqocu)){ 
			 $ocu ++;
 		}
		}
		$oc2=$ocu+$eh+$er;
$sqtc=mysqli_query($GLOBALS['con'] ,"select count(*) as cantid from valeryus08 WHERE ntipo!='MAESTRA'");
 $tc=mysqli_fetch_array($sqtc);
	if($tc['cantid']>0){
		  	$p2=(($oc2*100)/$tc['cantid']);
 			 $p2;		
}
	$pdf->SetFont('ARIAL','B',7);
	$pdf->Cell(5,3,'',0,1,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',0);
	$pdf->Cell(35,3,'OCUPADOS',0,0,'L',0);
	$pdf->Cell(35,3,$oc1,0,0,'C',0);
	$pdf->Cell(15,3,number_format($p1,2,'.',',').'% ',0,0,'C',0);
	$pdf->Cell(35,3,$oc2,0,0,'C',0);
	$pdf->Cell(15,3,number_format($p2,2,'.',',').'% ',0,1,'C',0);

		  $sqtc=mysqli_query($GLOBALS['con'] ,"select count(*) as cantid from valeryus08 WHERE ntipo!='MAESTRA'");
 $tc=mysqli_fetch_array($sqtc);
 			 $d1=$tc['cantid']-$oc1; 		
			$d2=$tc['cantid']-$oc2; 		
	$pdf->SetFont('ARIAL','B',7);
	$pdf->Cell(5,3,'',0,1,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',0);
	$pdf->Cell(35,3,'DISPONIBLES',0,0,'L',0);
	$pdf->Cell(35,3,$d1,0,0,'C',0);
	$pdf->Cell(15,3,' ',0,0,'C',0);
	$pdf->Cell(35,3,$d2,0,0,'C',0);
	$pdf->Cell(15,3,' ',0,1,'C',0);
	$pdf->SetFont('ARIAL','B',7);
	$pdf->Cell(5,3,'',0,1,'C',0);
	$pdf->Cell(35,3,'',0,0,'C',0);
	$pdf->Cell(35,3,'TOTAL HABITACIONES',0,0,'L',0);
	$pdf->Cell(35,3,$tc['cantid'],0,0,'C',0);
	$pdf->Cell(15,3,' ',0,0,'C',0);
	$pdf->Cell(35,3,$tc['cantid'],0,0,'C',0);
	$pdf->Cell(15,3,' ',0,1,'C',0);


$pdf->Output("Status_Hotel.pdf","D");
?>


