<?php
    session_start();
    if(!$_GET['id'] || !$_SESSION['centro'])
    {
        header("location:act-index.php");
    }

    include("../../conexion.php");
    include("../../include/funcionesGlobales.php");

    $consultaActa = mysql_query("SELECT * FROM act_acta WHERE id=".$_GET['id'], $conexion);
    $filaActa = mysql_fetch_array($consultaActa);

    $consultaCentro = mysql_query("SELECT * FROM centros WHERE id=".$_SESSION['centro'], $conexion);
    $filaCentro = mysql_fetch_array($consultaCentro);

    $consultaLibro = mysql_query("SELECT * FROM act_libro WHERE id=".$filaActa['idBook'], $conexion);
    $filaLibro = mysql_fetch_array($consultaLibro);

    $consultaCurso = mysql_query("SELECT * FROM anioacademico WHERE id=".$filaLibro['curso'], $conexion);
    $filaCurso = mysql_fetch_array($consultaCurso);

    ob_start();
?>
<html>
    <head>
        <title>Libro de Actas - Acta</title>
    </head>
    <body style="font-family:tahoma;margin:40px">
        <script type="text/php">

              if ( isset($pdf) ) {
                $font = Font_Metrics::get_font("verdana", "bold");
                $pdf->page_text(40, 18, "IES \"<?php echo $filaCentro['centro']?>\"", $font, 12, array(0,0,0));
                $pdf->page_text(560, 18, "{PAGE_NUM}", $font, 12, array(0,0,0));
                $pdf->page_text(40, 750, "Acta del Departamento de Orientación", $font, 12, array(0,0,0));
                $pdf->page_text(480, 750, "Curso <?php echo $filaCurso['anioAcademico']?>", $font, 12, array(0,0,0));
              }
        </script>
<?php
    include ("act-printAct.php");
?>
        </body>
    </html>
<?php

    $html = ob_get_contents();
    $ok = ob_end_clean();

    ini_set ("memory_limit","20M");
    require_once ("../../include/dompdf/dompdf_config.inc.php");

    $dompdf = new DOMPDF();

    $dompdf->load_html ($html);

    $dompdf->render();
    $dompdf->stream ("acta".$filaActa['fecha'].".pdf");
    $pdf = $dompdf->output ();

?>