<link href="../css/formato_boletin.css" rel="stylesheet" type="text/css">
<?php
//FORMATO DEL BOLETIN PRESCOLAR PARA JORGE ELIECER GAITAN  - ORITO
$academia->instruccion("SELECT ide_adtivo, LCASE(CONCAT_WS(' ', no1_adtivo, no2_adtivo,ape1_adtivo, ape2_adtivo)) nom_ape FROM adm_administrativos WHERE cod_cargo=1 or cod_cargo=2 order by cod_cargo");
$regFirmantes = $academia->fetchAll();
$nom_rector = $regFirmantes[0]['nom_ape'];
$nom_cordin = $regFirmantes[1]['nom_ape'];

$sql = "call SP_BOLETINES_GENERICO_NOTAS_INDIVIDUALES('$cod_estudiantes',$grupo,$periodon,'$iduser')";

$academia->instruccion($sql);
echo '<div style="display:none">' . $sql . '</div>';
unset($sql);
$row = $academia->extraer_registro();
$dtsColegio = $sesion->get('info_colegio');
$encabezado = $dtsColegio['enca_boletin'];
$observa = "";
$mayus_nom = $sesion->getVar('configuracion.format_nom');
$mayus_mat = $sesion->getVar('configuracion.format_mat');
do {
    $observa = "";
    #echo "<br><br><br>";
    echo '<div id="pageBoletin">';
    #echo "<br><br><br>";
    echo $encabezado;
    $notest = str_replace("\n", "<br>", $row['notas']);
    $notest = str_replace("\t", " ", $notest);
    $notest = parseString($notest);
    $notest = json_decode($notest, true);

    $infcom = json_decode($row['comportamiento'], true);
    $cod_est = $notest['cd_est'];
    $msgPbar = "id-" . $notest['dc_est'] . "-pto-" . $notest['pto_gru'];
    $msgPbar.="-grado-" . $grado . "-per-" . $periodon . '-val-si-anio' . $sesion->get('anio');
    $dtsObserva = json_decode($row['observaciones'], true);
    $prom_periodo_num = $notest['prom_periodo'];
    $prom_periodo_let = $notest['prom_peri_letra'];
    $pto_grupo = $notest['pto_gru'];
    ?>
    <link href="../css/formato_boletin_<?php echo $frm_bol_gral ?>.css" rel="stylesheet" type="text/css">
    <div style="text-align:center; width:100%"><b>INFORME NIVEL PRESCOLAR.</b></div>
    <table width="100%" cellspacing="1" class='boletin'>
        <tr>
            <td style="font-weight: bold">Nombre del estudiante</td>
            <td colspan="5"><?php echo formatoPalabras($notest['no_est'], $mayus_nom); ?></td>
        </tr>
        <tr>
            <td style="font-weight: bold">Grado</td>
            <td colspan="0"><?php echo $grado; ?></td>
            <td style="font-weight: bold">ETAPA</td>
            <td colspan="0"><?php echo $periodo; ?></td>
            <td style="font-weight: bold">Año lectivo</td>
            <td><?php echo $sesion->get('anio') ?></td>
        </tr>
        <tr>
            <td style="font-weight: bold">DOCENTE</td>
            <td colspan="3"><?php echo formatoPalabras($director, $mayus_nom) ?></td>
            <td style="font-weight: bold">INASISTENCIAS</td>
            <td ><?php  ?></td>

        </tr>
    </table>
    <div class="separador"></div>
    <?php
    $materias = $notest['materias'];
    $numPeriodos = count($materias[0]['historicos']);
    $bandera = $periodon == $numPeriodos ? true : false;
    ?>
    <div style="font-family: Calibri; font-size: 8pt">
        <?php
        $materias = $notest['materias'];
        $cdant = -1;
        $contNmat = 1;
        foreach ($materias as $rmat):
            ?>
            <div class="bloque_materia">
                <table  width="100%" cellspacing="1" class='boletin'>
                    <tr>
                        <td rowspan="2" style="font-weight: bold; width: 70%;" >DIMENSIÓN: <?php echo formatoPalabras($rmat['no_asi'], $mayus_mat) ?></td>
                        <td colspan="2" style="font-weight: bold;  text-align: center">VALORACION</td>
                    </tr>

                    <tr>
                        <td style="width: 9%; text-align: center" class="bold">ALCANZADO</td>
                        <td style="width: 9%; text-align: center" class="bold">REFORZAR</td>
                    </tr>


                    <?php
                    $totNtInd = count($rmat['notasind']);


                    foreach ($rmat['notasind'] as $dnt) {
                        echo "<tr>";
                        echo '<td >' . $dnt['nomnota'] . '</td>';
                        echo '<td style="width: 9%; text-align: center"">' . (($dnt['valnota'] <= 1.9) ? 'X' : '' ) . '</td>';
                        echo '<td style="width: 9%; text-align: center"">' . (($dnt['valnota'] > 1.9 && $dnt['valnota'] <= 2.9 ) ? 'X' : '') . '</td>';

                        echo "</tr>";
                    }
                    ?>

                </table>
            </div>
            <div class="separador"></div>
            <?php
        endforeach;
        ?>

        <?php
        $dtsObserva = str_replace("\n", "<br/>", $row['observaciones']);
        $dtsObserva = str_replace("\t", "  ", $dtsObserva);
        $dtsObserva = parseString($dtsObserva);
        #echo $dtsObserva.'<br>';
        $dtsObserva = json_decode($dtsObserva, true);
        $observa = $dtsObserva['obsobserva'];

        echo '<br><br><table width="100%" align="center" class="observa"><tr><td><b>OBSERVACIONES:</b></td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr></table>';

        ?>

        <div class="separador"></div>

        <br><br>

        <table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-bottom:2px; font-size: 9pt;  font-family: Arial, Helvetica, sans-serif;  vertical-align:top;">
            <tr align="center">
                <td style="vertical-align: bottom">_________________________________<br>
                    <?php echo strtoupper($director) ?><br>
                    Director de Grupo
                </td>
                <td class="v-align-top" style="text-align: center">
                    <img src='../images/firma_cor.jpg' width='160' height='40' alt='Firma rector' class='codbar' style='vertical-align:bottom'>
                    <br>
                    Esp. EDSON NILSEN LOPEZ BARRERA
                    <?php echo "<br> Cordinador Académico" ?>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center">
                    <br>
                    <img src='../images/firma_rec.png' width='160' height='40' alt='Firma rector' class='codbar' style='vertical-align:bottom'>
                    <br> Esp. DORIS CONSTANZA CORTES QUIJANO
                </td>
            </tr>
        </table>

        <table id="foot" width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td width="6%" rowspan="2" align="center" valign="middle">&nbsp;</td>
                <td align="center" valign="middle"><?php echo $sesion->getVar('info_colegio.pie_boletin') ?></td>
                <td width="6%" rowspan="2" align="right"><?php
                    // user data
                    $PNG_TEMP_DIR = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR;
                    $PNG_WEB_DIR = 'temp/';
                    //ofcourse we need rights to create temp dir
                    if (!file_exists($PNG_TEMP_DIR))
                        mkdir($PNG_TEMP_DIR);

                    $errorCorrectionLevel = 'L';
                    $matrixPointSize = 1;
                    //echo $msgPbar;
                    $filename = $PNG_TEMP_DIR . 'Boletin' . $cod_est . '_' . $sesion->get('academia_succes') . "-" . md5($errorCorrectionLevel . '|' . $matrixPointSize . '') . '.png';
                    QRcode::png($msgPbar, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
                    echo '<img src="' . $PNG_WEB_DIR . basename($filename) . '" class="codbar" />';
                    ?></td>
            </tr>
            <tr>
                <td align="center"><span class="copy"><?php echo $dtsLang['project']['nom_soft'] . ' ' . $dtsLang['project']['ver_soft'] . ' ' . $dtsLang['project']['footertext'] . " " . $dtsLang['project']['anio_ini'] . ' - ' . date('Y') ?></span></td>
            </tr>
        </table>
    </div>
    <?php
    echo "</div>"; //cirra la pagina
}while ($row = $academia->extraer_registro());
$academia->liberar();
