Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/06/2011, 14:21
Rasec101
 
Fecha de Ingreso: diciembre-2009
Ubicación: Santiago, Chile
Mensajes: 143
Antigüedad: 14 años, 5 meses
Puntos: 2
problema con calendario de eventos

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
  1. <?
  2.     include_once("Eventos.php");
  3.    
  4.    
  5.  function existeEvento($monthNo, $ano, $dia)
  6.  {
  7.     //nombre
  8.     $clEvento = new Eventos();
  9.     $resEvento = $clEvento->obtenerEvento($monthNo, $ano, $dia);
  10.     $resEvento2 = $clEvento->obtenerEvento2($monthNo, $ano, $dia);
  11.     if(count($resEvento) > 0)
  12.     {
  13.         echo "<td class='event'>$dia<br>";
  14.         foreach($resEvento as $campo)
  15.         {
  16.             ?>
  17.        
  18.            <div style="margin-left: 5px;">
  19.                 <img src='images/iconos/mas.gif'/>
  20.                 <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>
  21.             </div><br/>
  22.             <?
  23.         }
  24.         echo " </td>";
  25.         return true;    
  26.     }else
  27.         return false;
  28.  }
  29.  
  30.  function mes($mes)
  31.  {
  32.     if ($mes=="January") $mes="Enero";
  33.     if ($mes=="February") $mes="Febrero";
  34.     if ($mes=="March") $mes="Marzo";
  35.     if ($mes=="April") $mes="Abril";
  36.     if ($mes=="May") $mes="Mayo";
  37.     if ($mes=="June") $mes="Junio";
  38.     if ($mes=="July") $mes="Julio";
  39.     if ($mes=="August") $mes="Agosto";
  40.     if ($mes=="September") $mes="Setiembre";
  41.     if ($mes=="October") $mes="Octubre";
  42.     if ($mes=="November") $mes="Noviembre";
  43.     if ($mes=="December") $mes="Diciembre";
  44.     return  $mes;
  45.  }
  46. $xmlFile = "calendario/calendar.xml";
  47. if (!isset($_GET['year'])) {
  48.     $year = date(Y);
  49. }
  50. else {
  51.     $year = $_GET['year'];
  52. }
  53. if (!isset($_GET['monthNo'])) {
  54.     $monthNo = date(n);
  55. }
  56. else {
  57.     $monthNo = $_GET['monthNo'];
  58. }
  59. $monthName = date(F, mktime(0, 0, 0, $monthNo, 1, $year));
  60. $daysInMonth = date(t, mktime(0, 0, 0, $monthNo, 1, $year));
  61. $data = implode("", file($xmlFile));
  62. $parser = xml_parser_create();
  63. xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
  64. xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
  65. xml_parse_into_struct($parser, $data, $values, $tags);
  66. xml_parser_free($parser);
  67. $i = 0;
  68. $lookForMonth = 0;
  69. $getDays = 0;
  70. while ($i < count($values)) {
  71.     if ($getDays && $values[$i][tag] == $monthName) {
  72.         break;
  73.     }
  74.     if ($values[$i][tag] == "Y$year" && $values[$i][type] == "open") {
  75.         $lookForMonth = 1;
  76.     }
  77.     if ($getDays) {
  78.         $day = $values[$i][tag];
  79.         $day = substr($day, 1);
  80.         $event[$day] = $values[$i][value];
  81.     }
  82.     if ($lookForMonth && $values[$i][tag] == $monthName) {
  83.         $getDays = 1;
  84.     }
  85.     $i++;
  86. }
  87. echo "<html>\n\n";
  88. echo "<head>\n";
  89. echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"calendario/calendar.css\">\n";
  90. echo "</head>\n\n";
  91. echo "<body>\n";
  92. echo "<a name=\"tg\" id=\"a\"></a>";
  93. echo "<table align=\"center\" class=\"calendario\">\n";
  94. echo "<caption class=\"calendario\">Calendario de ".mes($monthName)." $year</caption>\n";
  95. echo "<tr>\n";
  96. echo "\t<th class=\"calendario\">Domingo</th>\n";
  97. echo "\t<th class=\"calendario\">Lunes</th>\n";
  98. echo "\t<th class=\"calendario\">Martes</th>\n";
  99. echo "\t<th class=\"calendario\">MIercoles</th>\n";
  100. echo "\t<th class=\"calendario\">Jueves</th>\n";
  101. echo "\t<th class=\"calendario\">Viernes</th>\n";
  102. echo "\t<th class=\"calendario\">Sabado</th>\n";
  103. echo "</tr>\n";
  104. for ($dayNo = 1; $dayNo <= $daysInMonth; $dayNo++) {
  105.     $dayName = date(D, mktime(0, 0, 0, $monthNo, $dayNo, $year));
  106.     if ($dayNo == 1 && $dayName != "Sun") {
  107.         echo "<tr class=\"calendario\">\n";
  108.         $dayOfWeek = date(w, mktime(0, 0, 0, $monthNo, $dayNo, $year));
  109.         for ($i = 0; $i < $dayOfWeek; $i++) {
  110.             echo "\t<td class=\"calendario\"  style=\"background-color: #E8E8E8\">&nbsp;</td>\n";
  111.         }
  112.     }
  113.     if ($dayName == "Sun") {
  114.         echo "<tr class=\"calendario\">\n";
  115.     }
  116.     if(existeEvento($monthNo, $year, $dayNo))
  117.     {
  118.     }
  119.     else {
  120.         echo "\t<td class=\"calendario\"><b>$dayNo</b>";
  121.        
  122.        
  123. ?>
  124.        
  125. <?        
  126.         echo "\t</td>\n";
  127.     }
  128.     if ($dayName == "Sat") {
  129.         echo "</tr>\n";
  130.     }
  131.     if ($dayNo == $daysInMonth && $dayName != "Sat") {
  132.         $dayOfWeek = date(w, mktime(0, 0, 0, $monthNo, $dayNo, $year));
  133.         for ($i = 6; $i > $dayOfWeek; $i--) {
  134.             echo "\t<td class=\"calendario\" style=\"background-color: #E8E8E8\">&nbsp;</td>\n";
  135.         }
  136.         echo "</tr>\n";
  137.     }
  138. }
  139. echo "</td></tr>";
  140. echo "</table>\n";
  141. echo "</body>\n\n";
  142. echo "</html>";
  143. echo "<table align=\"center\" class=\"calendario\">\n";
  144. echo "<tr>\n";
  145. echo "\t<th class=\"calendario\" style=\"background-color: #E8E8E8\" colspan=2><div align=center>\n";
  146. $prevMonth = $monthNo - 1;
  147. if ($prevMonth == 0) {
  148.     $prevMonth = 12;
  149.     $prevYear = $year - 1;
  150. }
  151. else {
  152.     $prevYear = $year;
  153. }
  154. $nextMonth = $monthNo + 1;
  155. if ($nextMonth == 13) {
  156.     $nextMonth = 1;
  157.     $nextYear = $year + 1;
  158. }
  159. else {
  160.     $nextYear = $year;
  161. }
  162. $prevYear1= $year - 1;
  163. $nextYear1= $year + 1;
  164. $prevMonthName = date(F, mktime(0, 0, 0, $prevMonth, 1, $prevYear));
  165. $nextMonthName = date(F, mktime(0, 0, 0, $nextMonth, 1, $nextYear));
  166. echo "<h3><p> <a href=\"?year=$prevYear&monthNo=$prevMonth#tg\"><img src=images/flechaDerecha.gif border=0/>&nbsp;".mes($prevMonthName)."</a>&nbsp;&nbsp; ".mes($monthName)."&nbsp;&nbsp; <a href=\"?year=$nextYear&monthNo=$nextMonth#tg\">".mes($nextMonthName)."&nbsp;<img src=images/flechaIquierda.gif border=0/></a> </p></h3>\n</th>\n";
  167. echo "\t<th class=\"calendario\" style=\"background-color: #E8E8E8\"> <html><head>
  168. <strong>
  169. <script language=Javascript>
  170. var meses = new Array ('Enero','Febrero','Marzo','Abril','Mayo','Junio','julio','Agos.','Sept.','Octu.','Nobi.','Dici.');
  171. var diasSemana = new Array('Domi.','Lunes','Mart.','Miér.','Juev.','Vier.','Sába.');
  172. var f=new Date();
  173. document.write(diasSemana[f.getDay()] + ' ' + f.getDate() + ' de ' + meses[f.getMonth()] + ' del ' + f.getFullYear());
  174. </script>
  175. </strong>
  176. </head><body></body> </html></th>\n";
  177. echo "\t<th class=\"calendario\" style=\"background-color: #E8E8E8\" colspan=2>
  178. <div align=center ><h3><p> <a href=\"?year=$prevYear1#tg\"><img src=images/flechaDerecha.gif border=0/>&nbsp; ".$prevYear1."</a> ".$year." <a href=\"?year=$nextYear1#tg\">".$nextYear1."&nbsp;<img src=images/flechaIquierda.gif border=0/> </a></h3><div></th>\n";
  179. echo "</tr>\n";
  180. ?>
