Código PHP :
<?
if($_REQUEST){
// $consulta_1="SELECT Count(DISTINCT fecha) FROM fechas"; //usarlo para paginar
extract($_REQUEST);
// FILTRO PARA LAS FECHAS
if ($mes!="TODO" AND $anio!="TODO"){
$criterio_fecha=" AND fechas.fecha like '%/".$mes."/".$anio."'";
$filtro=" Estas viendo ". date(F." ".Y,mktime(0,0,0,$mes,1,$anio));
$nombre_archivo=date(F."_".Y,mktime(0,0,0,$mes,1,$anio));
}elseif ($mes=="TODO" AND $anio!="TODO"){ //Filtro por año
$criterio_fecha=" AND fechas.fecha like '%/".$anio."'";
$filtro=" Estas viendo todo el ". date(Y,mktime(0,0,0,1,1,$anio));
$nombre_archivo="todo_".date(Y,mktime(0,0,0,1,1,$anio));
}elseif ($mes!="TODO" AND $anio=="TODO" ){ //Filtro por MES
$criterio_fecha=" AND fechas.fecha like '%/".$mes."/%'";
$anio="2006";
$filtro=" Estas viendo todas las de ". date(F,mktime(0,0,0,$mes,1,$anio));
$nombre_archivo="todo_".date(F,mktime(0,0,0,$mes,1,$anio));
}else{
$criterio_fecha="";
$filtro=" Estas viendo todas las actividades ";
$nombre_archivo="todas_actividades";
}
//echo date(d."/".m."/".Y);
}else{
$mes=date(m);
$anio=date(Y);
$criterio_fecha=" AND fechas.fecha Like '".date("%/".$mes."/".$anio)."'"; //fecha Actual
$filtro=date(F." ".Y)." (Filtro por defecto)";
$nombre_archivo=date(F."_".Y);
}
?>
</p>
<table width="100%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolor="#006699" class="sectiontableheader">
<tr>
<td valign="middle"><? @include 'menu_actividades.html'; ?></td>
<td valign="middle"><form name="form1" method="get" action="ver_actividades.php">
<table width="100%" border="0" align="right" cellpadding="3" cellspacing="0">
<tr class="sectiontableheader">
<td width="19%"><font color="#FFFFFF"> </font><font color="#FFFFFF">Mes:
<select name="mes" class="searchbox" id="mes">
<option value="01">Enero</option>
<option value="02">Febrero</option>
<option value="03">Marzo</option>
<option value="04">Abril</option>
<option value="05">Mayo</option>
<option value="06">Junio</option>
<option value="07">Julio</option>
<option value="08">Agosto</option>
<option value="09">Setiembre</option>
<option value="10">Octubre</option>
<option value="11">Noviembre</option>
<option value="12">Diciembre</option>
<option value="TODO" selected>TODO</option>
</select>
</font></td>
<td width="20%"><font color="#FFFFFF">Año:
<select name="anio" class="searchbox" id="anio">
<option value="TODO">TODO</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>
<option value="2013">2013</option>
</select>
</font></td>
<td width="21%"><div align="center"><font color="#FFFFFF">
<input name="Submit" type="submit" class="button" value="Filtrar Actividades">
</font></div></td>
</tr>
</table>
</form></td>
</tr>
</table>
<p> </p><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td width="50%" class="frontpageheader"><font size="3">Listado de Actividades: <?php echo $filtro; ?></font></td>
<td width="36%" ><div align="center"><a href="excel2.php?criterio=<? echo $criterio_fecha; ?>&filtro=<?php echo $filtro; ?>&nombre_archivo=<?php echo $nombre_archivo; ?>"><img src="images/excel3.gif" width="32" height="30" border="0"><br>
Guardar esta lista en Excel </a></div></td>
<td width="6%"><img src="images/banderaRoja.gif" width="20" height="22">ocupado</td>
<td width="8%"><img src="images/banderaVerde.gif" width="20" height="22">
Libre</td>
</tr>
</table>
<p> </p><table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#006699">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="sectiontableheader">
<td colspan="2"><div align="center"><font color="#FFFFFF">Fechas</font></div></td>
<td width="69%"><div align="center"><font color="#FFFFFF">Actividades</font></div></td>
</tr>
<?
if($criterio_fecha==""){
$consulta_2="SELECT distinct fechas.fecha FROM auxiliar_calendario, fechas, actividades Where auxiliar_calendario.id_act=actividades.id_act And auxiliar_calendario.id_fechas=fechas.id_fechas ORDER BY RIGHT(fechas.fecha, 8) DESC, RIGHT(fechas.fecha, 10) ASC, RIGHT(fechas.fecha, 4) ASC";
}else{
$consulta_2="SELECT distinct fechas.fecha FROM auxiliar_calendario, fechas, actividades Where auxiliar_calendario.id_act=actividades.id_act And auxiliar_calendario.id_fechas=fechas.id_fechas".$criterio_fecha."ORDER BY RIGHT(fechas.fecha, 8) DESC, RIGHT(fechas.fecha, 10) ASC, RIGHT(fechas.fecha, 4) ASC";
}
$result=mysql_query ($consulta_2);
$nro1=1;
while ($row = mysql_fetch_array($result)){
if($nro1==1){
$nro1=2;
}else{
$nro1=1;
}
//verificar si esta reservada
$consultar_reserva=mysql_query("SELECT * FROM fechas WHERE reservado=1 AND fecha='".$row['fecha']."'");
if(mysql_fetch_array($consultar_reserva)){
$banderita="<span id=\"toolTipBox\" width=\"200\"></span><img src=\"images/banderaRoja.gif\" width=\"23\" height=\"25\" onMouseOver=\"toolTip('Este día esta reservado',this)\">";
}else{
$banderita='<img src="images/banderaVerde.gif" width="23" height="25">';
}
$fecha_de_hoy=date(d."/".m."/".Y);
if(strpos($row['fecha'],$fecha_de_hoy)){
$dia_de_hoy="<span id=\"toolTipBox\" width=\"200\"></span><img src=\"images/clock.gif\" width=\"25\" height=\"25\" onMouseOver=\"toolTip('Actividades del día de hoy',this)\">";
}else{
$dia_de_hoy="";
}
?>
<tr class="sectiontableentry<? echo $nro1; ?>">
<td width="6%" height="30" valign="middle"><div align="center"><? echo $banderita; ?></div></td>
<td width="25%" height="30"> <span id="toolTipBox" width="200"></span>
<div align="center"><? echo $row['fecha']; ?><? echo $dia_de_hoy; ?></div></td>
<td height="30">
<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">
<?
$consulta_3="SELECT actividades.id_act, actividades.actividad, actividades.responsable, actividades.hora_inicio, actividades.hora_fin, lugar.nombre, fechas.fecha, fechas.reservado, fechas.id_fechas FROM actividades, fechas, lugar, auxiliar_calendario WHERE actividades.id_act=auxiliar_calendario.id_act AND fechas.id_fechas=auxiliar_calendario.id_fechas AND lugar.id_lugar=actividades.id_lugar AND fechas.fecha='".$row['fecha']."'";
$consulta_actividades=mysql_query($consulta_3);
while($recordset=mysql_fetch_array($consulta_actividades)){
?>
<tr>
<td width="116" height="30"><div align="left"><? echo $recordset['actividad']; ?></div></td>
<td width="80" height="30"><div align="center"><? echo $recordset['nombre']; ?></div></td>
<td width="85" height="30"><div align="center"><? echo $recordset['responsable']; ?></div></td>
<td width="66" height="30"><div align="center"><? echo $recordset['hora_inicio']. " - " .$recordset['hora_fin']; ?></div></td>
<td width="32" height="30"><span id="toolTipBox" width="200"></span><div align="center"><a href="javascript:abrirpopup('trasladar_fecha.php?id_act=<? echo $recordset['id_act'].'&id_fecha='.$recordset['id_fechas']; ?>',500,300)"> <img src="images/flecha123.gif" width="16" height="16" border="0" onMouseOver="toolTip('Trasladar de día esta actividad',this)"></a></div></td>
<td width="24" height="30"><span id="toolTipBox" width="200"></span> <div align="center"><a href="javascript:abrirpopup('detalle_actividad.php?id_act=<? echo $recordset['id_act']; ?>',500,500)"><img src="images/consultar.gif" width="16" height="16" border="0" onMouseOver="toolTip('Ver mas detalles relacionados con esta actividad',this)"></a></div></td>
<td width="24" height="30"><span id="toolTipBox" width="200"></span>
<div align="center"><img src="images/editar_small.gif" width="16" height="16" onMouseOver="toolTip('Editar',this)"></div></td>
<td width="32" height="30"><span id="toolTipBox" width="200"></span> <div align="center"><a href="javascript:abrirpopup('borrar_actividad.php?id_act=<? echo $recordset['id_act'].'&id_fecha='.$recordset['id_fechas']; ?>',500,300)"><img src="images/borrarv.gif" width="16" height="16" border="0" onMouseOver="toolTip('Borrar',this)"></a></div></td>
</tr>
<?
}
?>
</table>
<?
}
?>
<p> </p></td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="left"><a href="ver_actividades.php?mes=<? printf("%02d",$mes-1); ?>&anio=<? echo $anio ?>"><<
Mes Anterior</a></div></td>
<td><div align="center"><a href="ver_actividades.php?mes=<? echo date(m); ?>&anio=<? echo date(Y) ?>">Vista
segun hoy</a></div></td>
<td><div align="right"><a href="ver_actividades.php?mes=<? printf("%02d",$mes+1); ?>&anio=<? echo $anio ?>">Mes
Siguiente >></a></div></td>
</tr>
</table>
