<?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',10);
	    //Espacio
		
	    //Título
	    $this->Cell(190,1,'MASTER PERCEPCIONES DEDUCCIONES',0,1,'C');
	    //Salto de línea
	    $this->Ln(3);
	}
	//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');
	}
}
include("DMMYSQLG.php");
if($_POST['bot']==""){
	if($_POST['tip_bus']=="clave"){
		$sql1 ="SELECT * FROM dnmaster WHERE cve_mae = '".$_POST['txt_t1']."'";
	}elseif($_POST['tip_bus']=="fecha"){
		$sql1 ="SELECT * FROM dnmaster WHERE fec_vig = '".$_POST['txt_t1']."'";
	}else{
		$sql1 = "SELECT * FROM dnmaster";
	}
}else{
	$sql1 = "SELECT * FROM dnmaster WHERE cve_mae = '".$_POST['bot']."'";
}
$sql = mysqli_query ($sql1); 
while ($reg = mysqli_fetch_row($sql)) { 
    $data[] = $reg[0]; 
	$data1[] = $reg[1];
	$data2[] = $reg[2];
	$data3[] = $reg[3];
	$data4[] = $reg[4];
	$data5[] = $reg[5];
	$data6[] = $reg[6];
	}
$num_elementos=count($data);

$pdf=new PDF('P','mm','A4');
$pdf->AddPage();
$pdf->AliasNbPages();
for($i=0;$i<=$num_elementos-1;$i++)
{
	$pdf->SetFont('Arial','B',7);
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->SetFillColor(192,192,192);
	$pdf->Cell(20,4,'CLAVE',1,0,'C',1);
	$pdf->Cell(100,4,'FECHA VIGENCIA',1,1,'C',1);
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->Cell(20,4, $data[$i],1,'0','C');
	$fec1=$data6[$i];
	include('DF20000.php');
	$pdf->Cell(100,4, $f_f,1,1,'C');
	
	$pdf->Cell(32,3,'',0,0,'C');
	$pdf->Cell(120,4,'DESCRIPCION',1,1,'C',1);
	$pdf->Cell(32,3,'',0,0,'C');
	$pdf->Cell(120,4,$data1[$i],1,1,'L');
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->Cell(120,4,'FORMULA CALCULO',1,1,'C',1);
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->Cell(120,4,$data2[$i],1,1,'L');
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->Cell(120,4,'FORMULA EXCENTO ISPT',1,1,'C',1);
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->Cell(120,4,$data3[$i],1,1,'L');
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->Cell(120,4,'FORMULA EXCENTO IMSS',1,1,'C',1);
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->Cell(120,4,$data4[$i],1,1,'L');
	$pdf->Cell(32,4,'',0,0,'C');
	$pdf->Cell(60,4,'PROGRAMA CALCULO',1,0,'');
	$pdf->Cell(60,4,$data5[$i],1,1,'L');
	$pdf->Cell(5,7,'',0,1,'C');

} 
$pdf->Output("Master_Percep_Deducc.pdf","D");
?> 