Buenas tardes miren me esplico estoy trabajando en un calendario de eventos ya esta terminado pero tengo un problema con las fechas que pasan de un mes a otro ejemplo si un evento esta con fecha de inicio el 2011-06-03 y fecha de termino el 2011-07-03 no me muestra el evento y si las fechas son el mismo mes me funciona super aca dejo el codigo para ver si alguno ne puede dar una idea desde ya gracias.
Calendario.php
Código PHP:
Ver original<?
include_once("Eventos.php");
function existeEvento($monthNo, $ano, $dia)
{
//nombre
$clEvento = new Eventos();
$resEvento = $clEvento->obtenerEvento($monthNo, $ano, $dia);
$resEvento2 = $clEvento->obtenerEvento2($monthNo, $ano, $dia);
if(count($resEvento) > 0) {
echo "<td class='event'>$dia<br>";
foreach($resEvento as $campo)
{
?>
<div style="margin-left: 5px;">
<img src='images/iconos/mas.gif'/>
<a class="busquedasPopulares" href="verEvento.php?Ev=<?=$campo["idEvento"];?>&TB_iframe=true&height=450&width=800" rel="sexylightbox[22]" title="Evento: [<em><?=$campo["nombre"];?>.</em>]"><?=$campo["nombre"];?></a>
</div><br/>
<?
}
echo " </td>";
return true;
}else
return false;
}
function mes($mes)
{
if ($mes=="January") $mes="Enero";
if ($mes=="February") $mes="Febrero";
if ($mes=="March") $mes="Marzo";
if ($mes=="April") $mes="Abril";
if ($mes=="May") $mes="Mayo";
if ($mes=="June") $mes="Junio";
if ($mes=="July") $mes="Julio";
if ($mes=="August") $mes="Agosto";
if ($mes=="September") $mes="Setiembre";
if ($mes=="October") $mes="Octubre";
if ($mes=="November") $mes="Noviembre";
if ($mes=="December") $mes="Diciembre";
return $mes;
}
$xmlFile = "calendario/calendar.xml";
if (!isset($_GET['year'])) { }
else {
$year = $_GET['year'];
}
if (!isset($_GET['monthNo'])) { }
else {
$monthNo = $_GET['monthNo'];
}
$monthName = date(F
, mktime(0, 0, 0, $monthNo, 1, $year)); $daysInMonth = date(t
, mktime(0, 0, 0, $monthNo, 1, $year)); $i = 0;
$lookForMonth = 0;
$getDays = 0;
while ($i < count($values)) { if ($getDays && $values[$i][tag] == $monthName) {
break;
}
if ($values[$i][tag] == "Y$year" && $values[$i][type] == "open") {
$lookForMonth = 1;
}
if ($getDays) {
$day = $values[$i][tag];
$event[$day] = $values[$i][value];
}
if ($lookForMonth && $values[$i][tag] == $monthName) {
$getDays = 1;
}
$i++;
}
echo "<html>\n\n";
echo "<head>\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"calendario/calendar.css\">\n";
echo "</head>\n\n";
echo "<body>\n";
echo "<a name=\"tg\" id=\"a\"></a>";
echo "<table align=\"center\" class=\"calendario\">\n";
echo "<caption class=\"calendario\">Calendario de ".mes($monthName)." $year</caption>\n";
echo "<tr>\n";
echo "\t<th class=\"calendario\">Domingo</th>\n";
echo "\t<th class=\"calendario\">Lunes</th>\n";
echo "\t<th class=\"calendario\">Martes</th>\n";
echo "\t<th class=\"calendario\">MIercoles</th>\n";
echo "\t<th class=\"calendario\">Jueves</th>\n";
echo "\t<th class=\"calendario\">Viernes</th>\n";
echo "\t<th class=\"calendario\">Sabado</th>\n";
echo "</tr>\n";
for ($dayNo = 1; $dayNo <= $daysInMonth; $dayNo++) {
$dayName = date(D
, mktime(0, 0, 0, $monthNo, $dayNo, $year)); if ($dayNo == 1 && $dayName != "Sun") {
echo "<tr class=\"calendario\">\n";
$dayOfWeek = date(w
, mktime(0, 0, 0, $monthNo, $dayNo, $year)); for ($i = 0; $i < $dayOfWeek; $i++) {
echo "\t<td class=\"calendario\" style=\"background-color: #E8E8E8\"> </td>\n";
}
}
if ($dayName == "Sun") {
echo "<tr class=\"calendario\">\n";
}
if(existeEvento($monthNo, $year, $dayNo))
{
}
else {
echo "\t<td class=\"calendario\"><b>$dayNo</b>";
?>
<?
echo "\t</td>\n";
}
if ($dayName == "Sat") {
echo "</tr>\n";
}
if ($dayNo == $daysInMonth && $dayName != "Sat") {
$dayOfWeek = date(w
, mktime(0, 0, 0, $monthNo, $dayNo, $year)); for ($i = 6; $i > $dayOfWeek; $i--) {
echo "\t<td class=\"calendario\" style=\"background-color: #E8E8E8\"> </td>\n";
}
echo "</tr>\n";
}
}
echo "</td></tr>";
echo "</table>\n";
echo "</body>\n\n";
echo "</html>";
echo "<table align=\"center\" class=\"calendario\">\n";
echo "<tr>\n";
echo "\t<th class=\"calendario\" style=\"background-color: #E8E8E8\" colspan=2><div align=center>\n";
$prevMonth = $monthNo - 1;
if ($prevMonth == 0) {
$prevMonth = 12;
$prevYear = $year - 1;
}
else {
$prevYear = $year;
}
$nextMonth = $monthNo + 1;
if ($nextMonth == 13) {
$nextMonth = 1;
$nextYear = $year + 1;
}
else {
$nextYear = $year;
}
$prevYear1= $year - 1;
$nextYear1= $year + 1;
$prevMonthName = date(F
, mktime(0, 0, 0, $prevMonth, 1, $prevYear)); $nextMonthName = date(F
, mktime(0, 0, 0, $nextMonth, 1, $nextYear)); echo "<h3><p> <a href=\"?year=$prevYear&monthNo=$prevMonth#tg\"><img src=images/flechaDerecha.gif border=0/> ".mes($prevMonthName)."</a> ".mes($monthName)." <a href=\"?year=$nextYear&monthNo=$nextMonth#tg\">".mes($nextMonthName)." <img src=images/flechaIquierda.gif border=0/></a> </p></h3>\n</th>\n";
echo "\t<th class=\"calendario\" style=\"background-color: #E8E8E8\"> <html><head>
<strong>
<script language=Javascript>
var meses = new Array ('Enero','Febrero','Marzo','Abril','Mayo','Junio','julio','Agos.','Sept.','Octu.','Nobi.','Dici.');
var diasSemana = new Array('Domi.','Lunes','Mart.','Miér.','Juev.','Vier.','Sába.');
var f=new Date();
document.write(diasSemana[f.getDay()] + ' ' + f.getDate() + ' de ' + meses[f.getMonth()] + ' del ' + f.getFullYear());
</script>
</strong>
</head><body></body> </html></th>\n";
echo "\t<th class=\"calendario\" style=\"background-color: #E8E8E8\" colspan=2>
<div align=center ><h3><p> <a href=\"?year=$prevYear1#tg\"><img src=images/flechaDerecha.gif border=0/> ".$prevYear1."</a> ".$year." <a href=\"?year=$nextYear1#tg\">".$nextYear1." <img src=images/flechaIquierda.gif border=0/> </a></h3><div></th>\n";
echo "</tr>\n";
?>
la consulta para traer loseventos de mysql
Eventos.php
Código PHP:
Ver originalfunction obtenerEvento($monthNo, $ano, $dia)
{
$this->InciarConexion();
//select * from eventos where fechaIncio >= '$hoy' AND fechaTermino <= '$hoy'
$Consulta = " SELECT * ";
$Consulta .= " FROM eventos ";
$Consulta .= " WHERE year( fecha) <= $ano AND year( fechatermino) >= $ano ";
$Consulta .= " AND month( fecha) <= $monthNo AND month( fechatermino) >= $monthNo";
$Consulta .= " AND day( fecha) <= $dia AND day( fechatermino) >= $dia ";
echo $Consulta;
if($this->EstadoDelaConexion())
{
$ResConsulta = $this->consultar($Consulta);
$this->cerrar_conexion ();
return $ResConsulta;
}
}
function obtenerEvento2($ano, $monthNo, $dia)
{
$this->InciarConexion();
$Consulta = " SELECT * ";
$Consulta .= " FROM eventos ";
$Consulta .= " WHERE year( fechatermino ) = $ano ";
$Consulta .= " AND month( fechatermino ) = $monthNo ";
$Consulta .= " AND day( fechatermino ) = $dia ";
//echo $mes;
if($this->EstadoDelaConexion())
{
$ResConsulta = $this->consultar($Consulta);
$this->cerrar_conexion ();
return $ResConsulta;
}
}