<?php require('fpdf.php');

class PDF extends FPDF
{
// Cabecera de página
function Header(){
include('../librerias/conex.php');

if (isset($_REQUEST['pnrocmp'])){$pnrocmp=$_REQUEST['pnrocmp'];}else{$pnrocmp="";} 
if (isset($_REQUEST['pnriper'])){$pnriper=$_REQUEST['pnriper'];}else{$pnriper="";} 
if (isset($_REQUEST['pcodemp'])){$pcodemp=$_REQUEST['pcodemp'];}else{$pcodemp="";}


$link=@Conectarse(); 
$correr=0;
$Sqlconsulta="select nomcmp.*,admemp.diremp,admemp.nitemp,admemp.digemp,admemp.obsemp,admemp.nomemp from nomcmp,admemp where nomcmp.codsed=admemp.codsed and nomcmp.nrocmp='".$pnrocmp."' and nomcmp.estcmp!='Eliminado' ";

$resultcar = mysql_query($Sqlconsulta,$link);
while($rowcar = mysql_fetch_array($resultcar)){
extract($rowcar);
//llenar datos del JSON
	$nriper=$rowcar['nriper'];
	$nomper=$rowcar['nomper'];
	$fchcmp=$rowcar['fchcmp'];
	$nrofac=$rowcar['nrocmp'];
	$dirter="";
	$nrorem="";
	$fincmp=$rowcar['fincmp'];
	$inicmp=$rowcar['inicmp'];
	$ciuter="";
	$telter="";
	$dirent="";
	$cttord="";
	$cttprv="";
	$emlprv="";
	$nomemp=$rowcar['nomemp'];
	$nitemp=$rowcar['nitemp'];
	$diremp=$rowcar['diremp'];
	$obsemp=$rowcar['obsemp'];
    $correr=$correr+1;
}
mysql_free_result($resultcar);
mysql_close($link);
	
    // Logo
     $this->Image('themes/images/logo.png',10,1,50);
	 $this->Image('themes/images/linea.png',10,58,195);
	 $this->Image('themes/images/cuadro.png',110,31,90);
	  
    // Arial bold 15
    $this->SetFont('Arial','B',15);
    // Movernos a la derecha
    $this->Cell(50,1);
    // Título
     $this->Cell(10,1,$nomemp,0,0,'0');
	 $this->Cell(100,1);
	 $this->SetFont('Arial','',7);
	 $this->Cell(10,1,'EM-EMPIRE',0,0,'0');
	
    // Salto de línea
     $this->Ln(5);
	 $this->Cell(90,1);
	 $this->SetFont('Arial','B',10);
	 $this->Cell(10,1,'NIT:'+$nitemp,0,0,'0');
	 $this->Cell(55,1);
	 $this->SetFont('Arial','',9);
	 $DateOfRequest =  date("d/m/Y H:i:s"); 
	 $this->Cell(90,1,$DateOfRequest,0,0,'0');
	 
	 $this->Ln(5);
	 $this->Cell(60,1);
	 $this->SetFont('Arial','',9);
	 $this->Cell(10,1,$obsemp,0,0,'0');
	 $this->Ln(8);
	 
	 $this->Cell(110,1);
	 $this->SetFont('Arial','B',12);
	 $this->Cell(2,1,'VOLANTE No.'.$pnrocmp,0,0,'0');
	 $this->Ln(6);
	 
	 $this->Cell(1,1);
	 $this->SetFont('Arial','B',10);
	 $this->Cell(2,1,'EMPLEADO ',0,0,'0');
	 
	 $this->Cell(22,1);
	 $this->SetFont('Arial','',9);
	 $this->Cell(2,1,rtrim($nriper)."-".rtrim($nomper),0,0,'0');
	 
	 $this->Cell(75,1);
	 $this->SetFont('Arial','B',10);
	 $this->Cell(2,1,'Inicia:',0,0,'0');
	 $this->Cell(18,1);
	 $this->SetFont('Arial','',9);
	 $this->Cell(2,1,rtrim($inicmp),0,0,'0');
	 
	 $this->Cell(30,1);
	 $this->SetFont('Arial','B',9);
	 $this->Cell(2,1,'Finaliza:',0,0,'0');
	 $this->Cell(12,1);
	 $this->SetFont('Arial','',9);
	 $this->Cell(2,1,rtrim($fincmp),0,0,'0');
	 $this->Ln(5);
	 
	 $this->Cell(1,1);
	 $this->SetFont('Arial','B',9);
	 $this->Cell(2,1,'CARGO: ',0,0,'0');
	 $this->Cell(21,1);
	 $this->SetFont('Arial','',9);
	 $this->Cell(2,1,$nomcrg,0,0,'0');
	 
	 $this->Cell(76,1);
	 $this->SetFont('Arial','B',9);
	 $this->Cell(2,1,'Salario:',0,0,'0');
	 $this->Cell(16,1);
	 $this->SetFont('Arial','',9);
	 $this->Cell(2,1,$vlrsal,0,0,'0');
	 
	 $this->Cell(32,1);
	 $this->SetFont('Arial','B',9);
	 $this->Cell(2,1,'Dias Lab: ',0,0,'0');
	 $this->Cell(12,1);
	 $this->SetFont('Arial','',9);
	 $this->Cell(2,1,$dialab,0,0,'0');
	 $this->Ln(5);
	 
	 $this->Cell(1,1);
	 $this->SetFont('Arial','B',9);
	 $this->Cell(2,1,'SEDE: ',0,0,'0');
	 $this->Cell(21,1);
	 $this->SetFont('Arial','',9);
	 $this->Cell(2,1,$nomcrg,0,0,'0');
	  $this->Ln(5);
	 
	 $this->Cell(1,1);
	 $this->SetFont('Arial','B',9);
	 $this->Cell(2,1,'EPS:',0,0,'0');
	 $this->Cell(21,1);
	 $this->SetFont('Arial','',8);
	 $this->Cell(2,1,$nomcrg,0,0,'0');
	 $this->Ln(5);
	 
	 $this->Cell(1,1);
	 $this->SetFont('Arial','B',8);
	 $this->Cell(2,1,'PENSION:',0,0,'0');
	 $this->Cell(21,1);
	 $this->SetFont('Arial','',8);
	 $this->Cell(2,1,$nomcrg,0,0,'0');
   $this->Ln(7);
   
   

	 
}

// Pie de página
function Footer()
{
	
    // Posición: a 1,5 cm del final
    $this->SetY(-15);
	$this->Image('themes/images/pie.png',10,150,0);
	
    // Arial italic 8
    $this->SetFont('Arial','I',8);
    // Número de página
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}

// Creación del objeto de la clase heredada
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();

