<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
$com = "I";
include("DMMYSQLG.php");
//include("DSA3000.php");
include("DMMYSQLG.php"); 
class PDF extends FPDF
{
	//Cabecera de página
	function Header()
	{
	    //Logo
	   // include("DYIM_VER.php");
	    //Arial bold 14
	    $this->SetFont('Arial','B',10);
	
	    //Título
			$this->Cell(230,3,'REPORTE DE CUENTAS ABIERTAS',0,1,'C');
	    //Salto de línea
	    $this->Ln(8);
		$this->Cell(230,3,'REPORTE DE CUENTAS ABIERTAS',0,1,'C');
		//$this->Cell(10,5,'',0,'C');//centra
		$this->SetFont('Times','',7);//establece tamaño de letra
		$this->SetFillColor(192,192, 192);
		$this->Cell(40,5,'',0,'','C',0);
		$this->Cell(20,5,'PUNTO DE VENTA',1,'','C',1);
		$this->Cell(45,5,'MESA',1,'','C',1);
		$this->Cell(35,5,'FOLIO VTA.',1,'','C',1);
		$this->Cell(30,5,'No. POSICION',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','',8);
	    //Número de página
	    $this->Cell(0,10, $this->PageNo().'/{nb}',0,0,'C');
	}
}
$sql = "SELECT ctmesas.*,fpos.fol_ven as folVen, fpos.nparte1 as fPos,ptventa.np_desc1 as ptVta  from ctmesas 
		left join ptventa on (ptventa.nparte1=ctmesas.descripcion) 
		left join ctarea on (ctarea.nparte1=ctmesas.area)
		left join fpos on (fpos.mesa=ctmesas.nparte1)
		where ctmesas.status=1 and fpos.status=1 ";
$result = mysqli_query ($sql) or die (mysqli_error($GLOBALS['con'])); 
$num_elementos=count($data);
$pdf=new PDF('L','mm','Letter');
$pdf->AddPage();
while ($data = mysqli_fetch_array($result)) { 
    $pdf->Cell(40,5,'',0,'','C',0);
	$pdf->Cell(20,5, $data['ptVta'],0,'','C');
	$pdf->Cell(45,5, $data['np_desc1'].'('.$data['posicion'].')',0,'','C');
	@$fol=mysqli_fetch_array(mysqli_query($GLOBALS['con'] ,"select con_ven as folio from dgpemema where fol_ven='".$data['folVen']."'")); 		
	$pdf->Cell(35,5, $fol['folio'],0,'','C');
	$pdf->Cell(30,5, $data['fPos'],0,'1','C');
} 
$pdf->Output("Cuentas Abiertas.pdf","D");
?> 