la consulta para traer loseventos de mysql
Eventos.php
Código PHP:
Ver original
  1. function obtenerEvento($monthNo, $ano, $dia)
  2.     {
  3.         $this->InciarConexion();
  4.         //select * from eventos where fechaIncio >= '$hoy' AND fechaTermino <= '$hoy'
  5.         $Consulta  = " SELECT * ";
  6.         $Consulta .= " FROM eventos  ";
  7.         $Consulta .= " WHERE year( fecha) <= $ano AND year( fechatermino) >= $ano ";
  8.         $Consulta .= " AND month( fecha)  <= $monthNo AND month( fechatermino)  >= $monthNo";
  9.         $Consulta .= " AND day( fecha)  <= $dia AND day( fechatermino)  >= $dia ";
  10.        
  11.         echo $Consulta;
  12.         if($this->EstadoDelaConexion())
  13.         {
  14.           $ResConsulta = $this->consultar($Consulta);
  15.           $this->cerrar_conexion ();
  16.           return $ResConsulta;
  17.         }
  18.     }
  19.    
  20.    
  21.         function obtenerEvento2($ano, $monthNo, $dia)
  22.     {
  23.         $this->InciarConexion();
  24.         $Consulta  = " SELECT * ";
  25.         $Consulta .= " FROM eventos  ";
  26.         $Consulta .= " WHERE year( fechatermino ) = $ano ";
  27.         $Consulta .= " AND month( fechatermino )  = $monthNo ";
  28.         $Consulta .= " AND day( fechatermino )  = $dia ";
  29.         //echo $mes;
  30.         if($this->EstadoDelaConexion())
  31.         {
  32.           $ResConsulta = $this->consultar($Consulta);
  33.           $this->cerrar_conexion ();
  34.           return $ResConsulta;
  35.         }
  36.     }