<?php

include('pdf/fpdf.php');
session_cache_limiter('private');
session_start();
$com = "I";
include("DMMYSQLG.php");
include("DSA3000.php");
include("DMMYSQLG.php");
include('DF80000.php');
class PDF extends FPDF
{
	//Cabecera de Página
	function Header()
	{
	    //Logotipo
	    include("DYIM_VER.php");
	    //Arial Bold (14)
	    $this->SetFont('Arial','B',12);
	    $this->Cell(280,3,'REPORTE DE PROGRAMACION DE INCIDENCIAS',0,1,'C');
		$sq_tipnom=mysqli_query($GLOBALS['con'] ,"select * from dntipnom where cve_nomi = '".$_REQUEST['tn']."'");
		$dt_tipnom=mysqli_fetch_array($sq_tipnom);
	   	$this->Cell(280,10,$dt_tipnom['des_nomi'],0,1,'C');
	   	$this->Cell(280,10,'DEL ' . chfecha($_REQUEST['t1'],"d/m/Y","d de M del Y") . ' AL ' . chfecha($_REQUEST['t2'],"d/m/Y","d de M del Y"),0,1,'C');
	    //Salto de línea
	    $this->Ln(3);
		$this->SetFont('Times','',8);
		$this->SetFillColor(192,192, 192);
		$this->Cell(10,5,'N°',1,0,'C',1);
		$this->Cell(60,5,'EMPLEADO',1,0,'C',1);
		$this->Cell(20,5,'FEC/INI',1,0,'C',1);
		$this->Cell(20,5,'FEC/FIN',1,0,'C',1);
		$this->Cell(20,5,'ENTRADA',1,0,'C',1);
		$this->Cell(20,5,'SALIDA',1,0,'C',1);
		$this->Cell(60,5,'AUSENCIA',1,0,'C',1);
		$this->Cell(70,5,'OBSERVACIONES',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();

	$fec = $_POST['t1'];
	include('DF20000.php');
		$fecha_inicial = $f_m;
		//$pdf->Cell(15,5,$fecha_inicial,1,0,'C');
	$fec = $_POST['t2'];
	include('DF20000.php');
		$fecha_final = $f_m;
 $sql=mysqli_query($GLOBALS['con'] ,"select dnrelcau.*, dntrab_a.* from dnrelcau INNER JOIN dntrab_a ON dnrelcau.empleado = dntrab_a.no_nom  where (fec_ini >= '$fecha_inicial' and fec_ini <= '$fecha_final') or (fec_fin >= '$fecha_inicial' and fec_fin <= '$fecha_final')");
while ($reg = mysqli_fetch_array($sql)) { 
		$pdf->Cell(10,5, $reg['empleado'],1,'0','C');
		$pdf->Cell(60,5, $reg['nom'],1,'0','C');
		$pdf->Cell(20,5, chfecha($reg['fec_ini'],"Y-m-d","d/m/Y"),1,'0','C');
		$pdf->Cell(20,5, chfecha($reg['fec_fin'],"Y-m-d","d/m/Y"),1,'0','C');
		$pdf->Cell(20,5, $reg['hor_ent'],1,'0','C');
		$pdf->Cell(20,5, $reg['hor_sal'],1,'0','C');
		$sqlx = mysqli_query($GLOBALS['con'] ,"select * from dnmotaus where no_reg= '".$reg['ausencia']."'");
		$regx = mysqli_fetch_array($sqlx);
		$pdf->Cell(60,5, $regx['descrip'],1,'0','C');
		$pdf->Cell(70,5, $reg['observac'],1,1,'C');
}

$pdf->Output();
?>