<?php

namespace CmBundle\Controller;

use FPDF;

date_default_timezone_set('America/Mexico_City');

class PDFBoleta extends FPDF
{
    public function generarBoleta($a, $datos, $promedio, $cuatri, $per)
    {
        //$this->Image('images/EncabezadoOk.png', 0, 0, 216);
        //$this->Image('images/mg1.png', 0, 0, 216);
        //$this->Image('images/pieOK.png', 0, 250, 216);
        $this->SetAutoPageBreak(true, 5);
        $this->SetFont('Arial', 'B', 13);
        $this->SetTextColor(255, 255, 255);
        $this->Cell(0, 5, utf8_decode("BOLETA DE CALIFICACIONES"), 0, 0, 'R', false);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->SetFont('Arial', 'B', 13);
        $this->SetTextColor(0, 0, 0);
        $nombreInstitucion = "UNIVERSIDAD TEC Mexiquense";
        $this->Cell(0, 6, utf8_decode($nombreInstitucion), 0, 0, 'C', false);
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("Coordinación de Servicios Escolares"), 0, 0, 'C', false);
        $this->Ln();
        $this->Ln();

        $this->SetDrawColor(51, 99, 117); // AZUL CEEPAM

        $this->SetFont('Arial', 'B', 10);
        $this->Cell(50, 8, utf8_decode("NOMBRE DEL ALUMNO (A):"), 0, 0, 'C', false);
        $this->SetFont('Arial', '', 10);
        $nombre = $a->getApePat() . " " . $a->getApeMat() . " " . $a->getNomAlu();
        $this->Cell(110, 8, utf8_decode($nombre), 1, 0, 'C', false);
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(0, 8, utf8_decode("INDICADOR:"), 0, 0, 'L', false);
        $this->Ln();
        $this->Ln(1);
        $this->Cell(50, 8, utf8_decode("GRADO ACADÉMICO:"), 0, 0, 'C', false);
        $this->SetFont('Arial', '', 10);
        $this->Cell(50, 8, utf8_decode($a->getCveLic()->getCveNivAca()->getNombre()), 1, 0, 'C', false);
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(40, 8, utf8_decode("CUATRIMESTRE:"), 0, 0, 'C', false);
        $this->SetFont('Arial', '', 10);
        $this->Cell(20, 8, utf8_decode($cuatri . "°"), 1, 0, 'C', false);
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(6, 8, utf8_decode("O ="), 0, 0, 'L', false);
        $this->SetFont('Arial', 'B', 8);
        $this->Cell(0, 8, utf8_decode("ORDINARIO"), 0, 0, 'L', false);
        $this->Ln();
        $this->Ln(1);
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(50, 8, utf8_decode("ESPECIALIDAD:"), 0, 0, 'C', false);
        $this->SetFont('Arial', '', 10);
        if (strlen($a->getCveLic()->getNomLic()) > 32) {
            $this->SetFont('Arial', '', 7);
            $this->Cell(65, 8, utf8_decode($a->getCveLic()->getNomLic()), 1, 0, 'C', false);
            $this->SetFont('Arial', '', 10);
        } else {
            $this->Cell(65, 8, utf8_decode($a->getCveLic()->getNomLic()), 1, 0, 'C', false);
        }

        $this->SetFont('Arial', 'B', 10);
        $this->Cell(25, 8, utf8_decode("PERIODO:"), 0, 0, 'C', false);
        $this->SetFont('Arial', '', 10);
        $this->Cell(20, 8, utf8_decode($per), 1, 0, 'C', false);
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(6, 8, utf8_decode("E ="), 0, 0, 'L', false);
        $this->SetFont('Arial', 'B', 8);
        $this->Cell(0, 8, utf8_decode("EXTRAORDINARIO"), 0, 0, 'L', false);
        $this->Ln();
        $this->Ln(1);
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(160, 8, utf8_decode(""), 0, 0, 'C', false);
        /*
        $this->Cell(50, 8, utf8_decode("PLANTEL:"), 0, 0, 'C', false);
        $this->SetFont('Arial', '', 10);
        $this->Cell(110, 8, utf8_decode($a->getCvePla()->getNomPla()), 1, 0, 'C', false);
        */
        $this->SetFont('Arial', 'B', 10);
        $this->Cell(6, 8, utf8_decode("T ="), 0, 0, 'L', false);
        $this->SetFont('Arial', 'B', 8);
        $this->Cell(0, 8, utf8_decode("TÍTULO DE SUFICIENCIA"), 0, 0, 'L', false);
        $this->SetFont('Arial', 'B', 10);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->SetTextColor(255, 255, 255);

