<?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()
	{
	    //Logotipo
	    include("DYIM_VER.php");
	    //Arial Bold (14)
	    $this->SetFont('Arial','B',12);
	    //Espacio
		
	    //Título
	    $this->Cell(190,2,'IMPRESORAS' ,0,1,'C');
	    //Salto de línea
	    $this->Ln(3);
	    $this->SetFont('Arial','',7);
		$this->SetFillColor(192,192,192);
 	    $this->Cell(18,5,'CLAVE',1,0,'C',1);
	    $this->Cell(40,5,'NOMBRE',1,1,'C',1);
	}
	//Pie de Página
	function Footer()
	{
	    //Posición: 1,5 cm del Final
	    $this->SetY(-15);
	    //Arial Italic 8
	    $this->SetFont('Arial','I',8);
	    //Número de página
	    $this->Cell(0,0, $this->PageNo().'/{nb}',0,0,'C');
	}
}

if($_POST['bot']==""){
	if($_POST['tip_bus']=="clave"){
		$sql1 ="SELECT * FROM pvimpresora WHERE cve_impres = '".$_POST['txt_t1']."'";
	}elseif($_POST['tip_bus']=="des_impre"){
		$sql1 ="SELECT * FROM pvimpresora WHERE des_impre LIKE '%".$_POST['txt_t1']."%'";
	}else{
		$sql1 = "SELECT * FROM pvimpresora";
	}
}else{
	$sql1 = "SELECT * FROM pvimpresora WHERE cve_impre = '".$_POST['bot']."'";
}
$sql = mysqli_query ($sql1); 
while ($reg = mysqli_fetch_row($sql)) { 
    $data[] = $reg[0]; 
	$data1[] = $reg[1];
	}
$num_elementos=count($data);

$pdf=new PDF('P','mm','A4');
$pdf->AddPage();
$pdf->AliasNbPages();
for($i=0;$i<=$num_elementos-1;$i++)
{
	$pdf->Cell(18,5, $data[$i],0,'0','C');
	$pdf->Cell(40,5, $data1[$i],0,'1','L');
} 
$pdf->Output("Impresoras.pdf","D");
?> 