<?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");
	}
	function Footer()
	{
	    $this->SetY(-15);
	    $this->SetFont('Arial','I',8);
	    $this->Cell(0,0, $this->PageNo().'/{nb}',0,0,'C');
	}
}

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

$pdf->SetFont('Arial','B',8);
$pdf->SetFillColor(192,192,192);

$sql_a=mysqli_query($GLOBALS['con'] ,"SELECT * FROM dntrab_a WHERE no_trab='".$_POST['bot']."'");
$row_a=mysqli_fetch_array($sql_a);

$fotografia = 'foto/NO_'. $row_a['no_nom'] .'.JPG';
if (file_exists($fotografia)) {
    $pdf->Image('foto/NO_'.$row_a['no_nom'].'.JPG',24,45,35,45);
}else{
    $pdf->Image('foto/Sin_Foto.jpg',24,45,35,45);
}

$sql_b=mysqli_query($GLOBALS['con'] ,"SELECT * FROM dntrab_b WHERE no_trab='".$_POST['bot']."'");
@$row_b=mysqli_fetch_array($sql_b);

$sql_dn=mysqli_query($GLOBALS['con'] ,"SELECT * FROM dndatnom WHERE no_trab='".$_POST['bot']."'");
@$row_dn=mysqli_fetch_array($sql_dn);

$sql_ba=mysqli_query($GLOBALS['con'] ,"SELECT * FROM dxcatban WHERE cve_banco='".$row_dn['banco']."'");
@$row_ba=mysqli_fetch_array($sql_ba);
	  
$pdf->Cell(5,9,'',0,1,'C');
$pdf->Cell(62,5,'',0,0,'C');
$pdf->Cell(125,5,'NOMINA   '.'( ' . $row_a["no_nom"] . ' | ' . $row_a["nom"] . ' ' . $row_a["ape_pat"] . ' ' . $row_a["ape_mat"] . ' )',0,1,'C',1);

$pdf->Cell(62,4,'',0,1,'C');
$pdf->Cell(62,5,'',0,0,'C');
$pdf->Cell(125,5,'NACIONALIDAD:   '.$row_b["nacion"],0,1,'L');

$pdf->Cell(62,4,'',0,1,'C');
$pdf->Cell(62,5,'',0,0,'C');
$pdf->Cell(26,5,'EDAD:   '.$row_b["edad"].' AŅOS',0,1,'L');

$pdf->Cell(62,5,'',0,0,'C');

if($row_b["edo_civ"]=="S"){
	$edo_civil="SOLTERO";
}elseif($row_b["edo_civ"]=="C"){
	$edo_civil="CASADO";
}elseif($row_b["edo_civ"]=="V"){
	$edo_civil="VIUDO";
}elseif($row_b["edo_civ"]=="D"){
	$edo_civil="DIVORCIADO";
}
$pdf->Cell(125,5,'ESTADO CIVIL:   '.$edo_civil,0,1,'L');

$pdf->Cell(62,2,'',0,1,'C');
$pdf->Cell(62,5,'',0,0,'C');
$pdf->Cell(125,5,'RFC:   '.$row_b["rfc"],0,1,'L');
$pdf->Cell(62,5,'',0,0,'C');
$pdf->Cell(125,5,'CREDENCIAL DE ELECTOR:   '.$row_b["no_cred_elec"],0,1,'L');
$pdf->Cell(62,5,'',0,0,'C');
$pdf->Cell(125,5,'AFILIACION AL SEGURO SOCIAL:   '.$row_b["seg_soc"],0,1,'L');

$pdf->Cell(62,5,'',0,1,'C');
$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(173,5,'DATOS',0,1,'C',1);

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(87,5,'CALLE:   '.$row_b["calle"],0,1,'L');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(43,5,'NO  INTERIOR:   '.$row_b["no_int"],0,1,'L');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(43,5,'NO EXTERIOR:   '.$row_b["no_ext"],0,1,'L');

$pdf->Cell(62,3,'',0,1,'C');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(87,5,'ENTRE CALLE:   '.$row_b["en_calle"],0,1,'L');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(86,5,'Y CALLE:   '.$row_b["y"],0,1,'L');

$pdf->Cell(62,3,'',0,1,'C');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(87,5,'COLONIA:   '.$row_b["colonia"],0,1,'L');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(86,5,'CODIGO POSTAL:   '.$row_b["cp"],0,1,'L');

$pdf->Cell(62,3,'',0,1,'C');

include("DMMYSQLG.php");

$pdf->Cell(14,5,'',0,0,'C');
$sql_pa=mysqli_query($GLOBALS['con'] ,"SELECT * FROM dxpaises WHERE cve_pais = '".$row_b['pais']."'");
$row_pa=mysqli_fetch_array($sql_pa);
$pdf->Cell(87,5,'PAIS:   '.$row_pa["des_pais"],0,1,'L');

