<?php

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

class Con4 extends database
{
    function proceso($doc)
    {
      
        $this->conectar();
        $resul=$this->consulta("select * from curso_asignatura_profesor where profesor='".$doc."';");
       
        while ( $tsArray = $this->fetch_assoc($resul) )
                {
                $data[] = $tsArray;

                }

        //print_r($data);
        if(mysql_num_rows($resul))
        {
        $f=0;
          for($i=0;$i<count($data);$i++)
            {
                $resul=$this->consulta("select * from logros where grado='".$data[$i]['grado']."' and curso='".$data[$i]['curso']."' and asignatura='".$data[$i]['asignatura']."' order by periodo asc ");

                //echo ("select * from logros where grado='".$data[$i]['grado']."' and curso='".$data[$i]['curso']."' and asignatura='".$data[$i]['asignatura']."' order by periodo asc ");

               
                while($row=$this->fetch_assoc($resul))
                {
                    $c=0;


                    $arr[$f][$c+1]= $this->name('grado',$row['grado']);
                    $arr[$f][$c+2]= $this->name('cursos',$row['curso']);
                    $arr[$f][$c+3]=$this->name('catalogo',$row['asignatura']);
                    $arr[$f][$c+4]=$this->name('periodos',$row['periodo']);
                    $arr[$f][$c+5]=$row['codigo'];
                    $arr[$f][$c+6]=$row['descripcion'];
                    $arr[$f][$c+7]=$row['orden'];
                    $arr[$f][$c+8]=$row['orden1'];
                    $f++;
                }
              /* echo "<br><br>";
                print_r($arr);
            
               echo "<br><br>";*/

            }

            $arr[$f][0]=$this->namepro('profesores',$data[0]['profesor']);

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


    function namepro($tabla,$cod){
         $result=$this->consulta("select * from ".$tabla." where cedula='".$cod."';");
         $rs=$this->fetch_assoc($result);
         return $rs['nombres'];
    }
}
/*
$ob=new Con4();
      $arr= $obj->proceso($_REQUEST['docente']);
        $obj->disconnect();


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

    }
    echo "<br><br>";
}
 *
 * */
 
?>