        $this->SetFillColor(51, 99, 117); // AZUL CEEPAM


        $this->SetFont('Arial', 'B', 8);
        $this->Cell(10, 10, utf8_decode("N.M."), 1, 0, "C", TRUE);
        $this->Cell(30, 10, utf8_decode("CLAVE"), 1, 0, "C", TRUE);
        $this->Cell(100, 10, utf8_decode("UNIDAD DE APRENDIZAJE"), 1, 0, "C", TRUE);
        $this->Cell(30, 10, utf8_decode("CALIFICACIÓN"), 1, 0, "C", TRUE);
        $this->Cell(0, 10, utf8_decode("INDICADOR"), 1, 0, "C", TRUE);
        $this->Ln();
        // COLOR DE RELLENO CELDAS
        $this->SetFillColor(162, 204, 235); // AZUL CLARO

        $this->SetTextColor(0, 0, 0); // NEGRO
        $bandera = TRUE;
        foreach ($datos as $key => $v) {
            $this->Cell(10, 10, utf8_decode($key + 1), 1, 0, "C", $bandera);
            $this->Cell(30, 10, utf8_decode($v->getCveCur()->getClave()), 1, 0, "C", $bandera);
            $this->Cell(100, 10, utf8_decode($v->getCveCur()->getNomAsignatura()), 1, 0, "C", $bandera);
            $this->Cell(30, 10, utf8_decode(number_format(floatval($v->getCalFinal()), "1", ".", ",")), 1, 0, "C", $bandera);
            $this->SetFont('Arial', 'B', 10);
            $this->Cell(0, 10, utf8_decode($v->getIndicador()), 1, 0, "C", $bandera);
            $this->SetFont('Arial', 'B', 8);
            $this->Ln();
            $bandera = !$bandera;
        }
        $this->Ln(2);
        $this->SetTextColor(255, 255, 255);
        $this->SetFillColor(51, 99, 117); // AZUL CEEPAM
        $this->SetFont('Arial', 'B', 8);
        $this->Cell(110, 10, utf8_decode(""), 0, 0, "C", FALSE);
        $this->Cell(30, 10, utf8_decode("PROMEDIO"), 1, 0, "C", TRUE);

        // COLOR DE RELLENO CELDAS
        $this->SetFillColor(162, 204, 235); // AZUL CLARO

        $this->SetTextColor(0, 0, 0);

        //$this->Cell(30, 10, utf8_decode(number_format($promedio, "2", ".", ",")), 1, 0, "C", TRUE);
        $this->Cell(30, 10, utf8_decode(bcdiv($promedio, '1', 1)), 1, 0, "C", TRUE);
        $this->Ln();
        $this->SetY(200);
        $this->Cell(0, 15, "", 0, 0, 'C', false);
        $this->Ln();


        $this->Ln(1);
        $this->Cell(98, 5, utf8_decode("___________________________________________"), 0, 0, 'C', false);
        $this->Cell(0, 5, utf8_decode("___________________________________________"), 0, 0, 'C', false);
        $this->Ln(4);


        $this->Cell(98, 5, utf8_decode("COORDINACIÓN DE CONTROL ESCOLAR"), 0, 0, 'C', false);
        $this->Cell(0, 5, utf8_decode("COORDINACIÓN ACADÉMICA"), 0, 0, 'C', false);

        /*
        $this->Ln(3);
        $this->Cell(98, 5, utf8_decode("DE LA UNIVERSIDAD TEC Mexiquense"), 0, 0, 'C', false);
        $this->Cell(0, 5, utf8_decode("DE LA UNIVERSIDAD TEC Mexiquense"), 0, 0, 'C', false);
        $this->Ln();
        */
    }
}