Ver Mensaje Individual
  #16 (permalink)  
Antiguo 05/01/2010, 18:58
Avatar de masterojitos
masterojitos
 
Fecha de Ingreso: julio-2008
Ubicación: Lima Callao Chucuito
Mensajes: 1.931
Antigüedad: 16 años, 7 meses
Puntos: 105
Respuesta: Calendario php, ayuda porfavor

mira, hace tiempo, encontre un calendario, apartir de este codigo, podrias dar solucion al tuyo..... como dicen, estamos para resolver dudas o dar ayudas mas no para dar todo el trabajo ^^.

Solo ejecuta esto y veras el calendario (claro, pon las imagenes si quieres verlo mejor)
Código PHP:
Ver original
  1. <?php
  2. $tipo_semana = 1;
  3. $tipo_mes = 1;
  4.  
  5. $MESCOMPLETO[1] = 'Enero';
  6. $MESCOMPLETO[2] = 'Febrero';
  7. $MESCOMPLETO[3] = 'Marzo';
  8. $MESCOMPLETO[4] = 'Abril';
  9. $MESCOMPLETO[5] = 'Mayo';
  10. $MESCOMPLETO[6] = 'Junio';
  11. $MESCOMPLETO[7] = 'Julio';
  12. $MESCOMPLETO[8] = 'Agosto';
  13. $MESCOMPLETO[9] = 'Septiembre';
  14. $MESCOMPLETO[10] = 'Octubre';
  15. $MESCOMPLETO[11] = 'Noviembre';
  16. $MESCOMPLETO[12] = 'Diciembre';
  17.  
  18. $MESABREVIADO[1] = 'Ene';
  19. $MESABREVIADO[2] = 'Feb';
  20. $MESABREVIADO[3] = 'Mar';
  21. $MESABREVIADO[4] = 'Abr';
  22. $MESABREVIADO[5] = 'May';
  23. $MESABREVIADO[6] = 'Jun';
  24. $MESABREVIADO[7] = 'Jul';
  25. $MESABREVIADO[8] = 'Ago';
  26. $MESABREVIADO[9] = 'Sep';
  27. $MESABREVIADO[10] = 'Oct';
  28. $MESABREVIADO[11] = 'Nov';
  29. $MESABREVIADO[12] = 'Dic';
  30.  
  31. $SEMANACOMPLETA[0] = 'Domingo';
  32. $SEMANACOMPLETA[1] = 'Lunes';
  33. $SEMANACOMPLETA[2] = 'Martes';
  34. $SEMANACOMPLETA[3] = 'Miércoles';
  35. $SEMANACOMPLETA[4] = 'Jueves';
  36. $SEMANACOMPLETA[5] = 'Viernes';
  37. $SEMANACOMPLETA[6] = 'Sábado';
  38.  
  39. $SEMANAABREVIADA[0] = 'Dom';
  40. $SEMANAABREVIADA[1] = 'Lun';
  41. $SEMANAABREVIADA[2] = 'Mar';
  42. $SEMANAABREVIADA[3] = 'Mie';
  43. $SEMANAABREVIADA[4] = 'Jue';
  44. $SEMANAABREVIADA[5] = 'Vie';
  45. $SEMANAABREVIADA[6] = 'Sáb';
  46.  
  47. ////////////////////////////////////
  48. if($tipo_semana == 0){
  49. $ARRDIASSEMANA = $SEMANACOMPLETA;
  50. }elseif($tipo_semana == 1){
  51. $ARRDIASSEMANA = $SEMANAABREVIADA;
  52. }
  53. if($tipo_mes == 0){
  54. $ARRMES = $MESCOMPLETO;
  55. }elseif($tipo_mes == 1){
  56. $ARRMES = $MESABREVIADO;
  57. }
  58. $mes = $_REQUEST['mes'];
  59. $ano = $_REQUEST['ano'];
  60. if(!$dia) $dia = date(d);
  61. if(!$mes) $mes = date(n);
  62. if(!$ano) $ano = date(Y);
  63.  
  64. $TotalDiasMes = date(t,mktime(0,0,0,$mes,$dia,$ano));
  65. $DiaSemanaEmpiezaMes = date(w,mktime(0,0,0,$mes,1,$ano));
  66. $DiaSemanaTerminaMes = date(w,mktime(0,0,0,$mes,$TotalDiasMes,$ano));
  67. $EmpiezaMesCalOffset = $DiaSemanaEmpiezaMes;
  68. $TerminaMesCalOffset = 6 - $DiaSemanaTerminaMes;
  69. $TotalDeCeldas = $TotalDiasMes + $DiaSemanaEmpiezaMes + $TerminaMesCalOffset;
  70.  
  71.  
  72. if($mes == 1){
  73. $MesAnterior = 12;
  74. $MesSiguiente = $mes + 1;
  75. $AnoAnterior = $ano - 1;
  76. $AnoSiguiente = $ano;
  77. }elseif($mes == 12){
  78. $MesAnterior = $mes - 1;
  79. $MesSiguiente = 1;
  80. $AnoAnterior = $ano;
  81. $AnoSiguiente = $ano + 1;
  82. }else{
  83. $MesAnterior = $mes - 1;
  84. $MesSiguiente = $mes + 1;
  85. $AnoAnterior = $ano;
  86. $AnoSiguiente = $ano;
  87. $AnoAnteriorAno = $ano - 1;
  88. $AnoSiguienteAno = $ano + 1;
  89. }
  90.  
  91. print "<table style=\"font-family:arial;font-size:9px\" bordercolor=navy align=center border=0 cellpadding=1 cellspacing=1>";
  92. print " <tr>";
  93. print " <td colspan=10>";
  94. print " <table border=0 align=center width=\"1%\" style=\"font-family:arial;font-size:9px\">";
  95. print " <tr>";
  96. print " <td width=\"1%\"><a href=\"?mes=$mes&ano=$AnoAnteriorAno\"><img src=atras2.gif border=1></a></td>";
  97. print " <td width=\"1%\"><a href=\"?mes=$MesAnterior&ano=$AnoAnterior \"><img src=atras.gif border=1></a></td>";
  98. print " <td width=\"1%\" colspan=\"1\" align=\"center\" nowrap><b>".$ARRMES[$mes]." - $ano</b></td>";
  99. print " <td width=\"1%\"><a href=\"?mes=$MesSiguiente&ano=$AnoSiguiente\"><img src=avanzar.gif border=1></a></td>";
  100. print " <td width=\"1%\"><a href=\"?mes=$mes&ano=$AnoSiguienteAno\"><img src=avanzar2.gif border=1></a></td>";
  101. print " </tr>";
  102. print " </table>";
  103. print " </td>";
  104. print "</tr>";
  105. print "<tr>";
  106. foreach($ARRDIASSEMANA AS $key){
  107. print "<td bgcolor=#ccccff><b>$key</b></td>";
  108. }
  109. print "</tr>";
  110.  
  111. for($a=1;$a <= $TotalDeCeldas;$a++){
  112.     if(!$b) $b = 0;
  113.     if($b == 7) $b = 0;
  114.     if($b == 0) print '<tr>';
  115.     if(!$c) $c = 1;
  116.     if($a > $EmpiezaMesCalOffset AND $c <= $TotalDiasMes){
  117.         if($c == date(d) && $mes == date(m) && $ano == date(Y)){
  118.             print "<td bgcolor=\"#ffcc99\">$c<br></td>";
  119.         }elseif($b == 0 OR $b == 6){
  120.             print "<td bgcolor=#99cccc>$c</td>";
  121.         }else{
  122.             print "<td bgcolor=\"#EEEEEE\">$c</td>";
  123.         }
  124.         $c++;
  125.     }else{
  126.         print "<td> </td>";
  127.     }
  128.     if($b == 6) print '</tr>';
  129.     $b++;
  130. }
  131. print "<tr><td align=center colspan=10></a></td></tr>";
  132. print "</table>";
  133. ?>

Suerte.
__________________
Atte. MasterOjitos :ojotes:
Todo sobre Programación Web
Las ultimas tendencias en Efectos y Recursos Web: MasterOjitos Blog