<?
include("../fnc.php");
enlinea_a();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Reporte de Notas por grado, por unidad (sin detalle)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../estilo1.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="right">
      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="87%" class="lbl_campo"> <div align="left"><?=$nombre_colegio;?><br>
            CENTRALIZACION DE NOTAS FINALES</div></td>
          <td width="13%"><div align="right"><a href="#" onclick="print();" class="link_parrafo"><img src="../images/printButton.png" width="16" height="16" border="0"> Imprimir</a></div></td>
        </tr>
        <tr>
          <td class="lbl_campo" align="left">GRADO: <?=ggrado($gid)." ".gnivel($nid)." ";?> </td>
          <td class="parrafo"><div align="right"><?=fechalarga($fechahora);?>
              </div>
            <div align="right"></div></td>
        </tr>
      </table>
      <br>
        <?if(!$gid){exit();}?>
      </div>
      <table width="640" border="0" cellpadding="1" cellspacing="0" bgcolor="#CFDFEF">
        <tr>
          <td width="54" bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong>CARNET</strong></div></td>
          <td width="418" bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong>NOMBRE DEL ALUMNO </strong></div></td>
          <?
                                    $id_gr=dec($gid);
                                    $id_un=dec($uid);
                                    $id_se=dec($sid);
                                    $qcursos=mysql_query("select cursos.*
                                                          from cursos_grados inner join cursos ON cursos.codigo = cursos_grados.curso
                                                          where grado='$id_gr'

                                                          order by oficial desc, posicion_certificado, cursos.curso");
//                                                          and cursos.promocion <> 'S'
                                    unset($arr_cursos);
                                    unset($arr_codcursos);
                                    unset($arr_prommateria);
                                    $arr_cursos=Array();
                                    $arr_codcursos=Array();
                                    $arr_prommateria=Array();
                                    $cont_menos60m=Array();
                                    $cont_menos70m=Array();
                                    $i=0;
                                    while($icurso=mysql_fetch_array($qcursos)){
                                      $i++;
                                      $arr_cursos[$i]=$icurso[curso];
                                      $arr_codcursos[$i]=$icurso[codigo];
                                      ?>
          <td width="20" bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong><?=$i;?></strong></div></td>
          <?
          }
          ?>
          <??>
          <td width="20" bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong>PROM.</strong></div></td>
          <td width="20" bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong>&lt;60</strong></div></td>
          <td width="20" bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong>&lt;70</strong></div></td>
        </tr>
        <?
                                  $qalumnos=mysql_query("select * from alumnos where grado_estudio = '$id_gr' and seccion = '$id_se' and year_estudio = '$df_year_actual' order by apellido, nombre");
                                  $cant_alumnos=mysql_num_rows($qalumnos);

                                  for($n=0;$n<=count($arr_codcursos);$n++){
                                     $cont_menos60m[$n]=0.00;
                                     $cont_menos70m[$n]=0.00;
                                  }

                                  while($ialumno=mysql_fetch_array($qalumnos)){
                                  $j++;
                                  ?>
        <tr valign="top" bgcolor="<?=color_fila($j);?>">
          <td class="parrafo"><div align="center"><?=$ialumno[carnet];?></div></td>
          <td class="parrafo"><div align="left"><?=$ialumno[apellido].", ".$ialumno[nombre];?></div></td>
          <?
                                    $cont_menor60=$cont_menor70=$promedio=0;
                                    for($n=1;$n<=count($arr_codcursos);$n++){

                                     $msg_nota="";
                                     $nota=0.00;

                                     $qnota=mysql_query("select * from notas_unidades
                                                         where grado='$id_gr'
                                                         and unidad='$id_un'
                                                         and curso = '{$arr_codcursos[$n]}'
                                                         and alumno='{$ialumno[carnet]}'");

//                                     if(mysql_num_rows($qnota)==0){
//                                      $msg_nota="P";
//                                      $nota=0.00;
//                                     }else{
//                                      $inota=mysql_fetch_array($qnota);
                                      $inota[nota]=nota_promedio($ialumno[carnet],$arr_codcursos[$n]);

                                      if($inota[nota]<60){
                                       $cont_menor60++;
                                       $cont_menos60m[$n]++;
                                      }

                                      if($inota[nota]>=60 && $inota[nota]<70){
                                       $cont_menor70++;
                                       $cont_menos70m[$n]++;
                                      }

                                      $inota[zona]=round($inota[zona],1);
                                      $inota[examen]=round($inota[examen],1);
                                      $color="blue";
                                      if($inota[cerrado]=="N"){
                                        $color="red";
                                      }

                                       $msg_nota="<center><strong><font color='$color'>".$inota[nota]."</font></strong></center>";
                                      $nota=$inota[nota];
//                                     }

                                     $arr_prommateria[$n]+=$nota;
                                     $promedio+=$nota;
                                    ?>
          <td class="parrafo"><div align="center"><?=$msg_nota;?></div></td>
          <?
                                    }
                                    ?>
          <td class="parrafo"><div align="right">
              <?=moneda(round($promedio/($n-1),2));?>
          </div></td>
          <td class="parrafo"><div align="right">
              <?=$cont_menor60;?>
          </div></td>
          <td class="parrafo"><div align="right">
              <?=$cont_menor70;?>
          </div></td>
        </tr>
        <?
        }
        ?>
        <tr bgcolor="<?=color_fila($j);?>">
          <td colspan="2" bgcolor="#FFFFFF" class="parrafo Estilo1">&nbsp;</td>
          <td bgcolor="#FFFFFF" class="parrafo">&nbsp;</td>
          <td bgcolor="#FFFFFF" class="parrafo">&nbsp;</td>
          <td bgcolor="#FFFFFF" class="parrafo">&nbsp;</td>
          <td bgcolor="#FFFFFF" class="parrafo">&nbsp;</td>
          <?
          for($k=0;$k<count($arr_codcursos);$k++){
          ?>
          <td bgcolor="#FFFFFF" class="parrafo">&nbsp;</td>
          <?
          }
          ?>
        </tr>
        <tr bgcolor="<?=color_fila($j);?>">
          <td colspan="2" bgcolor="#CFDFEF" class="parrafo Estilo1"><div align="center" colspan="2">
              <div align="left">PROMEDIO POR MATERIA</div>
          </div></td>
          <?
          for($n=1;$n<=count($arr_prommateria);$n++){
          ?>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong>
              <?=(round($arr_prommateria[$n]/$cant_alumnos,0));?>
          </strong></div></td>
          <?
          }
          ?>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
        </tr>
        <tr bgcolor="<?=color_fila($j);?>">
          <td colspan="2" bgcolor="#CFDFEF" class="parrafo Estilo1"><div align="center" colspan="2">
              <div align="left">REPROBARON MENOS DE 60 PTS:</div>
          </div></td>
          <?
          for($n=1;$n<=count($cont_menos60m);$n++){
          ?>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong>
              <?=$cont_menos60m[$n];?>
          </strong></div></td>
          <?
          }
          ?>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
        </tr>
        <tr bgcolor="<?=color_fila($j);?>">
          <td colspan="2" bgcolor="#CFDFEF" class="parrafo Estilo1"><div align="center" colspan="2">
              <div align="left">REPROBARON MENOS DE 70 PTS:</div>
          </div></td>
          <?
          for($n=1;$n<=count($cont_menos70m);$n++){
          ?>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="center"><strong>
              <?=$cont_menos70m[$n];?>
          </strong></div></td>
          <?
          }
          ?>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
          <td bgcolor="#CFDFEF" class="parrafo"><div align="right"><strong>&nbsp;</strong></div></td>
        </tr>
      </table>
      
      <br>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr class="parrafo">
          <td width="6%" bgcolor="#CFDFEF" class="lbl_campo"><div align="center">#</div></td>
          <td width="11%" bgcolor="#CFDFEF" class="lbl_campo"><div align="center">CODIGO</div></td>
          <td width="83%" bgcolor="#CFDFEF" class="lbl_campo"><div align="center">NOMBRE DEL CURSO</div></td>
        </tr>
        <?
        for($n=1;$n<=count($arr_codcursos);$n++){
        ?>
        <tr bgcolor="<?=color_fila($n);?>" class="parrafo">
          <td align="center"><?=$n;?></td>
          <td align="center"><?=$arr_codcursos[$n];?></td>
          <td align="left"><?=$arr_cursos[$n];?></td>
        </tr>
        <?}?>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
