<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace CmBundle\Controller;

use FPDF;

/**
 * Description of PDFFormatosCEEPAM
 *
 * @author SISTEMAS
 */
class PDFFormatosCEEPAM extends FPDF
{

    function Header()
    {
        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);
        $this->Image("images/fondos/mg.png", 0, 0, 216, 279);
        $this->Ln(20);
    }

    function Footer()
    {
        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);
        // Posición: a 1,5 cm del final
        $this->SetY(-15);
        // Arial italic 8
        $this->SetFont('Arial', 'I', 8);
        // Número de página
        $this->SetTextColor(0, 0, 0);
        $this->Cell(0, 10, utf8_decode('Página ' . $this->PageNo() . '/{nb}'), 0, 0, 'C');
    }

    //put your code here
    public function generarOficioCierreMatricula($datos, $columnas, $p, $alumnos, $preinscritos)
    {
        $meses = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');


        $this->SetFont("Helvetica", '', 12);

        $this->SetLeftMargin(25);
        $this->SetRightMargin(25);

        $this->Cell(0, 6, utf8_decode("Estado de México a " . date('d') . " de " . strtolower($meses[date('m') * 1 - 1]) . " de " . date('Y')), 0, 0, 'R', false);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode("ASUNTO: ACTIVOS Y PREINSCRITOS"), 0, 0, 'R', false);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->Cell(0, 6, utf8_decode($p->getNomPla()), 0, 0, 'L', false);
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("P R E S E N T E"), 0, 0, 'L', false);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->SetFont("Helvetica", '', 12);
        $texto = "Por este medio me permito enviarle un cordial saludo, al mismo tiempo y para que quede constancia por escrito,"
            . "hago la notificación de lo que se tiene en sistema respecto a sus activos y preinscritos.";
        $this->MultiCell(0, 6, utf8_decode($texto), 0, 'J', false);
        $this->Ln();
        $this->Ln();
        $texto = "Derivado de lo anterior solicito de su apreciable apoyo para la validación de los alumnos que a continuación se mencionan, "
            . "en caso de existir algún cambio favor de notificar lo antes posible, caso contrario se tomará la siguiente matricula como "
            . "definitiva y se solicitará el pago con respecto a esta.";
        $this->MultiCell(0, 6, utf8_decode($texto), 0, 'J', false);
        $this->Ln();
        $this->Ln();
        $texto = "Sin más por el momento quedo pendiente para cualquier duda y/o aclaración.";
        $this->MultiCell(0, 6, utf8_decode($texto), 0, 'J', false);
        $this->Ln();

        $this->SetY(200);
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode("ATENTAMENTE"), 0, 0, 'C', false);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("______________________________________"), 0, 0, 'C', false);
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("LIC. ALEJANDRA TRIGOS CORNEJO"), 0, 0, 'C', false);
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("DIRECTORA GENERAL"), 0, 0, 'C', false);


        $this->AddPage();
        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);

        $this->SetFont("Helvetica", 'B', 14);
        $this->Cell(0, 10, utf8_decode("CUADRO GENERAL: MATRÍCULA ACTIVA"), 0, 0, "C", false);
        $this->Ln(15);
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode($p->getNomPla()), 0, 0, 'L', false);
        $this->Ln();

        if ($datos == null) {
            $this->Ln();
            $this->Cell(0, 10, utf8_decode("EL PLANTEL NO TIENE MATRICULA ACTIVA"), 1, 0, "C", false);
            $this->Ln();
        } else {
            $this->SetFillColor(200, 200, 200); //GRIS
            $this->SetFont("Helvetica", 'B', 10);
            $this->Cell(110, 5, utf8_decode("ACOTACIONES:"), 1, 0, "C", true);
            $this->Ln();
            foreach ($datos[0] as $k => $v) {//ACOTACIONES
                $this->SetFont("Helvetica", '', 8);
                $this->Cell(15, 4, utf8_decode($k . " ===> "), "L", 0, "R", false);
                $this->Cell(95, 4, utf8_decode($v[0]), "R", 0, "L", false);
                $this->Ln();
            }
            $this->Cell(110, 4, utf8_decode(""), "T", 0, "C", false);
            $this->Ln();
            /*
             * EMPIEZA EL CUADRO
             */
            $this->SetDrawColor(200, 200, 200);
            $this->SetFont("Arial", "B", 10);
            $this->SetFillColor(237, 125, 49); //NARANJA
            $this->SetTextColor(255, 255, 255);
            $ancho = 7;
            $this->Cell(15, $ancho, utf8_decode("CUA"), 1, 0, "C", true);
            foreach ($datos[0] as $k => $v) {

                $this->SetFillColor(0, 32, 96); //AZUL
                $this->Cell(10, $ancho, utf8_decode($k), 1, 0, "C", true);
            }

            $this->SetFillColor(146, 208, 80); //VERDE
            $this->Cell(15, $ancho, utf8_decode("TOTAL"), 1, 0, "C", true);
            $this->Ln();

            $this->SetTextColor(0, 0, 0);
            foreach ($datos as $kk => $vv) {
                if ($kk > 0) {
                    $sumaFila = 0;
                    $this->SetFont("Arial", "B", 10);
                    $this->SetFillColor(0, 32, 96);
                    $this->SetTextColor(255, 255, 255);
                    $this->Cell(15, $ancho, utf8_decode($kk . "°"), 1, 0, "C", true);
                    $this->SetTextColor(0, 0, 0);
                    $this->SetFont("Arial", "B", 10);
                    foreach ($vv as $k => $v) {
                        if ($v[0] > 0) {
                            $this->Cell(10, $ancho, utf8_decode($v[0]), 1, 0, "C", false);
                        } else {
                            $this->Cell(10, $ancho, utf8_decode(""), 1, 0, "C", false);
                        }
                        $sumaFila += $v[0];
                    }

                    $this->SetFillColor(237, 125, 49); //NARANJA
                    if ($sumaFila == 0) {
                        $this->Cell(15, $ancho, utf8_decode(""), 1, 0, "C", true);
                    } else {
                        $this->Cell(15, $ancho, utf8_decode($sumaFila), 1, 0, "C", true);
                    }

                    $this->Ln();
                }
            }
            $this->SetFillColor(0, 32, 96); //AZUL
            $this->SetTextColor(255, 255, 255);
            $this->SetFont("Arial", "B", 10);
            $this->Cell(15, $ancho, utf8_decode("TOTAL"), 1, 0, "C", true);
            $this->SetFillColor(237, 125, 49); //NARANJA
            $sumaColumnas = 0;
            $this->SetFont("Arial", "B", 11);
            foreach ($columnas as $k => $v) {//SUMA FILAS
                $this->Cell(10, $ancho, utf8_decode($v), 1, 0, "C", true);
                $sumaColumnas += $v;
            }
            $this->SetFillColor(0, 32, 96); //AZUL
            $this->Cell(15, $ancho, utf8_decode(""), 1, 0, "C", true);
            $this->Ln();

            $this->SetFillColor(146, 208, 80); //VERDE
            $this->SetTextColor(255, 255, 255);
            $this->SetFont("Arial", "B", 11);
            $this->Cell(15, 8, utf8_decode("TOTAL"), 1, 0, "C", true);
            $this->SetFont("Arial", "B", 14);
            $this->Cell((10 * count($columnas) + 15), 8, utf8_decode($sumaColumnas), 1, 0, 'C', true);
            /*
             * TERMINA EL CUADRO
             */
        }


        $this->AddPage(); //TERCER HOJA / ACTIVOS
        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);

        $this->SetFont("Helvetica", 'B', 14);
        $this->SetTextColor(0, 0, 0);
        $this->Cell(0, 10, utf8_decode("LISTA GENERAL: MATRÍCULA ACTIVA"), 0, 0, "C", false);
        $this->Ln();
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode($p->getNomPla()), 0, 0, 'L', false);
        $this->Ln();
        $this->SetFillColor(200, 200, 200); //GRIS
        $this->SetFont("Helvetica", 'B', 10);
        $especialidad = "";
        $cuatri = "";
        $indice = 1;

        if ($alumnos == null) {
            $this->Ln();
            $this->Cell(0, 10, utf8_decode("EL PLANTEL NO TIENE MATRICULA ACTIVA"), 1, 0, "C", false);
            $this->Ln();
        } else {
            foreach ($alumnos as $k => $a) {
                if ($especialidad == ($a->getCveLic()->getCveNivAca()->getNombre() . " EN " . $a->getCveLic()->getNomLic())) {
                    if ($cuatri == $a->getNumero()) {

                    } else {
                        $this->SetFillColor(200, 200, 200); //GRIS
                        $this->Cell(0, 1, utf8_decode(""), 1, 0, "C", true);
                        $this->Ln();
                        $this->Cell(0, 2, utf8_decode(""), 0, 0, "C", false);

                        $cuatri = $a->getNumero();
                        $indice = 1;
                        $this->Ln();
                        $this->SetFillColor(200, 200, 200); //GRIS
                        $this->SetFont("Helvetica", 'B', 10);
                        $this->Cell(150, 5, utf8_decode($especialidad), 1, 0, "C", true);
                        $this->Cell(0, 5, utf8_decode($cuatri . "°"), 1, 0, "C", true);
                        $this->Ln();
                        $this->Cell(10, 5, utf8_decode("N.C."), 1, 0, "R", true);
                        $this->Cell(20, 5, utf8_decode("MATRÍCULA"), 1, 0, "C", true);
                        $this->Cell(110, 5, utf8_decode("NOMBRE DEL ALUMNO"), 1, 0, "C", true);
                        $this->Cell(0, 5, utf8_decode("OBSERVACIONES"), 1, 0, "C", true);
                        $this->Ln();
                    }
                } else {
                    if ($k > 0) {
                        $this->SetFillColor(200, 200, 200); //GRIS
                        $this->Cell(0, 1, utf8_decode(""), 1, 0, "C", true);
                        $this->Ln();
                        $this->Cell(0, 2, utf8_decode(""), 0, 0, "C", false);
                    }
                    $this->SetFont("Helvetica", 'B', 10);
                    $especialidad = $a->getCveLic()->getCveNivAca()->getNombre() . " EN " . $a->getCveLic()->getNomLic();
                    $cuatri = $a->getNumero();
                    $indice = 1;

                    $this->Ln();
                    $this->SetFillColor(200, 200, 200); //GRIS
                    $this->Cell(150, 5, utf8_decode($especialidad), 1, 0, "C", true);
                    $this->Cell(0, 5, utf8_decode($cuatri . "°"), 1, 0, "C", true);
                    $this->Ln();
                    $this->Cell(10, 5, utf8_decode("N.C."), 1, 0, "R", true);
                    $this->Cell(20, 5, utf8_decode("MATRÍCULA"), 1, 0, "C", true);
                    $this->Cell(110, 5, utf8_decode("NOMBRE DEL ALUMNO"), 1, 0, "C", true);
                    $this->Cell(0, 5, utf8_decode("OBSERVACIONES"), 1, 0, "C", true);
                    $this->Ln();
                }
                $this->SetFont("Helvetica", '', 10);
                $this->SetFillColor(255, 255, 255); //BLANCO
                $this->Cell(10, 5, utf8_decode($indice), 1, 0, "R", true);
                $this->Cell(20, 5, utf8_decode($a->getCveCtl()), 1, 0, "C", true);
                $nombreAlumno = $a->getApePat() . " " . $a->getApemat() . " " . $a->getNomAlu();
                $this->Cell(110, 5, utf8_decode($nombreAlumno), 1, 0, "L", true);
                $this->Cell(0, 5, utf8_decode(""), 1, 0, "L", true);
                $indice++;
                $this->Ln();
            }

            $this->SetFillColor(200, 200, 200); //GRIS
            $this->Cell(0, 1, utf8_decode(""), 1, 0, "C", true);
            $this->Ln();
            $this->Cell(0, 2, utf8_decode(""), 0, 0, "C", false);

        }


        $this->AddPage(); //PREINSCRITOS
        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);

        $this->SetFont("Helvetica", 'B', 14);
        $this->SetTextColor(0, 0, 0);
        $this->Cell(0, 10, utf8_decode("LISTA GENERAL: PREINSCRITOS"), 0, 0, "C", false);
        $this->Ln();
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode($p->getNomPla()), 0, 0, 'L', false);
        $this->Ln();
        $this->SetFillColor(200, 200, 200); //GRIS
        $this->SetFont("Helvetica", 'B', 10);
        $especialidad = "";
        $cuatri = "";
        $indice = 1;

        if (count($preinscritos) == 0) {
            $this->Ln();
            $this->Cell(0, 10, utf8_decode("EL PLANTEL NO TIENE PREINSCRITOS"), 1, 0, "C", false);
            $this->Ln();
        } else {
            foreach ($preinscritos as $k => $a) {
                if ($especialidad == ($a->getCveLic()->getCveNivAca()->getNombre() . " EN " . $a->getCveLic()->getNomLic())) {
                    if ($cuatri == $a->getNumero()) {

                    } else {
                        $this->SetFillColor(200, 200, 200); //GRIS
                        $this->Cell(0, 1, utf8_decode(""), 1, 0, "C", true);
                        $this->Ln();
                        $this->Cell(0, 2, utf8_decode(""), 0, 0, "C", false);
                        $cuatri = $a->getNumero();
                        $indice = 1;
                        $this->Ln();
                    }
                } else {
                    $this->SetFont("Helvetica", 'B', 10);
                    $especialidad = $a->getCveLic()->getCveNivAca()->getNombre() . " EN " . $a->getCveLic()->getNomLic();
                    $cuatri = $a->getNumero();
                    $indice = 1;

                    $this->Ln();
                    $this->SetFillColor(200, 200, 200); //GRIS
                    $this->Cell(0, 5, utf8_decode($especialidad), 1, 0, "C", true);
                    $this->Ln();
                    $this->Ln();

                    $this->Cell(10, 5, utf8_decode("N.C."), 1, 0, "R", true);
                    $this->Cell(25, 5, utf8_decode("ESTATUS"), 1, 0, "R", true);
                    $this->Cell(15, 5, utf8_decode("CUA."), 1, 0, "C", true);
                    $this->Cell(110, 5, utf8_decode("NOMBRE DEL ALUMNO"), 1, 0, "C", true);
                    $this->Cell(0, 5, utf8_decode("OBSERVACIONES"), 1, 0, "C", true);
                    $this->Ln();
                }
                $this->SetFont("Helvetica", '', 10);
                $this->SetFillColor(255, 255, 255); //BLANCO
                $this->Cell(10, 5, utf8_decode($indice), 1, 0, "R", true);
                $this->SetFont("Helvetica", '', 8);
                $this->Cell(25, 5, utf8_decode($a->getEstatus()->getDesEst()), 1, 0, "C", true);
                $this->SetFont("Helvetica", '', 10);
                $this->Cell(15, 5, utf8_decode($a->getNumero() . "°"), 1, 0, "C", true);
                $nombreAlumno = $a->getApePat() . " " . $a->getApemat() . " " . $a->getNomAlu();
                $this->Cell(110, 5, utf8_decode($nombreAlumno), 1, 0, "L", true);
                $this->Cell(0, 5, utf8_decode(""), 1, 0, "L", true);
                $indice++;
                $this->Ln();
            }
        }
    }

    public function oficioAlumnosGeneralPlantel($alumnos, $plantel, $directas)
    {
        $meses = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');

        $this->SetFont("Helvetica", '', 12);

        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);

        $this->SetFont("Helvetica", 'B', 14);
        $this->SetTextColor(0, 0, 0);
        $this->Cell(0, 10, utf8_decode("LISTA GENERAL"), 0, 0, "C", false);
        $this->Ln();
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode($plantel->getNomPla()), 0, 0, 'L', false);
        $this->Ln();
        $this->SetFillColor(200, 200, 200); //GRIS
        $this->SetFont("Helvetica", 'B', 10);
        $especialidad = "";
        $cuatri = "";
        $indice = 1;

        if ($alumnos == null) {
            $this->Ln();
            $this->Cell(0, 10, utf8_decode("EL PLANTEL NO TIENE MATRICULA"), 1, 0, "C", false);
            $this->Ln();
        } else {
            foreach ($alumnos as $k => $a) {
                if ($especialidad == ($a->getCveLic()->getCveNivAca()->getNombre() . " EN " . $a->getCveLic()->getNomLic())) {
                    if ($cuatri == $a->getNumero()) {

                    } else {
                        $this->SetFillColor(200, 200, 200); //GRIS
                        $this->Cell(0, 1, utf8_decode(""), 1, 0, "C", true);
                        $this->Ln();
                        $this->Cell(0, 2, utf8_decode(""), 0, 0, "C", false);
                        $cuatri = $a->getNumero();
                        $indice = 1;
                        $this->Ln();
                    }
                } else {

                    if ($k > 1) {
                        $this->SetFillColor(200, 200, 200); //GRIS
                        $this->Cell(0, 1, utf8_decode(""), 1, 0, "C", true);
                        $this->Ln();
                        $this->Cell(0, 2, utf8_decode(""), 0, 0, "C", false);
                        $cuatri = $a->getNumero();
                        $indice = 1;
                        $this->Ln();
                    }

                    $this->SetFont("Helvetica", 'B', 10);
                    $especialidad = $a->getCveLic()->getCveNivAca()->getNombre() . " EN " . $a->getCveLic()->getNomLic();
                    $cuatri = $a->getNumero();
                    $indice = 1;

                    $this->Ln();
                    $this->SetFillColor(30, 94, 111); //AZUL CEEPAM
                    $this->SetTextColor(255, 255, 255);; // TEXTO BLANCO
                    $this->Cell(0, 5, utf8_decode($especialidad), 1, 0, "C", true);
                    $this->SetFillColor(200, 200, 200); //GRIS
                    $this->SetTextColor(0, 0, 0);; // TEXTO NEGRO
                    $this->Ln(7);

                    $this->Cell(10, 5, utf8_decode("N.C."), 1, 0, "R", true);
                    $this->Cell(15, 5, utf8_decode("CUA."), 1, 0, "C", true);
                    $this->Cell(100, 5, utf8_decode("NOMBRE DEL ALUMNO"), 1, 0, "C", true);
                    $this->Cell(35, 5, utf8_decode("ESTATUS"), 1, 0, "C", true);
                    $this->Cell(0, 5, utf8_decode("OBSERVACIONES"), 1, 0, "C", true);
                    $this->Ln();
                }
                $this->SetFont("Helvetica", '', 10);
                $this->SetFillColor(255, 255, 255); //BLANCO
                $this->Cell(10, 5, utf8_decode($indice), 1, 0, "R", true);
                $this->Cell(15, 5, utf8_decode($a->getNumero() . "°"), 1, 0, "C", true);
                $nombreAlumno = $a->getApePat() . " " . $a->getApemat() . " " . $a->getNomAlu();
                $this->Cell(100, 5, utf8_decode($nombreAlumno), 1, 0, "L", true);
                $this->SetFont("Helvetica", '', 8);
                $this->Cell(35, 5, utf8_decode($a->getEstatus()->getDesEst()), 1, 0, "C", true);
                $this->SetFont("Helvetica", '', 10);
                $this->Cell(0, 5, utf8_decode(""), 1, 0, "L", true);
                $indice++;
                $this->Ln();
            }
            $this->SetFillColor(200, 200, 200); //GRIS
            $this->Cell(0, 1, utf8_decode(""), 1, 0, "C", true);
            $this->Ln();
            $this->Cell(0, 2, utf8_decode(""), 0, 0, "C", false);
            $cuatri = $a->getNumero();
            $indice = 1;
            $this->Ln();

        }

        $this->AddPage();

        $this->SetFont("Helvetica", '', 12);

        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);

        $this->SetFont("Helvetica", 'B', 14);
        $this->SetTextColor(0, 0, 0);
        $this->Cell(0, 10, utf8_decode("LISTA DIRECTAS"), 0, 0, "C", false);
        $this->Ln();
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode($plantel->getNomPla()), 0, 0, 'L', false);
        $this->Ln();
        $this->SetFillColor(200, 200, 200); //GRIS
        $this->SetFont("Helvetica", 'B', 10);

        if ($directas == null) {
            $this->Ln();
            $this->Cell(0, 10, utf8_decode("EL PLANTEL NO TIENE DIRECTAS"), 1, 0, "C", false);
            $this->Ln();
        } else {
            $this->SetFont("Helvetica", 'B', 10);
            $this->Ln(7);
            $this->SetFillColor(30, 94, 111); //AZUL CEEPAM
            $this->SetTextColor(255, 255, 255);; // TEXTO BLANCO
            $this->Cell(10, 5, utf8_decode("N.C."), 1, 0, "R", true);
            //$this->Cell(15, 5, utf8_decode("CUA."), 1, 0, "C", true);
            $this->Cell(80, 5, utf8_decode("NOMBRE DEL ALUMNO"), 1, 0, "C", true);
            $this->Cell(22, 5, utf8_decode("ESTATUS"), 1, 0, "C", true);
            $this->Cell(0, 5, utf8_decode("ESPECIALIDAD"), 1, 0, "C", true);
            $this->SetFillColor(200, 200, 200); //GRIS
            $this->SetTextColor(0, 0, 0);; // TEXTO NEGRO

            $this->Ln();
            foreach ($directas as $k => $d) {
                $this->SetFont("Helvetica", '', 10);
                $this->SetFillColor(255, 255, 255); //BLANCO
                $this->Cell(10, 5, utf8_decode($k + 1), 1, 0, "R", true);
                //$this->Cell(15, 5, utf8_decode($d->getCveAlu()->getNumero() . "°"), 1, 0, "C", true);
                $nombreAlumno = $d->getCveAlu()->getApePat() . " " . $d->getCveAlu()->getApemat() . " " . $d->getCveAlu()->getNomAlu();
                $this->Cell(80, 5, utf8_decode($nombreAlumno), 1, 0, "L", true);
                $this->SetFont("Helvetica", '', 8);
                if ($d->getCveAlu()->getTipoAlumno() == 8) {
                    $this->Cell(22, 5, utf8_decode("DIRECTA"), 1, 0, "C", true);
                } else {
                    $this->Cell(22, 5, utf8_decode($d->getCveAlu()->getEstatus()->getDesEst()), 1, 0, "C", true);
                }
                $this->SetFont("Helvetica", '', 8);
                $especialidad = $d->getCveLic()->getCveNivAca()->getNombre() . " EN " . $d->getCveLic()->getNomLic();
                $this->Cell(0, 5, utf8_decode($especialidad), 1, 0, "L", true);
                $indice++;
                $this->Ln();
            }
            $this->SetFillColor(200, 200, 200); //GRIS
            $this->Cell(0, 1, utf8_decode(""), 1, 0, "C", true);
            $this->Ln();

        }

    }


    public function mapaCurricular($plan, $asignaturas)
    {

        $this->SetFillColor(50, 79, 33);
        $this->SetTextColor(255, 255, 255);
        $this->SetFont('Arial', '', 12);
        $this->Cell(50, 6, utf8_decode("NOMBRE DEL PLAN:"), 1, 0, 'C', true);
        $this->SetFont('Arial', '', 10);
        $this->SetTextColor(0, 0, 0);
        $this->Cell(0, 6, utf8_decode($plan->getNomPlan()), 1, 0, 'C', false);
        $this->Ln();
        $this->SetFont('Arial', '', 12);
        $this->SetTextColor(255, 255, 255);
        $this->Cell(35, 6, utf8_decode("ESPECIALIDAD:"), 1, 0, 'C', true);
        $this->SetFont('Arial', '', 10);
        $this->SetTextColor(0, 0, 0);
        $this->Cell(0, 6, utf8_decode($plan->getCveLic()->getCveNivAca()->getNombre() . " EN " . $plan->getCveLic()->getNomLic()), 1, 0, 'C', false);
        $this->Ln();
        $this->SetFont('Arial', '', 12);
        $this->SetTextColor(255, 255, 255);
        $this->Cell(20, 6, utf8_decode("RVOE: "), 1, 0, 'C', true);
        $this->SetFont('Arial', '', 10);
        $this->SetTextColor(0, 0, 0);
        $this->Cell(0, 6, utf8_decode($plan->getCvePlan()), 1, 0, 'C', false);
        $this->Ln();
        $this->Ln();

        $this->SetFont('Arial', 'B', 10);
        $this->SetTextColor(255, 255, 255);
        $this->Cell(10, 5, utf8_decode("N.C."), 1, 0, 'C', true);
        $this->Cell(10, 5, utf8_decode("#"), 1, 0, 'C', true);
        $this->Cell(20, 5, utf8_decode("PERIODO"), 1, 0, 'C', true);
        $this->Cell(20, 5, utf8_decode("CLAVE"), 1, 0, 'C', true);
        $this->Cell(0, 5, utf8_decode("ASIGNATURA"), 1, 0, 'C', true);

        $this->Ln();
        $this->SetFont('Arial', '', 10);
        $this->SetTextColor(0, 0, 0);
        $auxCua = 1;
        $indice = 0;
        foreach ($asignaturas as $k => $v) {
            if ($v->getNumCua() == 0) {
                // ES SEMESTRAL
                if ($auxCua != $v->getNumSem()) {
                    $auxCua = $v->getNumSem();
                    $indice = 0;
                    $this->Ln();
                    $this->SetFont('Arial', 'B', 10);
                    $this->SetTextColor(255, 255, 255);
                    $this->Cell(10, 5, utf8_decode("N.C."), 1, 0, 'C', true);
                    $this->Cell(10, 5, utf8_decode("#"), 1, 0, 'C', true);
                    $this->Cell(20, 5, utf8_decode("PERIODO"), 1, 0, 'C', true);
                    $this->Cell(20, 5, utf8_decode("CLAVE"), 1, 0, 'C', true);
                    $this->Cell(0, 5, utf8_decode("ASIGNATURA"), 1, 0, 'C', true);

                    $this->Ln();
                    $this->SetFont('Arial', '', 10);
                    $this->SetTextColor(0, 0, 0);
                }
                $this->Cell(10, 5, utf8_decode($k + 1), 1, 0, 'C', false);
                $this->Cell(10, 5, utf8_decode($indice + 1), 1, 0, 'C', false);
                $this->Cell(20, 5, utf8_decode($v->getNumSem()), 1, 0, 'C', false);
                $this->Cell(20, 5, utf8_decode($v->getClave()), 1, 0, 'C', false);
            } else {

                if ($auxCua != $v->getNumCua()) {
                    $auxCua = $v->getNumCua();
                    $indice = 0;
                    $this->Ln();
                    $this->SetFont('Arial', 'B', 10);
                    $this->SetTextColor(255, 255, 255);
                    $this->Cell(10, 5, utf8_decode("N.C."), 1, 0, 'C', true);
                    $this->Cell(10, 5, utf8_decode("#"), 1, 0, 'C', true);
                    $this->Cell(20, 5, utf8_decode("PERIODO"), 1, 0, 'C', true);
                    $this->Cell(20, 5, utf8_decode("CLAVE"), 1, 0, 'C', true);
                    $this->Cell(0, 5, utf8_decode("ASIGNATURA"), 1, 0, 'C', true);

                    $this->Ln();
                    $this->SetFont('Arial', '', 10);
                    $this->SetTextColor(0, 0, 0);
                }
                $this->Cell(10, 5, utf8_decode($k + 1), 1, 0, 'C', false);
                $this->Cell(10, 5, utf8_decode($indice + 1), 1, 0, 'C', false);
                $this->Cell(20, 5, utf8_decode($v->getNumCua()), 1, 0, 'C', false);
                $this->Cell(20, 5, utf8_decode($v->getClave()), 1, 0, 'C', false);
            }


            if (strlen($v->getNomAsignatura()) > 65) {
                $this->SetFont('Arial', '', 8);
                $this->Cell(0, 5, utf8_decode($v->getNomAsignatura()), 1, 0, 'C', false);
                $this->SetFont('Arial', '', 10);
            } else {
                $this->Cell(0, 5, utf8_decode($v->getNomAsignatura()), 1, 0, 'C', false);
            }

            $this->Ln();
            $indice++;
        }
    }


    public function generarOficioCertificacionDirecta($datos)
    {


        $meses = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');


        $this->SetFont("Helvetica", '', 12);

        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);

        $this->Cell(0, 6, utf8_decode("Estado de México a " . date('d') . " de " . strtolower($meses[date('m') * 1 - 1]) . " de " . date('Y')), 0, 0, 'R', false);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode("ASUNTO: SOLICITUD DE CERTIFICACIÓN"), 0, 0, 'R', false);
        $this->Ln();
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("A QUIEN CORRESPONDA"), 0, 0, 'L', false);
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("P R E S E N T E"), 0, 0, 'L', false);
        $this->Ln();
        $this->Ln();
        $this->SetFont("Helvetica", '', 12);
        $texto = "Por este medio me permito enviarle un cordial saludo, al mismo tiempo solicitar el ingreso a CERTIFICACIÓN de los "
            . "siguientes trámites:";
        $this->MultiCell(0, 6, utf8_decode($texto), 0, 'J', false);
        $this->Ln();
        $this->SetFont("Helvetica", 'B', 8);
        $this->SetFillColor(30, 94, 111);
        $this->SetTextColor(255, 255, 255);
        $this->Cell(8, 6, utf8_decode("N.C."), 1, 0, 'C', true);
        $this->Cell(20, 6, utf8_decode("MATRÍCULA"), 1, 0, 'C', true);
        $this->Cell(50, 6, utf8_decode("NOMBRE"), 1, 0, 'C', true);
        $this->Cell(16, 6, utf8_decode("TRAMITE"), 1, 0, 'C', true);
        $this->Cell(50, 6, utf8_decode("ESPECIALIDAD"), 1, 0, 'C', true);
        $this->Cell(20, 6, utf8_decode("TOTAL"), 1, 0, 'C', true);
        $this->Cell(20, 6, utf8_decode("ABONADO"), 1, 0, 'C', true);
        $this->Cell(20, 6, utf8_decode("DEBE"), 1, 0, 'C', true);
        $this->Ln();
        $this->SetFont("Helvetica", '', 8);
        $this->SetTextColor(0, 0, 0);
        foreach ($datos as $key => $d) {
            $this->Cell(8, 6, utf8_decode($key + 1), 1, 0, 'L', false);
            $this->Cell(20, 6, utf8_decode($d[0]->getCveCtl()), 1, 0, 'L', false);
            $nombre = $d[0]->getApePat() . " " . $d[0]->getApeMat() . " " . $d[0]->getNomAlu();
            $this->Cell(50, 6, utf8_decode($nombre), 1, 0, 'L', false);
            $especialidad = "X X X X X";
            if ($d[1] != null) {
                $especialidad = $d[1]->getCveLic()->getCveNivAca()->getNombre() . " EN " . $d[1]->getCveLic()->getNomLic();
            }

            if ($d[0]->getTipoAlumno() == 8) {
                $this->Cell(16, 6, utf8_decode("DIRECTA"), 1, 0, 'L', false);
            } else {
                $this->Cell(16, 6, utf8_decode("OTRO"), 1, 0, 'L', false);
            }
            $this->Cell(50, 6, utf8_decode($especialidad), 1, 0, 'L', false);
            $this->Cell(20, 6, utf8_decode($especialidad), 1, 0, 'L', false);
            $this->Cell(20, 6, utf8_decode($especialidad), 1, 0, 'L', false);
            $this->Cell(20, 6, utf8_decode($especialidad), 1, 0, 'L', false);
            $this->Ln();
        }

        $this->SetY(200);
        $this->SetFont("Helvetica", 'B', 12);
        $this->Cell(0, 6, utf8_decode("ATENTAMENTE"), 0, 0, 'C', false);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("______________________________________"), 0, 0, 'C', false);
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("LIC. ALEJANDRA TRIGOS CORNEJO"), 0, 0, 'C', false);
        $this->Ln();
        $this->Cell(0, 6, utf8_decode("DIRECTORA GENERAL"), 0, 0, 'C', false);
    }

}
