<?php
header('Content-Type: text/html; charset=iso-8859-1');
include ('bd.php');
require ('fpdf/fpdf.php');
date_default_timezone_set("America/La_Paz");
include "core/autoload.php";
include "core/app/model/AdmissionData.php";
include "core/app/model/UserAdmissionData.php";
include "core/app/model/BillData.php";
include "core/app/model/UserData.php";
include "core/app/model/MentionData.php";
include "core/app/model/DivisionData.php";
include "core/app/model/CourseData.php";
include "core/app/model/SufficiencyData.php";

class PDF extends FPDF
{

	function Header()
	{

		//Logo
		$this->SetFillColor(0,0,0); 
		$this->Image('logo coplumu.jpg',5,5,30);
		$this->Cell(189 ,10,'',0,1);//end of line
		//Arial bold 15
		$this->SetFont('Arial','B',8);
		//Movernos a la derecha
		$this->Cell(189 ,10,'',0,1);//end of line
		$this->Cell(30);

		$this->Cell(31,5,'',0,0,'C');
		$this->Cell(25);
		$this->SetFont('Arial','B',12);
		$this->Cell(31,5,'CONSERVATORIO PLURINACIONAL DE MUSICA',0,1,'C');
		$this->SetFont('Arial','B',10);
		$this->Cell(85);
		$this->Cell(31,5,'PROCESO ESPECIAL DE CONVALIDACION INTERNA DE ASIGNATURAS PARA SANEAR LA APLICACION, DESDE LA',0,1,'C');
		$this->Cell(85);
		$this->Cell(31,5,' GESTION 2019, DE LOS MARCOSCURRCULARES APROBADOS POR R.M. NRO 1295/2018 DE 27/12/2018',0,1,'C');
		$this->Cell(85);
		$this->SetFont('Arial','',10);
		$this->Cell(31,5,'Decreto Supremo Nro 1720 de 11 de septiembre de 2013, Resolucion Ministerial Nro 0460/2018 de 19 de Marzo de 2018',0,1,'C');
		$this->Cell(85);
		$this->Cell(31,5,'(MINEDU) y Resolucion Administrativa Nro 09/2021 de 24 de Mayo de 2021 (COPLUMU)',0,1,'C');
		$this->SetFont('Arial','B',12);
		
		$this->Cell(189 ,5,'',0,1);//end of line
		$this->Cell(189 ,5,'.....................................................................................................................................................................',0,1,'C');
		$this->Cell(35,5,'AP. PATERNO',0,0,'C');
		$this->Cell(15);
		$this->Cell(35,5,'AP. MATERNO',0,0,'C');
		$this->Cell(15);
		$this->Cell(35,5,'NOMBRES',0,1,'C');
		$this->Cell(189 ,5,'',0,1);//end of line
		$this->Cell(189 ,5,'.....................................................................................................................................................................',0,1,'C');
		$this->Cell(35,5,'CI.',0,0,'C');
		$this->Cell(15);
		$this->Cell(35,5,'COD. EST.',0,0,'C');
		$this->Cell(15);
		$this->Cell(35,5,'CARRERA.',0,0,'C');
		$this->Cell(15);
		$this->Cell(35,5,'AREA.',0,0,'C');
		$this->Cell(15);
		$this->Cell(35,5,'MENCION',0,1,'C');
		

		//Salto de l�nea
		$this->Ln(5);
		$this->SetAlpha(0.1);
		//$this->Image('fondo9.png', 16, 60, $fpdf->w, $fpdf->h);
		$this->SetAlpha(1);
	}

	function Footer()
	{
		//Posici�n: a 1,5 cm del final
		$this->SetY(-40);
		//Arial italic 8
		$this->SetFont('Arial','B',9);
		//N�mero de p�gina
		//$this->Cell(0,10,'',0,0,'C');
		$this->Cell(190 ,5,'RESPONSABLE DE LLENADO (KARDEX)',0,1,'C');
		$this->Cell(80 ,5,'DIRECTOR(A) ACADEMICO(A)',0,0,'C');
		$this->Cell(120 ,5,'RECTOR(A)',0,1,'C');
		$this->Cell(70 ,5,'La Paz, ',0,1,'');
		$this->SetFont('Arial','B',7);
		$this->Cell(70 ,5,'ADVERTENCIA: Este documento queda nulo si en el se hubiesen hecho raspaduras, anotaciones o enmiendas.',0,1,'');
		$this->Cell(70 ,5,'NOTA ACLARATORIA: Carga horaria conforme a Resolucion Administrativa Nro 11/2019 de 28 de Febrero de 2019 y Nro 12/2019 de 06 de Marzo de 2019.',0,1,'');
		$this->Cell(70 ,3,'**El presente documento se emite unicamente para el PROCESO ESPECIAL DE CONVALIDACION INTERNA DE ASIGNATURAS PARA REGULARIZACION DE TRAN-',0,1,'');
		$this->Cell(70 ,3,'CION DE MALLAS CURRICULARES DE ESTUDIANTES INSCRITOS EN EL PROGRAMA DE FORMACION SUPERIOR ARTISTICA y solo se toma en cuenta las asigna-',0,1,'');
		$this->Cell(70 ,3,'turas convalidables de acuerdo a Tabla de Equivalencias aprobada por la R.A. 09/2021 de Mayo de 2021.',0,1,'');
	}

