Ver Mensaje Individual
  #4 (permalink)  
Antiguo 01/08/2012, 14:42
Avatar de Heiroon
Heiroon
 
Fecha de Ingreso: junio-2010
Ubicación: Caracas, Venezuela - Por ahora...
Mensajes: 495
Antigüedad: 13 años, 11 meses
Puntos: 63
De acuerdo Respuesta: Calendario Datepicker absulutamente en PHP

Oye GatorV, pues resulta que no era imposible...

Aca dejo como aporte un calendario totalmente en PHP el cual con unas cuantas modificaciones puede adaptarse a muchas necesidades..

Saludos y un aplauso para mi!

Código PHP:
Ver original
  1. <?
  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.  
  59. if(!$dia) $dia = date(d);
  60. if(!$mes) $mes = date(n);
  61. if(!$ano) $ano = date(Y);
  62.  
  63. $TotalDiasMes = date(t,mktime(0,0,0,$mes,$dia,$ano));
  64. $DiaSemanaEmpiezaMes = date(w,mktime(0,0,0,$mes,1,$ano));
  65. $DiaSemanaTerminaMes = date(w,mktime(0,0,0,$mes,$TotalDiasMes,$ano));
  66. $EmpiezaMesCalOffset = $DiaSemanaEmpiezaMes;
  67. $TerminaMesCalOffset = 6 - $DiaSemanaTerminaMes;
  68. $TotalDeCeldas = $TotalDiasMes + $DiaSemanaEmpiezaMes + $TerminaMesCalOffset;
  69.  
  70.  
  71. if($mes == 1){
  72. $MesAnterior = 12;
  73. $MesSiguiente = $mes + 1;
  74. $AnoAnterior = $ano - 1;
  75. $AnoSiguiente = $ano;
  76. }elseif($mes == 12){
  77. $MesAnterior = $mes - 1;
  78. $MesSiguiente = 1;
  79. $AnoAnterior = $ano;
  80. $AnoSiguiente = $ano + 1;
  81. }else{
  82. $MesAnterior = $mes - 1;
  83. $MesSiguiente = $mes + 1;
  84. $AnoAnterior = $ano;
  85. $AnoSiguiente = $ano;
  86. $AnoAnteriorAno = $ano - 1;
  87. $AnoSiguienteAno = $ano + 1;
  88. }
  89.  
  90. print "<table style=\"font-family:arial;font-size:9px\" bordercolor=navy align=center border=0 cellpadding=1 cellspacing=1>";
  91. print " <tr>";
  92. print " <td colspan=10>";
  93. print " <table border=0 align=center width=\"1%\" style=\"font-family:arial;font-size:9px\">";
  94. print " <tr>";
  95. print " <td width=\"1%\"><a href=\"$PHP_SELF?mes=$mes&ano=$AnoAnteriorAno\"><i mg src=atras2.gif border=0></a></td>";
  96. print " <td width=\"1%\"><a href=\"$PHP_SELF?mes=$MesAnterior&ano=$AnoAnterior \"><img src=atras.gif border=0></a></td>";
  97. print " <td width=\"1%\" colspan=\"1\" align=\"center\" nowrap><b>".$ARRMES[$mes]." - $ano</b></td>";
  98. print " <td width=\"1%\"><a href=\"$PHP_SELF?mes=$MesSiguiente&ano=$AnoSiguien te\"><img src=avanzar.gif border=0></a></td>";
  99. print " <td width=\"1%\"><a href=\"$PHP_SELF?mes=$mes&ano=$AnoSiguienteAno\">< img src=avanzar2.gif border=0></a></td>";
  100. print " </tr>";
  101. print " </table>";
  102. print " </td>";
  103. print "</tr>";
  104. print "<tr>";
  105. foreach($ARRDIASSEMANA AS $key){
  106. print "<td bgcolor=#ccccff><b>$key</b></td>";
  107. }
  108. print "</tr>";
  109.  
  110. for($a=1;$a <= $TotalDeCeldas;$a++){
  111. if(!$b) $b = 0;
  112. if($b == 7) $b = 0;
  113. if($b == 0) print '<tr>';
  114. if(!$c) $c = 1;
  115. if($a > $EmpiezaMesCalOffset AND $c <= $TotalDiasMes){
  116. if($c == date(d) && $mes == date(m) && $ano == date(Y)){
  117. print "<td bgcolor=\"#ffcc99\">$c<br></td>";
  118. }elseif($b == 0 OR $b == 6){
  119. print "<td bgcolor=#99cccc>$c</td>";
  120. }else{
  121. print "<td bgcolor=\"#EEEEEE\">$c</td>";
  122. }
  123. $c++;
  124. }else{
  125. print "<td> </td>";
  126. }
  127. if($b == 6) print '</tr>';
  128. $b++;
  129. }
  130. print "<tr><td align=center colspan=10></a></td></tr>";
  131. print "</table>";
  132. ?>

No pongo karma negativo porque de verdad me exprese mal al decir q solo php y q no incluyera HTML y CSS... Saludos!
__________________
Gmail : [email protected]
Twitter: @heiroon

I'm back!