<?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;
use CmBundle\Controller\NumberToLetterConverter;
use PHPQRCode\QRcode;

date_default_timezone_set('America/Mexico_City');

/**
 * Description of PdfReciboCeepam
 *
 * @author OMAR
 */
class PdfReciboCeepam extends FPDF {

    //put your code here

    function ReciboMatriculacion($ingMat, $pagMat, $alumnos) {
        /*
         * TAMAÑO CARTA: 216mm X 280mm
         */

        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);
        $this->SetFillColor(255, 255, 255);
        $this->SetDrawColor(24, 50, 89);
        $this->Image("images/fondos/mg.png", 0, 0, 216);

        $this->Ln(15);

        $this->SetFont('Arial', 'B', '14');
        $this->Cell(0, 10, utf8_decode("RECIBO DE MATRICULACIÓN"), 0, 0, 'C', FALSE);
        $this->Ln(15);
        $this->SetFont('Arial', 'B', '12');
        $this->Cell(40, 8, utf8_decode("FOLIO:"), 0, 0, 'R', FALSE);
        $this->Cell(58, 8, utf8_decode($ingMat->getNumRecibo()), 1, 0, 'C', TRUE);
        $this->Cell(40, 8, utf8_decode("FECHA:"), 0, 0, 'R', FALSE);
        $this->SetFont('Arial', '', '12');
        $this->Cell(0, 8, utf8_decode($ingMat->getFecMov()->format('d-m-Y')), "B", 0, 'C', FALSE);
        $this->Ln(10);
        $this->SetFont('Arial', 'B', '12');
        $this->Cell(40, 8, utf8_decode("ESCUELA:"), 0, 0, 'R', FALSE);
        $this->SetFont('Arial', '', '12');
        $this->Cell(0, 8, utf8_decode($ingMat->getCvePla()->getNomPla()), "B", 0, 'C', FALSE);
        $this->Ln(10);
        $this->SetFont('Arial', 'B', '12');
        $this->Cell(40, 8, utf8_decode("MES:"), 0, 0, 'R', FALSE);
        $this->SetFont('Arial', '', '12');
        $this->Cell(58, 8, utf8_decode($ingMat->getCvePagMat()->getMesMatriculacion() . "-" . $ingMat->getCvePagMat()->getAnioMatriculacion()), "B", 0, 'C', FALSE);
        $this->SetFont('Arial', 'B', '12');
        $this->Cell(40, 8, utf8_decode("MONTO:"), 0, 0, 'R', FALSE);
        $this->SetFont('Arial', '', '12');
        $this->Cell(0, 8, utf8_decode("$" . number_format($ingMat->getTotal(), "2", ".", ",")), "B", 0, 'L', FALSE);

        $this->Ln(10);
        $convertidor = new NumberToLetterConverter();
        $cantidadLetra = $convertidor->to_word($ingMat->getTotal());


        $this->SetFont('Arial', 'B', '12');
        $this->Cell(40, 8, utf8_decode("LETRA:"), 0, 0, 'R', FALSE);
        $this->SetFont('Arial', '', '12');
        $this->Cell(0, 8, utf8_decode($cantidadLetra . "PESOS 00/100 MN"), "B", 0, 'C', FALSE);
        $this->Ln(10);
        $this->SetFont('Arial', 'B', '12');
        $this->Cell(40, 8, utf8_decode("TOTAL A PAGAR:"), 0, 0, 'R', FALSE);
        $this->SetFont('Arial', '', '12');
        $this->Cell(58, 8, utf8_decode("$" . number_format($pagMat->getMonto(), 2, ".", ",")), "B", 0, 'C', FALSE);
        $this->SetFont('Arial', 'B', '12');
        $this->Cell(40, 8, utf8_decode("ABONADO:"), 0, 0, 'R', FALSE);
        $this->SetFont('Arial', '', '12');
        $this->Cell(0, 8, utf8_decode("$" . number_format($pagMat->getAbonado(), 2, ".", ",")), "B", 0, 'C', FALSE);
        $this->Ln();
        $this->Ln();
        $this->Ln();
        $this->SetFont('Arial', '', '12');
        $this->Cell(98, 8, utf8_decode("ENTREGA"), 0, 0, 'C', FALSE);
        $this->Cell(0, 8, utf8_decode("RECIBE"), 0, 0, 'C', FALSE);
        $this->Ln();
        $this->Ln();

        $this->Cell(98, 5, utf8_decode("__________________________________"), 0, 0, 'C', FALSE);
        $this->Cell(0, 5, utf8_decode("__________________________________"), 0, 0, 'C', FALSE);
        $this->Ln();
        $this->Cell(98, 8, utf8_decode($ingMat->getCvePla()->getNomPla()), 0, 0, 'C', FALSE);
        $this->Cell(0, 8, utf8_decode("COORDINACIÓN ADMINISTRATIVA"), 0, 0, 'C', FALSE);


        $this->AddPage();

        $this->SetLeftMargin(10);
        $this->SetRightMargin(10);
        $this->SetFillColor(255, 255, 255);
        $this->SetDrawColor(24, 50, 89);
        $this->Image("images/fondos/mg.png", 0, 0, 216);

        $this->Ln(15);

        $this->SetFont('Arial', 'B', '14');
        $this->Cell(0, 10, utf8_decode("LISTA GENERAL DE ALUMNOS"), 0, 0, 'C', FALSE);
        $this->Ln(15);
        $this->SetFont('Arial', 'B', '12');

        $this->SetFont('Arial', '', '10');
        foreach ($alumnos as $k => $v) {
            $this->Cell(15, 5, utf8_decode($k+1), 1, 0, 'R', false);
            $this->Cell(0, 5, utf8_decode($v->getCveAlu()->getApePat() . " " . $v->getCveAlu()->getApeMat() . " " . $v->getCveAlu()->getNomAlu()), 1, 0, 'L', false);
            $this->Ln();
        }
    }

}
