<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
include("DMMYSQLG.php");
require_once("DF80000.php");
$sql="";
$suma=0;
$Sum=0;
class PDF extends FPDF{
//Cabecera de página
	function Header(){
	    //Logo
	         include("DYIM_VER.php");
	    //Arial bold 14
		$this->SetFont('Arial','B',14);
		//Título
		$this->Cell(225,5,'REGISTRO DE RESERVACIONES DE GRUPO',0,1,'C',0);
		//Salto de línea
		$this->Ln(8);
		$this->SetFont('Arial','B',9);//establece tamaño de letra
		$this->SetFillColor(192,192,192);
		$this->Cell(1,5,'',0,0,'C',0);
		$this->Cell(40,5,'HABITACION',1,0,'R',1);
		$this->Cell(50,5,'NOMBRE DEL HUESPED',1,0,'C',1);
		$this->Cell(15,5,'FOLIO',1,0,'C',1);
		$this->cell(10,5,'ADUL',1,0,'C',1);
		$this->cell(10,5,'MEN',1,0,'C',1);
		$this->cell(20,5,'LLEGADA',1,0,'C',1);
		$this->cell(20,5,'SALIDA',1,0,'C',1);
		$this->cell(45,5,'GRUPO',1,0,'C',1);
                $this->cell(45,5,'AGENCIAS',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

$tbus=mysqli_real_escape_string($GLOBALS['con'],$_POST['tbus']);
//if(!isset($_POST['bot']))$_POST['bot']="";
if(isset($_POST['bot']) && $_POST['bot']==""){
    
}else{
$TqM=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select * from valeryus19 where n_reg='".$_POST['bot']."'"));
$grupo=$TqM['fcodgrupo'];
$fecha=$TqM['ffecllegada'];
@$sql = mysqli_query($GLOBALS['con'] ,"SELECT * FROM valeryus19 WHERE fcodgrupo='$grupo' and cancelado='0' and status='RESERVA GRUPO' ORDER BY fnumcto DESC");
}
$a=0;
while($row = mysqli_fetch_array($sql)){
    $pdf-> Cell(1,5,'',0,0,'C',0);
    //$nuevo=$row['ftipocto'];
    $arr=explode(" ",$row['ftipocto']);
    $cadena=' ';
    for($i=0; $i<count($arr); $i++){
        $cadena.=substr($arr[$i],0,1)." "; 
    }

//$TCto=$row['ftipocto'];
	//$Cod=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select * from valeryus05 where descripcion='$TCto'"));
	$pdf-> Cell(10,5, $row["fnumcto"],1,0,'C',0);
	$pdf-> Cell(30,5, $cadena,1,0,'L',0);
	$pdf-> Cell(50,5, substr($row["fnombre"]." ".$row["fapellido"],0,25),1,0,'L',0);
	$pdf-> Cell(15,5, $row["n_reg"],1,0,'C',0);
	$sqw=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select count(n_reg) as Folios, count(ftipocto) as TiPos from valeryus19 where fcodgrupo='$grupo' and cancelado='0' and status='RESERVA GRUPO'"));
	//while ($asd=mysqli_fetch_array($sqw)){
	//$pdf-> Cell(29,5, $asd["TiPos"],1,0,'C',0);
	//if(!isset($asd['TiPos']))$asd['TiPos']="";
	$vat=isset($asd["TiPos"])?$asd["TiPos"]:"";
        $suma+=$vat;//$asd["TiPos"];
	$rsu=$suma-1;
	$Sum+=$sqw["Folios"];
	//}
	$pdf-> Cell(10,5, $row["fnumadu"],1,0,'C',0);
	$pdf-> Cell(10,5, $row["fnummenor"],1,0,'C',0);
	$pdf-> Cell(20,5, chfecha($row['ffecllegada'],'Y-m-d'),1,0,'C',0);
	$pdf-> Cell(20,5, chfecha($row['ffecsalida'],'Y-m-d'),1,0,'C',0);
	$pdf-> Cell(45,5, substr($grupo,0,25),1,0,'C',0);
        $pdf-> Cell(45,5, substr($row['fcodagen'],0,25),1,1,'C',0);
	$a++;
}
    $b=$a-1;
	$pdf-> Cell(10,5,'',0,0,'C',0);
	$pdf-> Cell(66,5, 'CUARTOS:   '.$b.'',1,0,'C',0);
	$pdf-> Cell(50,5, 'FOLIOS:    '.$a.'',1,0,'C',0);

$pdf->Output("Registro De Reservaciones De Grupo.pdf","D");
//81 ULTIMA ACTUALIZACION 27/OCTUBRE/2011 TOTALIZAR GRUPOS
?>                                               