<?php
require_once("../../../../dompdf/dompdf_config.inc.php");
require_once "../../../../dompdf/www/functions.inc.php";
require_once '../../../../app/model/db.class.php';
require_once '../../../../app/model/bs_info_col.php';
require_once '../rangos.php';

if (!isset($_SESSION)) { session_start(); } 
 //---------------------------------

 function ceros($nota){

     if (strlen($nota)==1)
        $nota="000".$nota;
     
     elseif (strlen($nota)==2)
         $nota="00".$nota;
     elseif (strlen($nota)==3)
         $nota="0".$nota;

    return $nota;

}


//---------------------------------

$obj = new database();
$obj->conectar(); 
$obj->consulta("set names 'utf8'");

$pagina=$_REQUEST['pagina'];
$pagina=$pagina*40;

  //---- Informacion Colegio
  
  $rs = $obj->consulta("select * from registrar");
  $info = $obj->fetch_assoc($rs);

     $html="
           <html>
           <head>           
           <meta http-equiv='expires' content='0'>
           <meta http-equiv='Cache-Control' content='no-cache'>
           <meta http-equiv='Pragma' CONTENT='no-cache'>
           <title>Indice Libro</title>
           </head>

        <body>
        <center>
        <img height='100' width='85%' src='../../../../imagenes/cabeza_certificado.jpg'/>
        <br>
        <FONT size='3'><b>INDICE LIBRO FINAL<br>A&Ntilde;O LECTIVO ".$_SESSION['anolectivo']."<b></FONT>  </CENTER><br>";


    $html.="<table align='center' width='90%' cellspacing='0' cellpadding='1' border='1' style='font-size: 13px'>";
    $html.="<tr align='center'>
            <td width='12%'>No. FOLIO</td>  
            <td width='10%'>CODIGO</td> 
            <td width='60%'>APELLIDOS Y NOMBRES</td> 
            <td width='9%'>GRADO</td> 
            <td width='9%'>CURSO</td></tr>";
    $s="";
      
    $libro_final = $obj->consulta("select * from libro_final order by numero limit ".$pagina.",40");
    
    while ($z = $obj->fetch_assoc($libro_final)) { 
           
           $grado=$z['grado'];                                                     
           $s.="<tr>   
           <td align='center'>".ceros($z['numero'])."</td>  
           <td align='center'>".$z['codigo']."</td> 
           <td>&nbsp;".$z['p_apellido']." ".$z['s_apellido']." ".$z['p_nombre']." ".($z['s_nombre'])."</td>
           <td align='center'>".$grado."</td> 
           <td align='center'>".$z['curso']."</td>
           </tr>";                             
    }
    
   $html.=$s."</table></body></html>";
    
    
   $obj->disconnect(); 
    
    
   $dompdf = new DOMPDF();     
   $dompdf->load_html($html);
   $dompdf->set_paper('a4', 'portrait');
    //$dompdf->set_paper('letter','landscape');
   $dompdf->render();

   $dompdf->stream("Indice_Libro_Final.pdf", array("Attachment" => false));

?>