<?php

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

class Con2 extends database
{
    function proceso($profesor)
    {
   
        $this->conectar();
        $resul=$this->consulta("select * from curso_asignatura_profesor where  profesor='".$profesor."'  order by orden asc;");
  
        if($this->numero_de_filas($resul)>0)
        {
            $f=0;
            while($row=$this->fetch_assoc($resul))
            {
                $c=0;

                $arr[$f][$c]= $row['grado'];

                $arr[$f][$c+1]= $row['curso'];
                $arr[$f][$c+2]= $this->name('cursos',$row['grado'],$row['curso']);
                $arr[$f][$c+3]= $this->jornada('cursos',$row['grado'],$row['curso']);
                $arr[$f][$c+4]=$row['asignatura'];
                $arr[$f][$c+5]=$this->name1('catalogo',$row['asignatura']);

                $arr[$f][$c+6]=$row['profesor'];
                $arr[$f][$c+7]=$this->name2('profesores',$row['profesor']);
                $arr[$f][$c+8]=$row['intensidad'];
                $arr[$f][$c+9]=$row['dias'];
                $arr[$f][$c+10]=$row['orden'];



                $arr[$f][$c+1]= $row['curso'];
                $arr[$f][$c+2]= $this->name('cursos',$row['grado'],$row['curso']);
                $arr[$f][$c+3]= $this->jornada('cursos',$row['grado'],$row['curso']);
                $arr[$f][$c+4]=$row['asignatura'];
                $arr[$f][$c+5]=$this->name1('catalogo',$row['asignatura']);

                $f++;
            }
            $resul=$this->consulta("select sum(intensidad) as horas from curso_asignatura_profesor where  profesor='".$profesor."'  order by curso asc;");
            while($row=$this->fetch_assoc($resul))
            {
            $arr[$f][0]=$row['horas'];
            }
            return ($arr);
        }else{
            return ('no');
        }
    
    }

    function jornada($tabla,$cod,$cod1){
         $result=$this->consulta("select * from ".$tabla." where grado='".$cod."' and codigo='".$cod1."';");
         $rs=$this->fetch_assoc($result);

         $result=$this->consulta("select * from jornadas where codigo='".$rs['jornada']."';");
         $rs=$this->fetch_assoc($result);
         return $rs['descripcion'];


    }

    function name($tabla,$cod,$cod1){
         $result=$this->consulta("select * from ".$tabla." where grado='".$cod."' and codigo='".$cod1."';");
         $rs=$this->fetch_assoc($result);
         return $rs['descripcion'];
    }

     function name1($tabla,$cod){
         $result=$this->consulta("select * from ".$tabla." where codigo='".$cod."';");
         $rs=$this->fetch_assoc($result);
         return $rs['nombrecorto'];
    }


     function name2($tabla,$cod){
         $result=$this->consulta("select * from ".$tabla." where cedula='".$cod."';");
         $rs=$this->fetch_assoc($result);
         return $rs['nombres'];
    }


}

if(empty ($_REQUEST['profesor']))
{
    $pro='';
}else{
    $pro=$_REQUEST['profesor'];
}


$obj=new Con2();
$arr=$obj->proceso($pro);
$obj->disconnect();

/*
for($i=0;$i<count($arr);$i++)
{
    for($c=0;$c<11;$c++)
    {
       echo $arr[$i][$c]." -- ";

    }
    echo "<br><br>";
}


*/
?>