<?php

require('fpdf/fpdf.php');

class PDF extends FPDF
{

private $tipoformato;
private $valor;

function colordia()
{
    //Colores, ancho de línea y fuente en negrita
    $this->SetFillColor(255,0,0);
    $this->SetTextColor(255);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
}	


function ImprimirTabla($data,$x, $y, $h, $w,$alig)
{
    $this->SetFillColor(224,200,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
	$dib=false;
   	for($i=0;$i<count($data);$i++)
    {
	for($j=0;$j<count($w);$j++)
		{
        $this->Cell($w[$j],$h,$data[$i][$j],1,0,$alig[$j],$dib);
		$dib = !$dib;
        }
		$y = $y + $h;
		$this->SetXY($x,$y);
		
    }
}

function ImprimirTablaTitulo($data,$x, $y, $h, $w,$alig,$dib)
{
    $this->SetFillColor(224,200,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
	  	
	
        $this->Cell($w,$h,$data,1,0,$alig,$dib);
		//$dib = !$dib;
    
		//$this->SetXY($x,$y);
		
    
}

function ImprimirTablaSinColor($data,$x, $y, $h, $w,$alig)
{
    $this->SetFillColor(224,200,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
	$dib=false;
   	for($i=0;$i<count($data);$i++)
    {
	for($j=0;$j<count($w);$j++)
		{
        $this->Cell($w[$j],$h,$data[$i][$j],1,0,$alig[$j],$dib);
		//$dib = !$dib;
        }
		$y = $y + $h;
		$this->SetXY($x,$y);
		
    }

}

function ImprimirTablaSinColorLineal($data,$x, $y, $h, $w,$alig)
{
    $this->SetFillColor(224,200,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
	$dib=false;
   	for($i=0;$i<count($data);$i++)
    {
	        $this->Cell($w[$i],$h,$data[$i],1,0,$alig[$i],$dib);
		//$dib = !$dib;
    }
		//$y = $y + $h;
		//$this->SetXY($x,$y);
		
    //}

}

function ImprimirTablaSinColorFirma($data,$x, $y, $h, $w,$alig,$dibuja)
{
    $this->SetFillColor(224,200,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
	$dib=false;
   	for($i=0;$i<count($data);$i++)
    {
	        $this->Cell($w[$i],$h,$data[$i],$dibuja[$i],0,$alig[$i],$dib);
		//$dib = !$dib;
    }
		//$y = $y + $h;
		//$this->SetXY($x,$y);
		
    //}

}

function ImprimirTablaHorario($data,$x, $y, $h, $w,$alig)
{
    $this->SetFillColor(224,200,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
	$dib=false;
   		for($j=0;$j<count($w);$j++)
		{
        $this->Cell($w[$j],$h,$data[$j],1,0,$alig,$dib);
		//$dib = !$dib;
		$x = $x + $w[$j];
		$this->SetXY($x,$y);
        }
		
		
    

}

function ImprimirTablaJustificada($data,$x, $y, $h, $w,$alig,$d)
{
    $this->SetFillColor(224,200,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
	$dib=false;
	$h=$h/$d;
   	for($i=0;$i<count($data);$i++)
    {
	for($j=0;$j<count($w);$j++)
		{
		$this->MultiCell($w[$j],$h,$data[$i][$j],1,$alig[$j],$dib);
		$dib = !$dib;
        }
		$y = $y + $h;
		$this->SetXY($x,$y);
		
    }

}

function ImprimirTablaArea($data,$x, $y, $h, $w,$alig,$d,$horario)
{
    $this->SetFillColor(224,200,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
	$dib=false;
	//$h=($h/$d)*$horario;
	//$h = $h*$horario;
		$this->Cell($w,$h,$data,1,0,$alig,$dib);
		//$this->MultiCell($w,$h,$data,1,$alig,$dib);
		//$dib = !$dib;
        //$y = $y + $h;
		//$this->SetXY($x,$y);

}

function ImprimirDias($data,$x, $y, $h, $w,$alig,$pint)
{
    
    $this->SetTextColor(42,20,172);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
   	for($i=0;$i<count($data);$i++)
    {
	$this->SetFillColor($pint[$i][0],$pint[$i][1],$pint[$i][2]);
	
        $this->Cell($w[$i],$h,$data[$i],1,0,$alig[$i],true);
        //$y = $y + $h;
	}

}

function ImprimirDiasHoras($data,$x, $y, $h, $w,$alig,$pint)
{
    
    $this->SetTextColor(42,20,172);
    $this->SetDrawColor(128,0,0);
    $this->SetLineWidth(.3);
    $this->SetFont('','B');
	$this->SetXY($x,$y);
    //Datos
   	for($i=0;$i<count($data);$i++)
    {
	$this->SetFillColor($pint[$i][0],$pint[$i][1],$pint[$i][2]);
	
        $this->Cell($w[$i],$h,$data[$i],1,0,$alig[$i],true);
        //$x = $x + $w[$i];
		//$this->SetXY($x,$y);
	}

}

			function Footer()
			{
					// Go to 1.5 cm from bottom
					$this->SetTextColor(0,0,0);
					$this->SetY(-15);
					// Select Arial italic 8
					$this->SetFont('Arial','I',8);
					// Print centered page number
					date_default_timezone_set('UTC');
				//	setlocale(LC_TIME,"spanish");
					$fecha = date("d/m/Y", time()-18000);
					$hora = date("h:i:s A", time() - 18000);
					$tipo = $this->getTipoFormato();
					$this->Cell(0,10,'Formato: '.$tipo.'   Fecha:'.$fecha.'   Hora: '.$hora.'   Pagina '.$this->PageNo().'/{nb}',0,0,'R');
			}
			
			public function setTipoFormato($val){
				$this->valor=$val;
			}
			
			public function getTipoFormato(){
				$val = $this->valor;
				return $this->leer_formato($val);
			}


			private function leer_formato($tipo){
				if($tipo==1){
					$cadena = "Programación";
				}
				if($tipo==2){
					$cadena = "Reprogramación";
				}
				if($tipo==3){
					$cadena = "Ejecución";
				}
				return $cadena;
			}
	

}

?>