<?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
{
	function Header()
	{
	    include("DYIM_VER.php");

	    $this->SetFont('Arial','B',12);
	    $this->Cell(190,2,'COLORES',0,1,'C');
		
	    $this->Ln(3);
		
	    $this->SetFont('Arial','',7);
		$this->SetFillColor(192,192,192);
 	    $this->Cell(18,5,'CLAVE',1,0,'C',1);
	    $this->Cell(60,5,'NOMBRE',1,1,'C',1);
	}
	function Footer()
	{
	    $this->SetY(-15);
	    $this->SetFont('Arial','I',8);
	    $this->Cell(0,0, $this->PageNo().'/{nb}',0,0,'C');
	}
}

if($_POST['bot']==""){
	if($_POST['tip_bus']=="clave"){
		$sql1 ="SELECT * FROM dpcatcol WHERE cve = '".$_POST['txt_t1']."'";
	}elseif($_POST['tip_bus']=="nombre"){
		$sql1 ="SELECT * FROM dpcolores WHERE color LIKE '%".$_POST['txt_t1']."%'";
	}else{
		$sql1 = "SELECT * FROM dpcatcol";
	}
}else{
	$sql1 = "SELECT * FROM dpcatcol WHERE cve = '".$_POST['bot']."'";
}
$sql = mysqli_query ($sql1); 
while ($reg = mysqli_fetch_row($sql)) { 
    $data[] = $reg[0]; 
	$data1[] = $reg[1];
	$data2[] = $reg[2];
	}
$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, $data1[$i],0,'0','C');
	$pdf->Cell(60,5, $data2[$i],0,'1','L');
} 
$pdf->Output("Colores.pdf","D");
?> 