	function addNumTVA($tva)
{
	$this->SetFont( "Arial", "B", 10);
	$r1  = $this->w - 80;
	$r2  = $r1 + 70;
	$y1  = 80;
	$y2  = $y1+10;
	$mid = $y1 + (($y2-$y1) / 2);
	$this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D');
	$this->Line( $r1, $mid, $r2, $mid);
	$this->SetXY( $r1 + 16 , $y1+1 );
	$this->Cell(40, 4, "TVA Intracommunautaire", '', '', "C");
	$this->SetFont( "Arial", "", 10);
	$this->SetXY( $r1 + 16 , $y1+5 );
	$this->Cell(40, 5, $tva, '', '', "C");
}
}

//$sell = AdmissionData::getById($_GET["id"]);
//$ops = UserAdmissionData::getAllByAdmissionId($_GET["id"]);
//$us = UserData::getById($sell->user_id);
$sdate = $sell->created_at;
$hora=date('h:m:s',strtotime($sdate));
$dia=date('d',strtotime($sdate));
$anio=date('Y',strtotime($sdate));	
$mes=date('m',strtotime($sdate));
$now = date_create($sell->created_at);
$birth = date_create($us->date_birth);
$edad = date_diff($birth,$now);
$total = 0;

if($mes == '01')
$letra = 'Enero';
if($mes == '02')
$letra = 'Febrero';
if($mes == '03')
$letra = 'Marzo';
if($mes == '04')
$letra = 'Abril';
if($mes == '05')
$letra = 'Mayo';
if($mes == '06')
$letra = 'Junio';
if($mes == '07')
$letra = 'Julio';
if($mes == '08')
$letra = 'Agosto';
if($mes == '09')
$letra = 'Septiembre';
if($mes == '10')
$letra = 'Octubre';
if($mes == '11')
$letra = 'Noviembre';
if($mes == '12')
$letra = 'Diciembre';


	$pdf  = new PDF('P', 'mm', 'letter');
	$pdf->AliasNbPages();
	$pdf->AddPage();

	$pdf->SetFont('Arial','',10);
	
	$pdf->Cell(31,5,'Calificacion obtenida durante el periodo lectivo de la  Gestion Academica de ',0,1,'');
	$pdf->Cell(189 ,5,'',0,1);//end of line

	//set font to arial, bold, 14pt
	$pdf->SetFont('Arial','B',9);

	$pdf->Cell(57 ,10,'ASIGNATURA ',1,0);
	$pdf->Cell(22 ,10,'REGIMEN',1,0);
	$pdf->Cell(36 ,10,'CALIFICACION',1,0);
	$pdf->Cell(15 ,10,'FOLIO ',1,0);
	$pdf->Cell(15 ,10,'LIBRO',1,0);
	$pdf->Cell(17 ,10,'CARGA HORARIA',1,0);
	$pdf->Cell(27 ,10,'RESULTADO',1,1);

	$pdf->Cell(27 ,10,'CODIGO',1,0);
	$pdf->Cell(30 ,10,'LITERAL',1,0);
	$pdf->Cell(22 ,10,'',1,0);
	$pdf->Cell(18 ,10,'NUMERAL',1,0);
	$pdf->Cell(18 ,10,'LITERAL',1,0);
	$pdf->Cell(15 ,10,'',1,0);
	$pdf->Cell(15 ,10,'',1,0);
	$pdf->Cell(17 ,10,'',1,0);
	$pdf->Cell(27 ,10,'',1,1);


	$pdf->Cell(189 ,5,'',0,1);//end of line

	$pdf->Cell(189 ,5,'',0,1);//end of line
	$pdf->SetFont('Arial','B',12);
	$pdf->Cell(25);
	$pdf->Cell(31,5,'DATOS ACADEMICOS',0,1,'C');
	$pdf->Cell(189 ,5,'',0,1);//end of line

	//set font to arial, bold, 14pt


	//foreach($ops as $op){
		if($op->division_id == 1){
			$pdf->SetFont('Arial','B',10);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MODALIDAD: ',1,0);
			$pdf->Cell(107 ,5,$op->getDivision()->name,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MATERIA: ',1,0);
			$pdf->Cell(107 ,5,utf8_encode($op->getCourse()->name),1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'FECHA Y HORARIO: ',1,0);
			$pdf->Cell(107 ,5,$op->getCourse()->hour,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MENCION: ',1,0);
			$pdf->Cell(107 ,5,utf8_encode($op->getCourseI()->name),1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'FECHA Y HORARIO: ',1,0);
			$pdf->Cell(107 ,5,$op->getCourseI()->hour,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'COSTO: Bs. ',1,0);
			$pdf->Cell(107 ,5,number_format($op->getDivision()->price,2,'.',','),1,1);
			//make a dummy empty cell as a vertical spacer
			$pdf->Cell(189 ,5,'',0,1);//end of line
	}if($op->division_id == 2){
		$pdf->SetFont('Arial','B',10);
		$pdf->Cell(25);
		$pdf->Cell(47 ,5,'MODALIDAD: ',1,0);
		$pdf->Cell(107 ,5,$op->getDivision()->name,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MATERIA: ',1,0);
			$pdf->Cell(107 ,5,'LENGUAJES MUSICALES',1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'FECHA Y HORARIO: ',1,0);
			$pdf->Cell(107 ,5,$op->getSufficiency()->date_at.' '.$op->getSufficiency()->time_at,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MENCION: ',1,0);
			$pdf->Cell(107 ,5,utf8_encode($op->getSufficiency()->name),1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'FECHA Y HORARIO: ',1,0);
			$pdf->Cell(107 ,5,$op->getSufficiency()->date_at.' '.$op->getSufficiency()->time_at,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'COSTO: Bs. ',1,0);
			$pdf->Cell(107 ,5,number_format($op->getDivision()->price,2,'.',','),1,1);
			//make a dummy empty cell as a vertical spacer
			$pdf->Cell(189 ,5,'',0,1);//end of line
	}if($op->division_id == 3){
		$pdf->SetFont('Arial','B',10);
		$pdf->Cell(25);
		$pdf->Cell(47 ,5,'MODALIDAD: ',1,0);
		$pdf->Cell(107 ,5,$op->getDivision()->name,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MATERIA: ',1,0);
			$pdf->Cell(107 ,5,'LENGUAJES MUSICALES',1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'HORARIO: ',1,0);
			$pdf->Cell(107 ,5,'2021-12-13 09:00-12:00',1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MENCION: ',1,0);
			$pdf->Cell(107 ,5,utf8_encode($op->getSufficiency()->name),1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'HORARIO: ',1,0);
			$pdf->Cell(107 ,5,$op->getSufficiency()->date_at.' '.$op->getSufficiency()->time_at,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'COSTO: Bs. ',1,0);
			$pdf->Cell(107 ,5,number_format($op->getDivision()->price,2,'.',','),1,1);
			//make a dummy empty cell as a vertical spacer
			$pdf->Cell(189 ,5,'',0,1);//end of line
	}if($op->division_id == 4){
		$pdf->SetFont('Arial','B',10);
		$pdf->Cell(25);
		$pdf->Cell(47 ,5,'MODALIDAD: ',1,0);
		$pdf->Cell(107 ,5,$op->getDivision()->name,1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MATERIA: ',1,0);
			$pdf->Cell(107 ,5,'LENGUAJES MUSICALES',1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'FECHA Y HORARIO: ',1,0);
			$pdf->Cell(107 ,5,'2021-12-13 09:00',1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'MENCION: ',1,0);
			$pdf->Cell(107 ,5,utf8_encode($op->getMention()->name),1,1);
			$pdf->Cell(25);
			$pdf->Cell(47 ,5,'FECHA Y HORARIO: ',1,0);
			$pdf->Cell(107 ,5,$op->getSufficiency()->date_at.' '.$op->getSufficiency()->time_at,1,1);
			if($sell->operation_type_id ==1){
				$pdf->Cell(25);
				$pdf->Cell(47 ,5,'COSTO: Bs. ',1,0);
				$pdf->Cell(107 ,5,number_format($op->getDivision()->price,2,'.',','),1,1);
			}else{
				$pdf->Cell(25);
				$pdf->Cell(47 ,5,'TIPO:',1,0);
				$pdf->Cell(107 ,5,'ESTUDIANTE REGULAR',1,1);
			}

			//make a dummy empty cell as a vertical spacer
			$pdf->Cell(189 ,5,'',0,1);//end of line

	}
	//}
	
	
$pdf->Output();