<?
include("../fnc.php");
enlinea_c();

if($idt){
 $qt=mysql_query("select * from pizarra_temas where id = ".dec($idt));
 if(mysql_num_rows($qt)==0){
   alert("Parámetros incorrectos","frm_login.php");
 }else{
   $it=mysql_fetch_array($qt);
   $tipo="Update";
 }
}else{
 $tipo="Add";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>e-Ducativo - Bienvenido</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../estilo1.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>

<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
  <tr>
    <td bgcolor="#336699">    <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E5E5E5">
      <tr bgcolor="#FFFFFF">
        <td width="40%"><img src="../images/logo_5.gif" width="300" height="50"></td>
        <td width="60%" background="../images/back_header_cat.gif" bgcolor="#FFFFFF"><div align="right" class="usuario_nombre_enc"><strong><?echo "$unombre $uapellido";?><br>
          </strong>Tiene <?=mensajes($uuser);?> mensaje(s) sin leer</div></td>
      </tr>
      <tr bgcolor="#FFFFFF">
        <td height="15" colspan="2" background="../images/barra_encabezado.gif">&nbsp;</td>
        </tr>
    </table>
      <table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="20%" valign="top" bgcolor="#FFFFCC"><?php include("menu.php"); ?>&nbsp;</td>
          <td width="80%" valign="top" bgcolor="#FFFFCC"><table width="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#333333">
            <tr align="center" valign="middle" bgcolor="#FFFFCC">
              <td height="20" class="titulo_pagina"><div align="center" class="titulo_pagina">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="65">&nbsp;</td>
                    <td><div align="center" class="titulo_pagina">PIZARRA DE DISCUSION <img src="../images/flecha_3.jpg" width="9" height="9"> Mensajes </div></td>
                    <td width="65"><div align="right"><a href="inicio.php" class="link_parrafo">Inicio<img src="../images/ic_home.png" width="21" height="21" border="0"></a></div></td>
                  </tr>
                </table>
              </div></td>
            </tr>
            <tr>
              <td align="left" valign="top" bgcolor="#FFFFCC"><div align="left" class="parrafo">
                <table width="99%"  border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#333333">
                  <tr>
                    <td bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="1">
                      <tr>
                        <td width="32%" bgcolor="#CFDFEF"><div align="left"><strong>Seleccione un grado: </strong></div></td>
                        <td width="68%" bgcolor="#ECF2F9">
                         <select name="menu1" class="textbox" onChange="MM_jumpMenu('parent',this,0)">
                             <option value="#" selected>Seleccione uno...</option>

                            <?
                                      $qgrados=mysql_query("select distinct grados.grado, grados.id as idg, cursos.curso, cursos.codigo as idc,
                                                            jornadas.jornada, jornadas.id as idj, niveles.nivel, niveles.id as idn, cursos_catedraticos.seccion
                                                            from cursos_catedraticos inner join grados on cursos_catedraticos.grado = grados.id
                                                            inner join cursos on cursos_catedraticos.curso = cursos.codigo
                                                            inner join niveles on grados.nivel = niveles.id
                                                            inner join jornadas on jornadas.id = grados.jornada
                                                            where cursos_catedraticos.catedratico = '$uuser'");
                                    while($ic=mysql_fetch_array($qgrados)){
                                    if(enc($ic[idg])==$gid and enc($ic[seccion])==$sid and enc($ic[idc])==$cid){
                                     $sel="selected class='selected_option'";
                                    }else{
                                     $sel="";
                                    }
                                    ?>
                                     <option value="<?="$PHP_SELF?gid=".enc($ic[idg])."&sid=".enc($ic[seccion])."&cid=".enc($ic[idc])."&jid=".enc($ic[idj])."&nid=".enc($ic[idn]);?>" <?=$sel;?>><?=$ic[jornada]." | ".$ic[nivel]." | ".$ic[grado]." | ".$ic[curso]." | ".$ic[seccion];?></option>
                                    <?
                                    }
                                    ?>

                         </select>
                        </td>
                      </tr>
                    </table>
                      <?if(!$cid or !$gid){exit();}?>
                      <table width="100%"  border="0" cellspacing="0" cellpadding="1">
                        <tr>
                          <td><br>
                            <table width="100%"  border="0" cellpadding="2" cellspacing="1" bgcolor="#EFEFEF">
                                <tr bgcolor="#6699CC">
                                  <td colspan="3"><div align="left" class="titulo_seccion_blanco">Pizarra de discusi&oacute;n del curso [ <u><?=gcurso($cid);?></u> ] </div></td>
                                  </tr>
                                <tr bgcolor="#CFDFEF">
                                  <td width="60%" bgcolor="#CFDFEF" class="parrafo"><strong>Tema</strong></td>
                                  <td width="15%" bgcolor="#CFDFEF"><div align="center" class="style2"><strong>Mensajes</strong></div></td>
                                  <td width="25%" bgcolor="#CFDFEF"><div align="center"><strong>Ultimo mensaje</strong></div></td>
                                </tr>
                                <?
                                $id_cr=dec($cid);
                                $qtma=mysql_query("select tema, id
                                                   from pizarra_temas pt
                                                   where pt.curso = '$id_cr'
                                                   group by pt.tema, pt.id");
                                $i=0;
                                while($itma=mysql_fetch_array($qtma)){
                                $qmsg=mysql_query("select tema, count(*) as cant, max(fecha) as mfecha
                                                   from pizarra_mensajes
                                                   where tema={$itma[id]}
                                                   group by tema");
                                if(mysql_num_rows($qmsg)==0){
                                  $imsg[cant]=0;
                                  $imsg[mfecha]="";
                                }else{
                                  $imsg=mysql_fetch_array($qmsg);
                                }
                                $i++;
                                ?>
                                <tr bgcolor="<?=color_fila($i);?>">
                                  <td><div align="left"><img src="../images/flecha_1.png" width="9" height="9"><a href="frm_pizarra_msg.php?tid=<?=enc($itma[id])."&cid=$cid&sid=$sid&jid=$jid&nid=$nid";?>" class="link_parrafo"><?=$itma[tema];?>
                                    </a></div></td>
                                  <td class="lbl_formulario style1"><div align="center" class="parrafo"><?=$imsg[cant];?></div></td>
                                  <td class="lbl_formulario style1"><div align="left" class="parrafo">
                                    <div align="center"><?=fechalarga($imsg[mfecha]);?></div>
                                  </div></td>
                                </tr>
                                <?
                                }
                                ?>
                            </table></td>
                        </tr>
                      </table></td>
                  </tr>
                </table>
                &nbsp; </div></td>
              </tr>
          </table></td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>