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

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>
</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"><strong>Pizarra de discusi&oacute;n</strong></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 bgcolor="#CFDFEF">
                        Seleccione un curso:
                    <select name="menu1" class="textbox" onChange="MM_jumpMenu('parent',this,0)">
                    <option value="#" selected>Seleccione uno...</option>
                       <?
                                    $grado=ggradoalumno($uuser);
                                    $qcursos=mysql_query("select cursos.curso, cursos.codigo
                                                          from cursos inner join cursos_grados
                                                               on cursos.codigo = cursos_grados.curso
                                                          where cursos_grados.grado = $grado");
                                    while($icursos=mysql_fetch_array($qcursos)){

                                    ?>
                                    <option value="frm_pizarra.php?cid=<?=enc($icursos[codigo]);?>"><?=$icursos[curso];?></option>
                                    <?
                                    }
                                    ?>

                    </select>
                        </td>
                      </tr>
                    </table>

                      <?if(!$cid ){exit();}?>
                      <table width="100%"  border="0" cellspacing="0" cellpadding="1">
                        <tr>
                          <td><br>
                            <table width="100%"  border="0" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
                                <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 pt.tema, pt.id, count(*) as cant, max(pm.fecha) as mfecha
                                                   from pizarra_temas pt inner join pizarra_mensajes pm
                                                   on pt.id = pm.tema
                                                   where pt.curso = '$id_cr'
                                                   group by pt.tema, pt.id");
                                while($itma=mysql_fetch_array($qtma)){
                                ?>
                                <tr bgcolor="#ECF2F9">
                                  <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";?>" class="link_parrafo"><?=$itma[tema];?>
                                    </a></div></td>
                                  <td class="lbl_formulario style1"><div align="center" class="parrafo"><?=$itma[cant];?></div></td>
                                  <td class="lbl_formulario style1"><div align="left" class="parrafo">
                                    <div align="center"><?=fechalarga($itma[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>