<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
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',18);
		//Título
		$this->Cell(225,5,'CATALOGO: CARGOS Y ABONOS',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(10,5,'',0,0,'C',0);
		$this->Cell(20,5,'CLAVE',10,0,'C',1);
		$this->Cell(35,5,'DESCRIPCION',10,0,'C',1);
		$this->cell(20,5,'T. CODIGO',10,0,'C',1);
		$this->cell(20,5,'F. PAGO',10,0,'C',1);
		$this->cell(20,5,'GRAVABLE',10,0,'C',1);
		$this->cell(25,5,'NO GRAVABLE',10,0,'C',1);
		$this->cell(15,5,'ISH',10,0,'C',1);
		$this->cell(20,5,'P. DE VENTA',10,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('P','mm','Letter');
$pdf->AddPage();

$pdf->SetFillColor(192,192,192);
$pdf->SetFont('Arial','',7);//establece tamaño de letra
if(!isset($_POST['tbus']))$_POST['tbus']="";
$tbus=mysqli_real_escape_string($GLOBALS['con'],$_POST['tbus']);
if(!isset($_POST['bot']))$_POST['bot']="";
if($_POST['bot']=="")
    $sql =  mysqli_query($GLOBALS['con'] ,"SELECT * FROM valeryus09 order by pclave");
	//$sql = mysqli_query($GLOBALS['con'] ,$_POST['tbus']);
else
	@$sql = mysqli_query($GLOBALS['con'] ,"select * from valeryus09 where n_reg = '".$_POST['bot']."'") ;
	
while($row = mysqli_fetch_array($sql)){
    $pdf-> Cell(10,5,'',0,0,'C',0);
	$pdf-> Cell(20,5, $row["pclave"],10,0,'C',0);
	$pdf-> Cell(35,5, $row["descripcion"],10,0,'C',0);
	$pdf-> Cell(20,5, $row["pmontomax"],10,0,'C',0);
	$pdf-> Cell(20,5, $row["ppago"],10,0,'C',0);
	$pdf-> Cell(20,5, $row["gra"],10,0,'C',0);
	$pdf-> Cell(25,5, $row["no_gra"],10,0,'C',0);
	$pdf-> Cell(15,5, $row["impuesto"],10,0,'C',0);
	$pdf-> Cell(20,5, ' ',10,1,'C',0);
	
}
$pdf->Output("Catalogo Cargos Y Abonos.pdf","D");
?> 