<?php

require_once ('../app/model/db.class.php');
require_once('../dompdf/dompdf_config.inc.php');
require_once ('../dompdf/www/functions.inc.php');

require_once ('bs_info.php');
require_once ('../app/model/bs_info_col.php');

function nombremes($mes){
setlocale(LC_TIME, 'spanish');
$nombre=strftime("%B",mktime(0, 0, 0, $mes, 1, 2000));
return $nombre;
}

$codigo =$_REQUEST['codigo'];


$ob=new InfoCol();
$arr=$obj->proceso();
$row=$obj->proceso2();
$obj->disconnect();

$ob1=new Con1();
$parmtros=$ob1->parametros();
$tabla=$ob1->infotabla($codigo);
$info=$ob1->proceso();
$leyen=$info['leyenda'];
$obj->disconnect();


        $sede=$obj->consulta("select sedes.descripcion from matriculas inner join (sedes inner join cursos on sedes.codigo = cursos.sede) on
                              (matriculas.curso = cursos.codigo) and (matriculas.grado = cursos.grado) where matriculas.codigo='".$codigo."'");

        $row1=$obj->fetch_assoc($sede);


$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>Certificado Final</title>

<style type='text/css'>
  
       .normal {
          border: 1px solid #000;
          border-collapse: collapse;
        }
        .normal th, .normal td {
          border: 1px solid #000;
        }
        
        .ecabezado{
        text-align:center;
        }
</style>

</head>

<body>";

$html.="<table width='90%' border='0' align='center'>";
$html.="<tr>
          <td align='center' rowspan='4'><img src='../fotografias/".$arr[1]."' width='75' height='75'></td>
          <td style='font-size: 13px; text-align:center;'><b>REP&Uacute;BLICA DE COLOMBIA</b></td>
          <td align='center' rowspan='4'><img src='../fotografias/escudo1.jpg' width='80' height='65'></td>
        </tr>";
$html.="<tr><td style='font-size: 13px; text-align:center;'><b>DEPARTAMENTO DEL CAQUET&Aacute;</b></td>";
$html.="<tr><td style='font-size: 13px; text-align:center;'><b>".$arr[0]."</b></td></tr>";
$html.="<tr><td style='font-size: 12px; text-align:center;'>".$arr[5]."</td></tr>";


$html.="</table><br>";


//------------------------------------------------------------------------------
        
$html.="<br><table width='90%' align='center'  border='0'>";
$html.="<tr><td style='font-size: 13px;'>Certificado No.  ".$parmtros['no_certificado']."</td></tr>";
$html.="</table>";                      
       
        
$html.="<table width='90%' border='0' align='center'>";
$html.="<tr><td style='font-size: 13px; width: 225px;' >R.E  :".$arr[7]."</td>";
$html.="<td style='font-size: 13px; text-align:right;'>C&oacute;digo DANE : ".$arr[8]." </td></tr>";
$html.="</table><br>"; 

$html.="
    <table width='90%' border='0' align='center'>";
$html.="<tr><td style='font-size: 13px; text-align:justify'>".($arr[9])."</td></tr>";
$html.="</table><br>";

    
$html.="<table width='70%' border='0' align='center'>";
$html.="<tr><td style='font-size: 16px; text-align:center;'><b>CERTIFICAN</b></td></tr>";
$html.="</table><br>";



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

$html.="<table width='90%' border='0' align='center'>";
$html.="<tr><td style='font-size: 13px; text-align:justify;'>".$leyen."</td></tr>";
$html.="</table><br><br>";



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


$html.="<table width='90%' border='0' align='center'>";
$html.="<tr>
           <th style='font-size: 13px; width: 344px;'>AREAS Y/O ASIGNATURAS</th>
           <th style='font-size: 13px; width: 56px;'>I.H</th>
           <th style='font-size: 13px; width: 100px;'>VALORACION</th>
           <th style='font-size: 13px;'>DESEMPE&Ntilde;O</th>
        </tr>";
$html.="</table>";

for($i=0;$i<count($tabla);$i++){
 $html.="
    <table width='90%' class='normal' border='0' align='center'><tr>";
    
    for($e=0;$e<4;$e++){   
        
            if($e==0){
                
                $html.="<td style='font-size: 13px; width: 344px; text-align:justify;'>".($tabla[$i][$e])."</td>";
            }

            if($e==1){
                $html.="<td style='font-size: 13px; width: 56px; text-align:center;'>".($tabla[$i][$e])."</td>"; 
            }

             if($e==2){

                 $nota=$tabla[$i][$e];

                 if (strlen($tabla[$i][$e])==1) {
                     $nota=$tabla[$i][$e].".0";
                 }

                $html.="<td style='font-size: 13px; width: 100px; text-align:center;'>".$nota."</td>";
            }

             if($e==3){
                $html.="<td style='font-size: 13px; text-align:center;'>".($tabla[$i][$e])."</td>";
            }

        }
        
        $html.="</tr>";
        $html.="</table>";
}

$html.="</table>";  

  //---Escala de Valoracion -----

  $html.="<table align='center' width='90%' border='1' style='font-size: 11px; text-align:center;'>";
  $html.="<tr>";

  $html.="<td>ESCALA DE VALORACI&Oacute;N:</td>";
  $html.="<td>BAJO (1.0 - 2.9)</td>";
  $html.="<td>B&Aacute;SICO (3.0 - 3.9)</td>";
  $html.="<td>ALTO (4.0 - 4.5)</td>";
  $html.="<td>SUPERIOR (4.6 - 5.0)</td>";

  $html.="</tr>";
  $html.="</table>";

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

$html.="<br>
    <table width='90%' border='0' align='center'>";
$html.="<tr><td style='font-size: 13px; text-align:justify;'>".("En virtud del Decreto 1024 del 15 de abril de 1982, del Ministerio de Justicia,
        este Certificado no requiere autenticaci&oacute;n de Notar&iacute;a.  Seg&uacute;n Decreto 2150 del 5 de diciembre de 1995, queda exento de sellos.")."</td></tr>";
$html.="</table><br>";


$mes = date("m");
$dia = date("j");
$anyo = date("Y");

$mes=nombremes($mes);

$html.="
    <table width='90%' border='0' align='center'>";
$html.="<tr><td style='font-size: 13px; text-align:justify;'>Dado en ".$arr[5]." a los ".$dia." d&iacute;as del mes de ".strtoupper($mes)." de ".$anyo.".</td></tr>";
$html.="</table><br><br><br>";
        
         



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

$html.="
    <table width='85%' border='0' align='center'>";
$html.="<tr><td><hr width='90%'></td>    <td><hr width='90%'></td></tr>";

$html.="<tr><td style='font-size: 12px; text-align:center;'><b>".$row['rector']."</b></td>     
            <td style='font-size: 12px; text-align:center;'><b>".$row['secretario']."</b></td></tr>";

$html.="<tr><td style='font-size: 12px; text-align:center;'>".$row['cedula_rector']."</td>     
            <td style='font-size: 12px; text-align:center;'>".$row['cedula_secretario']."</td></tr>";

$html.="<tr><td style='font-size: 11px; text-align:center;'>RECTOR</td>     
            <td style='font-size: 11px; text-align:center;'>SECRETARIA</td></tr>";

$html.="</table><br>";  


$html.="</body>
</html>";


$dompdf = new DOMPDF();     
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'portrait');
$dompdf->render();

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


?>
