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

if(!$mes){
  $mes=date("m");
}

if(!$year){
  $year=date("Y");
}

if($mes<1 or $mes >12){
 alert("Error, parámetros incorrectos","javascript:history.go(-1)");
}

$primer_dia=date("w",mktime(0,0,0,$mes,1,$year));
$dias_mes=date("t",mktime(0,0,0,$mes,1,$year));

$n_mesactual=mes_letras(date("m"));
$link_hoy="frm_calendario.php?mes=".date("m")."&year=".date("Y");

if($mes==12){
 $nyear=$year+1;
 $link_smes="frm_calendario.php?mes=1&year=".$nyear;
}else{
 $nmes=$mes+1;
 $link_smes="frm_calendario.php?mes=".$nmes."&year=".$year;
}

if($mes==1){
 $lyear=$year-1;
 $link_ames="frm_calendario.php?mes=12&year=".$lyear;
}else{
 $lmes=$mes-1;
 $link_ames="frm_calendario.php?mes=".$lmes."&year=".$year;
}
?>
<!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 type="text/javascript" src="../jsincludes/overlib.js"></script>
<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>JOSE EFREN MONTERROSO SOLARES<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" bgcolor="#FFFFCC">
        <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" bgcolor="#FFFFCC" class="titulo_pagina"><div align="center" class="titulo_seccion">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="65">&nbsp;</td>
                    <td><div align="center" class="titulo_pagina"><strong>CALENDARIO</strong></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="0" bgcolor="#336699">
                  <tr bgcolor="#336699">
                    <td width="33%" bgcolor="#CFDFEF"><div align="left"><a href="<?=$link_hoy;?>" class="link_parrafo">Regresar a <strong><?="$n_mesactual $year";?></strong></a></div></td>
                    <td width="2%" bgcolor="#CFDFEF"><div align="right"><a href="<?=$link_ames;?>" class="link_parrafo"><strong><img src="../images/back_f2.png" width="32" height="32" border="0"></strong></a></div></td>
                    <td width="30%" bgcolor="#CFDFEF"><div align="center" class="titulo_seccion"><?php echo mes_letras($mes); ?> <?=$year;?></div></td>
                    <td width="2%" bgcolor="#CFDFEF"><div align="left"><a href="<?=$link_smes;?>" class="link_parrafo"><strong><img src="../images/next_f2.png" width="32" height="32" border="0"></strong></a></div></td>
                    <td width="33%" bgcolor="#CFDFEF"><div align="right">
                                        <select name="menu1" class="textbox" onChange="MM_jumpMenu('self',this,0)">
                      <option value="frm_calendario.php?mes=1&amp;year=2000">2000</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2001">2001</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2002">2002</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2003">2003</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2004">2004</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2005">2005</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2006" selected>2006</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2007">2007</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2008">2008</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2009">2009</option>
                      <option value="frm_calendario.php?mes=1&amp;year=2010">2010</option>
                            </select>
                      </div></td>
                  </tr>
                </table>
                <table width="99%"  border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#666666">
                  <tr bgcolor="#CFDFEF" class="lbl_campo">
                    <td width="85"><div align="center">Domingo</div></td>
                    <td width="85"><div align="center">Lunes</div></td>
                    <td width="85"><div align="center">Martes</div></td>
                    <td width="85"><div align="center">Mi&eacute;rcoles</div></td>
                    <td width="85"><div align="center">Jueves</div></td>
                    <td width="85"><div align="center">Viernes</div></td>
                    <td width="85"><div align="center">S&aacute;bado</div></td>
                  </tr>
                  <?

                  $semana=1;
                  $sumar=false;
                  while($semana<=6){
                  ?>
                  <tr align="left" valign="top" bgcolor="#ECF2F9">
                    <?
                    for($i=0;$i<=6;$i++){
                    if($semana==1 and $i==$primer_dia){
                      $sumar=true;
                    }

                    if($dia>=$dias_mes){
                      $sumar=false;
                      $dia="";
                      $fecha_evento="";
                    }

                    if($sumar==true){
                      $dia++;
                      $fecha_evento="$year-$mes-$dia";
                    }


                    ?>
                    <td height="50" <?if($dia==""){echo "bgcolor='#D0D0D0'";}else{if($fecha=="$year-$mes-$dia"){echo "bgcolor='#CFDFEF'";}}?>>
                      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td align="left" valign="top" class="lbl_campo">
                            <?if($dia!=""){?><strong><?=$dia;?></strong><?}if($fecha=="$year-$mes-$dia"){echo " Hoy";}?>
                          </td>
                        </tr>
                        <tr>
                          <td height="20" align="left" valign="top">
                          <?
                          if($dia!=""){
                          $qeventos=mysql_query("select * from calendario where fecha = '$fecha_evento' order by fecha, hora");
                          $hay_evento=false;
                          while($ievento=mysql_fetch_array($qeventos)){
                          $hay_evento=true;
                          ?>
                            <a href="#" onMouseOver="return overlib('<strong><?=$ievento[asunto];?></strong><br>Hora: <?=substr($ievento[hora],0,5);?>');" onmouseout="return nd();"><img src="../images/cuad_rojo.gif" border="0"></a>
                          <?
                          }// fin del ciclo

                          $qeventos=mysql_query("select evaluaciones.*, cursos.curso as ncurso
                                                 from evaluaciones inner join cursos on evaluaciones.curso = cursos.codigo
                                                 where fecha_inicio = '$fecha_evento' and evaluaciones.activa = 'S' order by fecha_inicio");
                          while($ievento=mysql_fetch_array($qeventos)){
                          $hay_evento=true;
                          ?>
                            <a href="#" onMouseOver="return overlib('<strong>Evaluación:</strong> <?=$ievento[nombre];?><br>Curso: <?=$ievento[ncurso];?><br>Inicia el: <?=fechalarga($ievento[fecha_inicio]." ".$ievento[hora_inicio]);?><br>Caduca el: <?=fechalarga($ievento[fecha_fin]." ".$ievento[hora_fin]);?>');" onmouseout="return nd();"><img src="../images/cuad_naranja.gif" border="0"></a>
                          <?
                          }// fin del ciclo

                          $qeventos=mysql_query("select tareas.*, cursos.curso as ncurso
                                                 from tareas inner join cursos on tareas.curso = cursos.codigo
                                                 where fecha_limite = '$fecha_evento' and tareas.activa = 'S' order by fecha_limite");
                          while($ievento=mysql_fetch_array($qeventos)){
                          $hay_evento=true;
                          ?>
                            <a href="#" onMouseOver="return overlib('<strong>Tarea:</strong> <?=$ievento[tarea];?><br>Curso: <?=$ievento[ncurso];?><br>Fecha máxima de entrega:<br><?=fecha($ievento[fecha_limite])." ".substr($ievento[hora_limite],0,5);?> Hrs.');" onmouseout="return nd();"><img src="../images/cuad_celeste.gif"  border="0"></a>
                          <?
                          }// fin del ciclo

                          } // fin si el dia no existe
                          ?>
                          </td>
                        </tr>
                        <tr>
                          <td height="10"><div align="right">
                             <?if($dia!="" and $hay_evento==true){?>
                             <a href="calendario.php?<?="txtdia=$dia&txtmes=$mes&txtyear=$year&txtconsulta=1";?>" class="link_parrafo" title="Ver todos los eventos con sus detalles...">Ver eventos<img src="../images/flecha_3.jpg" width="9" height="9" border="0"> </a></div>
                             <?}?>
                          </td>
                        </tr>
                    </table></td>
                    <?
                    }  // fin del ciclo de dias
                    ?>
                  <tr>
                  <?
                  $semana++;
                  } // fin del ciclo de semanas
                  ?>
                 </table>
                <table width="99%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#666666">
                  <tr>
                    <td bgcolor="#ECF2F9">&nbsp;[<img src="../images/cuad_celeste.gif" width="6" height="6"> Tareas] &nbsp;[<img src="../images/cuad_naranja.gif" width="6" height="6"> Evaluaciones] &nbsp;[<img src="../images/cuad_rojo.gif" width="6" height="6"> Eventos agregados por la administraci&oacute;n] </td>
                  </tr>
                </table>
              </div></td>
              </tr>
          </table></td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>