<?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(275,1,'TABULADOR SUELDOS',0,1,'C');
		
	    $this->Ln(6);
		
	    $this->SetFont('Arial','',6);
		$this->SetFillColor(192,192,192);

	    $this->Cell(18,5,'CLAVE NOMINA',1,0,'C',1);
	    $this->Cell(52,5,'NOMBRE',1,0,'C',1);
	    $this->Cell(27,5,'RFC',1,0,'C',1);
	    $this->Cell(19,5,'FECHA VIGENCIA',1,0,'C',1);
	    $this->Cell(21,5,'SUELDO MENSUAL',1,0,'C',1);
	    $this->Cell(18,5,'SALARIO DIARIO',1,0,'C',1);
	    $this->Cell(21,5,'INTEGRACION IMSS',1,0,'C',1);
	    $this->Cell(23,5,'SALARIO INTEGRADO',1,0,'C',1);
	    $this->Cell(38,5,'PUESTO',1,0,'C',1);
	    $this->Cell(38,5,'DEPARTAMENTO',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');
	}
}

$pdf=new PDF('L','mm','A4');
$pdf->AddPage();
$pdf->AliasNbPages();

$sql_dap = mysqli_query($GLOBALS['con'] ,"SELECT * FROM dntrab_a ORDER BY no_nom");

while($row_dap = mysqli_fetch_array($sql_dap))
{

    $pdf->Cell(18,5,$row_dap["no_nom"],0,0,'C');
    $pdf->Cell(52,5,$row_dap["nom"] . ' ' . $row_dap["ape_pat"] . ' ' . $row_dap["ape_mat"],0,0,'L');

	$sql_da = mysqli_query($GLOBALS['con'] ,"SELECT * FROM dntrab_b WHERE no_nom = '".$row_dap['no_trab']."'");
	$row_da = mysqli_fetch_array($sql_da);
    $pdf->Cell(27,5,$row_da["rfc"],0,0,'L');

	$sql_dan = mysqli_query($GLOBALS['con'] ,"SELECT * FROM dndatnom WHERE no_nom = '".$row_dap['no_trab']."'");
	$row_dan = mysqli_fetch_array($sql_dan);
	
	$f_f="";
	
	$fec1=$row_dan["fec_alta"];
	include('DF20000.php');
    $pdf->Cell(19,5,$f_f,0,0,'C');

    $pdf->Cell(21,5,number_format($row_dan["sdo_mensual"], 2, '.', ','),0,0,'R');
    $pdf->Cell(18,5,number_format($row_dan["sal_diario"], 2, '.', ','),0,0,'R');
    $pdf->Cell(21,5,number_format($row_dan["int_imss"], 2, '.', ','),0,0,'R');
    $pdf->Cell(23,5,number_format($row_dan["sal_int"], 2, '.', ','),0,0,'R');
    
	$sql_pue = mysqli_query($GLOBALS['con'] ,"SELECT * FROM dncatpue WHERE no_puesto = '".$row_dan['puesto']."'");
	$row_pue = mysqli_fetch_array($sql_pue);	
	$pdf->Cell(38,5,$row_pue["des_puesto"],0,0,'L');
	
	$sql_dep = mysqli_query($GLOBALS['con'] ,"SELECT * FROM dncatdep WHERE no_depto = '".$row_dan['depto']."'");
	$row_dep = mysqli_fetch_array($sql_dep);	
    $pdf->Cell(38,5,$row_dep["des_depto"],0,1,'L');

}

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