<?php

require_once "../../../app/model/db.class.php";

function descrip($tabla,$cod){
         $obj = new database();
         $obj->conectar(); $obj->consulta("set names 'utf8'");
         
         $result=$obj->consulta("select * from ".$tabla." where codigo='".$cod."';");
         $rs=$obj->fetch_assoc($result);
         $obj->disconnect();
         return $rs['descripcion'];
    }

 function descrip_cur($tabla,$cod,$cod2){
         $obj = new database();
         $obj->conectar(); $obj->consulta("set names 'utf8'");
         
         $result=$obj->consulta("select * from ".$tabla." where codigo='".$cod."' and grado='".$cod2."';");
         $rs=$obj->fetch_assoc($result);
         $obj->disconnect();
         return $rs['descripcion'];
    }


function descrip_prof($tabla,$cod){
         $obj = new database();
         $obj->conectar(); $obj->consulta("set names 'utf8'");
         
         $result=$obj->consulta("select * from ".$tabla." where cedula='".$cod."';");
         $rs=$obj->fetch_assoc($result);
         $obj->disconnect();
         return $rs['nombres'];
    }


if($_REQUEST['accion']=='tabla')
    {
        $grado=$_REQUEST['grado'];
        $curso=$_REQUEST['curso'];
        $profesor=$_REQUEST['profesor'];
        $asignatura=$_REQUEST['asignatura'];

        $v1='';
        $v2='';
        $v3='';
        $v4='';

        if($grado!='')//---grado
        {
            $v1="='".$grado."'";
        }else{
            $v1=" like '%' ";
        }


        if($curso!='')//---curso
        {
            $v2="='".$curso."'";
        }else{
            $v2=" like '%' ";
        }

        if($profesor!='')//---profesor
        {
            $v3="='".$profesor."'";
        }else{
            $v3=" like '%' ";
        }

        if($asignatura!='')//---asignatura
        {
            $v4="='".$asignatura."'";
        }else{
            $v4=" like '%' ";
        }


        $obj=new database();
        $obj->conectar(); $obj->consulta("set names 'utf8'");
        
       $result=$obj->consulta("select * from curso_asignatura_profesor where grado ".$v1." and curso ".$v2." and profesor ".$v3." and asignatura ".$v4." order by orden asc;");

        $cadena="<center><br><table border='0' cellspacing='3' cellpadding='2' class='t_info'>";
        $cadena.="<tr><td colspan='6'><FONT SIZE='4' COLOR='#B40404'><b>LABOR ACAD&Eacute;MICA</b></FONT></td></tr>";
        $cadena.="<tr>";
        $cadena.="<th> GRADO </th>";
        $cadena.="<th> CURSO </th>";
        $cadena.="<th> ASIGNATURA </th>";
        $cadena.="<th width='500'> NOMBRE DE ASIGNATURA </th>";
        $cadena.="<th> I.H </th>";
        $cadena.="<th> DIAS </th>";
        $cadena.="</tr>";


        if($obj->numero_de_filas($result))
        {


            while ( $tsArray = $obj->fetch_assoc($result) )
            {
            $data[] = $tsArray;

            }
            //print_r($data);


            for($i=0;$i<count($data);$i++){
                $cadena.="<tr onmouseover=\"this.style.backgroundColor='#89F2AC';\" onmouseout=\"this.style.backgroundColor='#BBE9EE';\">";
                $cadena.="<td>&nbsp;".$data[$i]['grado']."&nbsp;</td>";
                $cadena.="<td>&nbsp;".$data[$i]['curso']."&nbsp;</td>";
                $cadena.="<td>&nbsp;".$data[$i]['asignatura']." &nbsp;</td>";
                $cadena.="<td>&nbsp; ".descrip('catalogo',$data[$i]['asignatura'])." &nbsp;</td>";
                $cadena.="<td align='center'>&nbsp;".$data[$i]['intensidad']."&nbsp;</td>";
                $cadena.="<td align='center'>&nbsp; ".$data[$i]['dias']." &nbsp;</td>";
          
                $cadena.='<td align="center"> <img id="elemento2"  class="confirmar" src="../imagenes/pdf(1).png" height="25" width="30" alt="Generar PDF" title="Generar PDF"
                    onclick="pdf('.$data[$i]['profesor'].','.$data[$i]['grado'].','.$data[$i]['curso'].',\''.$data[$i]['asignatura'].'\','.$data[$i]['orden'].')">  </td>';

            }


        }else{

            $cadena.="<tr>";
            $cadena.="<td colspan='7' align='center'>Labor Academica No Registrada</td>";
            $cadena.="</tr>";
        }


    $cadena.="</table>";

    $cadena.="</center>";



    echo $cadena;
    }

 if($_REQUEST['accion']=='infoprofesor')
    {
     $profesor=$_REQUEST['profesor'];
     echo descrip_prof('profesores', $profesor);
    }
   
    
    

?>
