<?php

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

require_once("../../../../dompdf/dompdf_config.inc.php");
require_once "../../../../dompdf/www/functions.inc.php";


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

$ob1=new Con1();
$arr1=$ob1->proceso();

$codigo=$_REQUEST['cod'];
$falta=$_REQUEST['falta'];


  $alumno=$obj->consulta("select matriculas.codigo,CONCAT(p_apellido,' ',s_apellido,' ',p_nombre,' ',s_nombre) as nombres,matriculas.estado, matriculas.grado, grados.descripcion as nom_grad, matriculas.curso, cursos.descripcion as nom_cur
               from (grados inner join (cursos inner join matriculas on (cursos.codigo = matriculas.curso) and (cursos.grado = matriculas.grado)) on grados.codigo = cursos.grado) inner join alumnos on matriculas.codigo = alumnos.codigo
               where  matriculas.codigo='".$codigo."'");

   $row_alum=$obj->fetch_assoc($alumno);


$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>Tipos de Faltas</title>

</head>

<body>";

$html.="<br><br><center><table width='90%' border='0' align='center'>";

$html.="<tr>";
$html.="<td align='right' rowspan='3'><img src='../../../../fotografias/".$arr[1]."' width='70' height='70'></td>";
$html.="<td style='font-size: 14px; text-align:center;'>".$arr[2]."</td></tr>";

$html.="<tr><td  style='font-size: 17px; text-align:center;'><b>".$arr[0]."</b></td></tr>";
$html.="<tr><td style='font-size: 14px; text-align:center;' >".$arr[5]."</td></tr>";

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

$html.="<center><b>DESCRIPCI&Oacute;N DE FALTAS<br><br>".$codigo." - ".$row_alum['nombres']."<br><br>GRUPO : ".$row_alum['nom_cur']."</b></center>";

   $s='';
   $per=1;

   while($per<=4){

           if ($falta=='*'){
               $cadena1="select * from reporte_faltas where periodo='".$per."' and codigo='".$codigo."' order by orden";
           } 
           else{
               $cadena1="select * from reporte_faltas where falta='".$falta."' and periodo='".$per."' and codigo='".$codigo."' order by orden";
           }
           
           $cadena1=$obj->consulta($cadena1);

           $tot = $obj->numero_de_filas($cadena1);

           if  ($tot>0){  //llllllllllllll

           $s.="<BR><CENTER>PERIODO ".$per."</CENTER>";

           $s.="<BR><table align='center' border='1' cellspacing='0' width='90%'>";

           if ($falta!='*'){

              //--------------------------------
                $descrip_f=$obj->consulta("SELECT * FROM faltas WHERE codigo='".$falta."'");
                $row_f = $obj->fetch_assoc($descrip_f);   
              //--------------------------------
               $s.="<tr ALIGN='CENTER' > <td width='10%'><b>FFECHA</b></td> <td  width='80%'><b>DESCRIPCI&Oacute;N</b></td> </tr>";

               $s.="<tr>
                    <td colspan='2' align='center' style='font-size: 12px'>".$falta." - ".$row_f['descripcion']."</td>
                    </tr>"; 
           }
           else{
                $s.="<tr ALIGN='CENTER' > <td width='10%'><b>FALTA</b></td> <td width='10%'><b>FFECHA</b></td> <td  width='80%'><b>DESCRIPCI&Oacute;N</b></td> </tr>";
           }
           
           while($row1 = $obj->fetch_assoc($cadena1)){

                $s.="<tr>";

                if ($falta=='*'){
                $s.="<td align='center' style='font-size: 12px'>".$row1['falta']."</td>";
                }
                
                $s.="<td align='center' style='font-size: 12px'>".$row1['fecha']."</td>";
                $s.="<td style='font-size: 12px;'>&nbsp;". ($row1['descripcion'])."</td>";
                $s.="</tr>";

           }

           $s.="</table>";
        
        } //llllllllllllll
        
        $per++;
    }




$obj->disconnect();

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


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

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

?>