<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
$com = "I";
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,'REPORTE DE RESERVACIONES',0,1,'C',0);
		//Salto de línea
		if($_POST['r1']=="f"){
		$this->Cell(50,5,'Fecha: '.$_POST['fec'].' al '.$_POST['fec2'],0,0,'C',0);
		}
		$this->Ln(8);
		$this->SetFont('Arial','B',7);//establece tamaño de letra
		$this->SetFillColor(192,192,192);
		$this->Cell(-5,5,'',0,0,'C',0);
		$this->Cell(15,5,'FOLIO',1,0,'C',1);
		$this->Cell(60,5,'APELLIDO Y NOMBRE',1,0,'C',1);
		$this->cell(20,5,'AGENCIA',1,0,'C',1);
		$this->cell(9,5,'ADUL.',1,0,'C',1);
		$this->cell(7,5,'MEN.',1,0,'C',1);
		$this->cell(8,5,'HAB.',1,0,'C',1);
		$this->cell(20,5,'TIPO',1,0,'C',1);
		$this->cell(8,5,'G/NG',1,0,'C',1);
		$this->cell(19,5,'FEC. LLEGADA',1,0,'C',1);
		$this->cell(19,5,'FEC. SALIDA',1,0,'C',1);
		$this->cell(30,5,'FORMA DE PAGO',1,0,'C',1);
		$this->cell(20,5,'TARIFA',1,0,'C',1);
		$this->cell(35,5,'NOTAS',1,1,'C',1);
		
	
	}	
	//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','',7);//establece tamaño de letra

$tbus=mysqli_real_escape_string($GLOBALS['con'],$_POST['tbus']);
if($_POST['bot']==""){
  $sql =  mysqli_query($GLOBALS['con'] ,"SELECT * FROM valeryus19 WHERE status = 'reserva individual'");
  @$tot=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select count(*) as total from valeryus19 where status = 'reserva individual'"));
  @$jso=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE status = 'reserva individual'"));
  @$ahj=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE status = 'reserva individual'")); 
	}
	if($_POST["r1"]=="no"){
	  $sql =  mysqli_query($GLOBALS['con'] ,"SELECT * FROM valeryus19 WHERE status = 'reserva individual' ORDER BY n_reg");
	  @$tot=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select count(*) as total from valeryus19 where status = 'reserva individual'"));
	  @$jso=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE status = 'reserva individual'"));
	  @$ahj=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE status = 'reserva individual'"));
	    }
	    if($_POST["r1"]=="p"){
		  $sql =  mysqli_query($GLOBALS['con'] ,"SELECT * FROM valeryus19 WHERE status = 'reserva individual' ORDER BY fapellido");
		  @$tot=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select count(*) as total from valeryus19 where status = 'reserva individual'"));
	      @$jso=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE status = 'reserva individual'"));
	      @$ahj=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE status = 'reserva individual'"));
			}
	        if($_POST["r1"]=="f"){
			  $fec = $_POST['fec'];
		      include('DF20000.php');
		      $fecha_inicial = $f_m;
		      $fec = $_POST['fec2'];
		      include('DF20000.php');
		      $fecha_final = $f_m;
		        $sql = mysqli_query($GLOBALS['con'] ,"SELECT * FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'reserva individual'");
			    @$tot=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select count(*) as total from valeryus19 where ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'reserva individual'"));
	            @$jso=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"SELECT SUM(fnumadu) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'reserva individual'"));
	            @$ahj=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"SELECT SUM(fnummenor) AS total FROM valeryus19 WHERE ffecllegada >= '$fecha_inicial' and ffecsalida <= '$fecha_final' AND status = 'reserva individual'")); 
				  }
while($row = mysqli_fetch_array($sql)){
    $pdf-> Cell(-5,5,'',0,0,'C',0);
	$pdf-> Cell(15,5, $row["n_reg"],10,0,'C',0);
	$pdf-> Cell(60,5, $row["fapellido"].''.$row["fnombre"],10,0,'C',0);
	$pdf-> Cell(20,5, $row["fcodagen"],10,0,'C',0);
	$pdf-> Cell(9,5, $row["fnumadu"],10,0,'C',0);
	$pdf-> Cell(7,5, $row["fnummenor"],10,0,'C',0);
	$pdf-> Cell(8,5, $row["fnumcto"],10,0,'C',0);
	$pdf-> Cell(20,5, $row["ftipocto"],10,0,'C',0);
	$pdf-> Cell(8,5, $row[""],10,0,'C',0);
	$pdf-> Cell(19,5, chfecha($row['ffecllegada'],'Y-m-d'),10,0,'C',0);
	$pdf-> Cell(19,5, chfecha($row['ffecsalida'],'Y-m-d'),10,0,'C',0);
	$pdf-> Cell(30,5, $row["fformpago"],10,0,'C',0);
	$pdf-> Cell(20,5, '$' .number_format($row["ftotal"], 2, '.', ','),10,0,'C',0);
	$pdf-> Cell(35,5, $row["fnorasvip"],10,1,'C',0);
	}
	//Salto de línea
	$pdf-> Cell(60,5,'FOLIOS :',10,1,'C',0);
	$pdf-> Cell(80,-5, $tot['total'],10,1,'C',0);
    $pdf-> Cell(160,5,'PERSONAS :',1,1,'C',0);
	$pdf-> Cell(188,-5, $jso['total'],10,1,'C',0);
	$pdf-> Cell(205,5, $ahj['total'],10,1,'C',0);
$pdf->Output("Reporte De Reservaciones.pdf","D");
?> 