<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
$com = "I";
$f_m="";
$i=0;
include("DMMYSQLG.php");
require_once("DF80000.php");
class PDF extends FPDF{
//Cabecera de página
	function Header(){
	    //Logo
	         include("DYIM_VER.php");
	    //Arial bold 14
		$this->SetFont('Arial','B',12);
		//Título
		$this->Cell(225,5,'CHART DE rec_ocupacion X CUARTO',0,1,'C',0);
		//Salto de línea
		$this->SetFont('Arial','B',11);
		$this->Cell(50,5,'',0,0,'C',0);
		$this->Cell(50,5,'Fecha: '.$_GET['fec'].' al '.$_GET['fec2'],0,0,'C',0);
		
		$this->Ln(8);
		$this->SetFont('Arial','B',7.5);//establece tamaño de letra
		$this->SetFillColor(192,192,192);
		
	       $this->cell(54,5,'HAB / FEC',1,0,'C',1);
		$fec = $_GET['fec'];
		include('DF20000.php');
			$ffecllegada = $f_m;
		$fec = $_GET['fec2'];
		include('DF20000.php');
			$ffecsalida = $f_m;
	 while ( dateCmp($ffecllegada,$ffecsalida)<=0)
	 {
	 $this->cell(41,5,"".whatDay($ffecllegada)." ".chfecha($ffecllegada,'Y-m-d','dd')."",1,0,'C',1);
	
	 	$ffecllegada=addDay($ffecllegada,1); 
		
	 	 }    
		 $this->cell(21,5,' ',0,1,'C',0);
			 
	
	}	
	//Pie de página
	function Footer()
	{
	//Posición: a 1,5 cm del final
	$this->SetY(-15);
	//Arial italic 8
	$this->SetFont('Arial','I',8);
	//Número de página
	$this->Cell(0,10, $this->PageNo(),0,0,'C');
	}
}

$pdf=new PDF('L','mm','Letter');
$pdf->AddPage();

$pdf->SetFillColor(192,192,192);


		  
	    $pdf->SetFont('Arial','',6.5);
		$sql=mysqli_query($GLOBALS['con'] ,$sq1="SELECT ncto,ntipo FROM valeryus08 where ntipo <>'MAESTRA' order by ncto limit 90");
			
			
	while($reg = mysqli_fetch_array($sql))
	{
	$fec = $_GET['fec'];
		include('DF20000.php');
			$ffecllegada = $f_m;
		$fec = $_GET['fec2'];
		include('DF20000.php');
			$ffecsalida = $f_m;
		    $pdf->cell(54,4.5,$reg['ncto'].' - '.$reg['ntipo'],1,0,'L',1);
			
			$i ++;
			
	 while ( dateCmp($ffecllegada,$ffecsalida)<=0)
	 {
	 $sqb=mysqli_query($GLOBALS['con'] ,"SELECT n_reg FROM chart where ffecllegada <= '$ffecllegada' and  ffecsalida>'$ffecllegada' and fnumcto='".$reg['ncto']."' and cancelado='0' and ffecllegada > '2013-04-01'");
	 $reb= mysqli_fetch_array($sqb);
	 
	 $pdf->cell(41,4.5,"".($reb['n_reg']!=""?("F: ".$reb['n_reg']):" ")."",1,0,'C',0); 
	
	 	$ffecllegada=addDay($ffecllegada,1); 
		}	 	 
		$pdf->cell(21,4.5,'',0,1,'C',0);
			
	}	

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