<?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',11);
	    //Espacio
		
	    //Título
	    $this->Cell(190,3,'REPORTE CATEGORIA',0,1,'C');
	    //Salto de línea
	    $this->Ln(3);
		$this->SetFont('Times','',7);//establece tamaño de letra
		$this->SetFillColor(192,192, 192);
		$this->Cell(23,5,'',0,'C');//centra
		$this->Cell(15,5,'Grupo',1,0,'C',1);
		$this->Cell(40,5,'Descripcion',1,0,'C',1);
		$this->Cell(30,5,'Rango Vat1 Hasta',1,0,'C',1);
		$this->Cell(30,5, 'Rango Vat2 Hasta',1,0,'C',1);
		$this->Cell(30,5, 'Rango Vat3 Hasta',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');
	}
}

if($_POST['bot']==""){
	if($_POST['tip_bus']=="clave"){
		$sql1 ="SELECT * FROM dgbasicop WHERE gpo_basico = '".$_POST['txt_bus']."' order by gpo_basico";
	}elseif($_POST['tip_bus']=="nombre"){
		$sql1 ="SELECT * FROM dgbasicop WHERE des_basico LIKE '%".$_POST['txt_bus']."%' order by gpo_basico";
	}else{
		$sql1 = "SELECT * FROM dgbasicop order by gpo_basico";
	}
}else{
	$sql1 = "SELECT * FROM dgbasicop WHERE gpo_basico = '".$_POST['bot']."' order by gpo_basico";
}
$sql = mysqli_query ($sql1); 
while ($reg = mysqli_fetch_row($sql)) { 
    $data[] = $reg[0]; 
	$data1[] = $reg[2]; 
	$data2[] = $reg[3];
	$data3[] = $reg[4]; 
	$data4[] = $reg[5];  
	}
$num_elementos=count($data);
$pdf=new PDF();
$pdf->AddPage();
//Titolo de la tabla
$pdf->SetFont('Times','',8);//establece tamaño de letra
$pdf->SetFillColor(49,120, 200);


for($i=0;$i<=$num_elementos-1;$i++)
{
	//$pdf->SetFillColor(49,120, 200);
	$pdf->Cell(23,5,'',0,'C');//centra
	$pdf->Cell(15,5, $data[$i],1,'','C');
	$pdf->Cell(40,5, $data1[$i],1,'','C');
	$pdf->Cell(30,5, $data2[$i],1,'','C');
	$pdf->Cell(30,5, $data3[$i],1,'','C');
	$pdf->Cell(30,5, $data4[$i],1,1,'C');
} 
$pdf->Output("CATEGORIA.pdf","D");
?> 
