<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
$sql="";
//include("DMMYSQLG.php");

include("DMMYSQLG.php");
require_once("DF80000.php");
class PDF extends FPDF{
//Cabecera de página
	function Header(){
	    //Logo
	         //include("DYIM_JAC.php");
			 include("DYIM_VER.php");
	    //Arial bold 14
		$this->SetFont('Arial','B',13);
		//Título
		$this->Cell(192,5,'REPORTE DE DEPOSITOS',0,1,'C',0);
		//Salto de línea
		if(isset($_POST['r1'])&&$_POST['r1']=="f"){
		$this->Cell(65,5,'FECHA DE ENTRADA: '.$_POST['fec'].'',0,0,'C',0);
		}
		$this->Ln(8);
		$this->SetFont('Arial','B',8);//establece tamaño de letra
		$this->SetFillColor(192,192,192);
		$this->Cell(-2,5,'',0,0,'C',0);
		$this->Cell(15,5,'FOLIO',1,0,'C',1);
		$this->Cell(10,5,'HAB',1,0,'C',1);
		$this->Cell(45,5,'HUESPED',1,0,'C',1);
		$this->cell(17,5,'STATUS',1,0,'C',1);
		$this->cell(15,5,'FEC IN',1,0,'C',1);
		$this->cell(15,5,'FEC SAL',1,0,'C',1);
		$this->cell(10,5,'#RBO',1,0,'C',1);
		$this->cell(17,5,'DEPOSITO',1,0,'C',1);
		$this->cell(10,5,'USU',1,0,'C',1);
		$this->cell(75,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','',8);//establece tamaño de letra
$vtb=(isset($_POST['tbus']))?$_POST['tbus']:"";
$tbus=mysqli_real_escape_string($GLOBALS['con'],$vtb);
  $fec = $_POST['fec'];
  include('DF20000.php');
  $fecha_inicial = $f_m;
  
  if(isset($_POST['r1'])&&$_POST['r1']==""){
    $sql = mysqli_query($GLOBALS['con'] ,"select * from valeryus19 left join valeryus030 on valeryus19.n_reg=valeryus030.nparte1 where valeryus030.depositos='1' and valeryus19.cancelado='0' and (valeryus030.cancelado='0' or valeryus030.cancelado='2') ORDER BY ffecllegada");
	  }elseif(isset($_POST['r1'])&&$_POST['r1']=="f"){  
	    $sql = mysqli_query($GLOBALS['con'] ,"select * from valeryus19 left join valeryus030 on valeryus19.n_reg=valeryus030.nparte1 where valeryus030.depositos='1' and valeryus19.cancelado='0' and (valeryus030.cancelado='0' or valeryus030.cancelado='2') and ffecllegada='$fecha_inicial' ORDER BY ffecllegada");         
		}
	
$a=0;
while($row = mysqli_fetch_array($sql)){
$a++;
	$pdf->SetFont('Arial','',7);
    $pdf-> Cell(-2,5,'',0,0,'C',0);
	if ($a>1){
	$pdf-> Cell(192,0.3,'',0,1,'L',1);		
	$pdf-> Cell(-2,5,'',0,0,'C',0);
	}
	$huesped=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select * from valeryus19 where n_reg='".$row['nparte1']."' and cancelado='0'"));
	$pdf-> Cell(15,5, $huesped["n_reg"],10,0,'C',0);
	if ($huesped['status']=='RESERVA INDIVIDUAL' || $huesped['status']=='HUESPED' || $huesped['status']=='RESERVA GRUPO'){
		$huesped["fnumcto"]=$huesped["fnumcto"];
		}else{
		$huesped["fnumcto"]=$huesped["fmuncto"];
		}
	$pdf-> Cell(10,5, $huesped["fnumcto"],10,0,'C',0);	
	$pdf-> Cell(45,5,substr($huesped["fapellido"].' '.$huesped["fnombre"],0,29),10,0,'L',0);
	if ($huesped['status']=='RESERVA INDIVIDUAL' || $huesped['status']=='HUESPED' || $huesped['status']=='RESERVA GRUPO'){
		$huesped['status']='X SALDAR';
		}else{
		$huesped['status']='SALDADO';
		}
	$pdf-> Cell(15,5, $huesped["status"],10,0,'C',0);
	$pdf-> Cell(15,5, chfecha($huesped['ffecllegada'],'Y-m-d'),10,0,'C',0);
	$pdf-> Cell(15,5, chfecha($huesped['ffecsalida'],'Y-m-d'),10,0,'C',0);
	
	    $pdf-> Cell(15,5, $row["can_ref"],10,0,'C',0);
	    $forma=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select * from valeryus09 where n_reg='".$row['nparte1_det']."'"));
	    $pdf-> Cell(15,5, '$ ' .$row["total"],10,0,'C',0);
	    $pdf-> Cell(10,5, $row["usuario"],10,0,'C',0);
	    $pdf-> Cell(85,5, substr($row["fnorasvip"],0,85),10,1,'L',0);
} 
        $pdf-> Cell(-2,5,'',0,0,'C',0);
		$pdf-> Cell(40,5,'TOTAL DE DEPOSITOS: ',1,0,'L',1);
		$pdf-> Cell(20,5,$a,1,0,'C',1);
		$pdf-> Cell(205,5,'',1,1,'C',1);

$pdf->Output("Reporte de Depositos.pdf","D");
//163-->90 ULTIMA ACTUALIZACION 21/AGOSTO/2012 
?> 