	 $pdf->Cell(1,1);
	 $pdf->SetFont('Arial','B',9);
	 $pdf->Cell(2,1,'CONCEPTO',0,0,'0');
	 
	 $pdf->Cell(45,1);
	 $pdf->SetFont('Arial','B',9);
	 $pdf->Cell(2,1,'CANTIDAD',0,0,'0');
	 
	 $pdf->Cell(20,1);
	 $pdf->SetFont('Arial','B',9);
	 $pdf->Cell(2,1,'V. UNITARIO',0,0,'0');
	 
	 $pdf->Cell(25,1);
	 $pdf->SetFont('Arial','B',9);
	 $pdf->Cell(2,1,'DEVENGOS',0,0,'0');
	 
	 $pdf->Cell(30,1);
	 $pdf->SetFont('Arial','B',9);
	 $pdf->Cell(2,1,'DEDUCCIONES',0,0,'0');
	 
	 $pdf->Cell(35,1);
	 $pdf->SetFont('Arial','B',9);
	 $pdf->Cell(2,1,'ASIGNACIONES',0,0,'0');
$pdf->Ln(5);

if (isset($_REQUEST['pnrocmp'])){$pnrocmp=$_REQUEST['pnrocmp'];}else{$pnrocmp="";}
$link=@Conectarse(); 
$correr=0;
$Sqlconsulta="select * from nompre where nrocmp='".$pnrocmp."' order by codknp";
$resultcar = mysql_query($Sqlconsulta,$link);
while($rowcar = mysql_fetch_array($resultcar)){
extract($rowcar);
//llenar datos del JSON
	 $pdf->Cell(1,1);
	 $pdf->SetFont('Arial','',9);
	 $pdf->Cell(2,1,$rowcar['codknp']."-".$rowcar['nomknp'],0,0,'0');
	 
	 $pdf->Cell(45,1);
	 $pdf->SetFont('Arial','',9);
	 $pdf->Cell(2,1,$rowcar['canknp'],0,0,'0');
	 
	 $valor=number_format($rowcar['devnom']);
	 $pdf->Cell(20,1);
	 $pdf->SetFont('Arial','',9);
	 $pdf->Cell(2,1,$valor,0,0,'0');
	 
	 $pdf->Cell(25,1);
	 $pdf->SetFont('Arial','',9);
	 $pdf->Cell(2,1,$rowcar['codknp'],0,0,'0');
	 
	 $valort=number_format($rowcar['devnom']);
	 $pdf->Cell(30,1);
	 $pdf->SetFont('Arial','',9);
	 $pdf->Cell(2,1,$valort,0,0,'0');
	 
	 $pdf->Cell(35,1);
	 $pdf->SetFont('Arial','',9);
	 $pdf->Cell(2,1,$rowcar['codknp'],0,0,'0');
$pdf->Ln(5);



    $correr=$correr+1;
}
mysql_free_result($resultcar);
mysql_close($link);

	 $pdf->Cell(1,1);
	 $pdf->SetFont('Arial','',9);
	 $pdf->Cell(2,1,'OBSERVACION:',0,0,'0');

$pdf->Output();

mysql_close($link);

?>