$pdf->Cell(14,5,'',0,0,'C');
$sql_es=mysqli_query($GLOBALS['con'] ,"SELECT * FROM dxestado WHERE cve_estado = '".$row_b['edo']."'");
$row_es=mysqli_fetch_array($sql_es);
$pdf->Cell(87,5,'ESTADO:   '.$row_es["des_estado"],0,1,'L');

$pdf->Cell(14,5,'',0,0,'C');
$sql_es=mysqli_query($GLOBALS['con'] ,"SELECT * FROM dxdelmun WHERE cve_delmun = '".$row_b['del_mun']."'");
$row_es=mysqli_fetch_array($sql_es);
$pdf->Cell(87,5,'DELEGACION / MUNICIPIO:   '.$row_es["des_delmun"],0,1,'L');

$pdf->Cell(62,5,'',0,1,'C');
$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(173,5,'DATOS NOMINA',0,1,'C',1);

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(87,5,'TIPO DE NOMINA:   '.$row_dn["tip_nom"],0,1,'L');

$pdf->Cell(62,3,'',0,1,'C');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(87,5,'STATUS:   '.$row_dn["status"],0,1,'L');

if($row_dn["fec_baja"]=="0000-00-00"){

	$pdf->Cell(14,5,'',0,0,'C');
	$fec1=$row_dn["fec_alta"];
	include('DF20000.php');
	$pdf->Cell(87,5,'FECHA DE ALTA:   '.$f_f,0,1,'L');

}

if($row_dn["fec_alta"]=="0000-00-00"){

	$pdf->Cell(14,5,'',0,0,'C');
	$fec1=$row_dn["fec_baja"];
	include('DF20000.php');
	$pdf->Cell(45,5,'FECHA DE BAJA:   '.$f_f,0,0,'L');
	$pdf->Cell(45,5,'CAUSA BAJA:   '.$row_dn["causa"],0,1,'L');

}

$pdf->Cell(62,3,'',0,1,'C');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(41,5,'TIPO DE SALARIO:   '.$row_dn["tip_sal"],0,0,'L');
$pdf->Cell(26,5,'SALARIO DIARIO:   '.number_format($row_dn["sal_diario"], 2, '.', ',').'      SUELDO MENSUAL:   '.number_format($row_dn["sdo_mensual"], 2, '.', ','),0,1,'L');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(26,5,'FACTOR:   '.$row_dn["factor"].'      IMPORTE FACTOR:   '.number_format($row_dn["imp_factor"], 2, '.', ',').'      VARIABLE:   '.$row_dn["variable"].'      SALARIO INTEGRADO:   '.number_format($row_dn["sal_int"], 2, '.', ','),0,1,'L');

$pdf->Cell(62,3,'',0,1,'C');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(26,5,'NIVEL EMPLEADO:   '.$row_dn["niv_emp"].'      PUESTO:   '.$row_dn["puesto"].'      DEPARTAMENTO:   '.$row_dn["depto"],0,1,'L');

$pdf->Cell(62,3,'',0,1,'C');

$pdf->Cell(14,5,'',0,0,'C');

$fec1=$row_dn["fec_ini_even"];
include('DF20000.php');
$f1=$f_f;

$fec1=$row_dn["fec_fin_even"];
include('DF20000.php');
$f2=$f_f;

$pdf->Cell(87,5,'TIPO DE EMPLEADO:   '.$row_dn["tip_emp"],0,1,'L');

if($row_dn["tip_emp"]=="EVENTUAL"){

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(87,5,'FECHA INICIAL:   '.$f1.'      FECHA FINAL:   '.$f2,0,1,'L');

}

$pdf->Cell(62,3,'',0,1,'C');

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(87,5,'CUENTA CONTABLE FUN / EMPLEADO:   '.$row_dn["cta_funemp"].'      CUENTA CONTABLE SDO X PAG:   '.$row_dn["cta_sdopag"],0,1,'L');

$pdf->Cell(62,3,'',0,1,'C');

if($row_dn["tip_pag"]=="E"){
	$tip_pago="EFECTIVO";
}elseif($row_dn["tip_pag"]=="T"){
	$tip_pago="TARJETA";
}elseif($row_dn["tip_pag"]=="C"){
	$tip_pago="CHEQUE";
}

$pdf->Cell(14,5,'',0,0,'C');
$pdf->Cell(26,5,'TIPO DE PAGO:   '.$tip_pago.'      BANCO:   '.$row_ba["nom_banco"].'      CUENTA CONTABLE:   '.$row_dn["cta_con"],0,1,'L');

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