Exemple #1
0
function get_festivos($anio)
{
    global $festivos;
    global $festivos_tmp;
    festivo_religioso(pascua($anio), 'Jueves Santo', 0);
    festivo_religioso(pascua($anio), 'Viernes Santo', 0);
    festivo_religioso(pascua($anio), 'Asension', 1);
    festivo_religioso(pascua($anio), 'Corpus Cristi', 1);
    festivo_religioso(pascua($anio), 'Sagrado Corazon', 1);
    for ($i = 1; $i <= 12; $i++) {
        $this_month = getDate(mktime(0, 0, 0, $i, 1, $anio));
        $next_month = getDate(mktime(0, 0, 0, $i + 1, 1, $anio));
        $days = round(($next_month[0] - $this_month[0]) / (60 * 60 * 24));
        for ($i_day = 1; $i_day <= $days; $i_day++) {
            $festivo = date("w", mktime(0, 0, 0, $i, $i_day, $anio));
            if ($festivo == 0 || $festivo == 6) {
                $festivo_month = $festivos[$i];
                array_push($festivo_month, $i_day);
                $festivos[$i] = $festivo_month;
            }
            $fiesta_tmp = $festivos_tmp[$i];
            foreach ($fiesta_tmp as $fiesta) {
                if ($fiesta == $i_day) {
                    $festivo_mov = date("w", mktime(0, 0, 0, $i, $i_day, $anio));
                    $festivo_month = $festivos[$i];
                    if ($festivo_mov != 1) {
                        $num = sig_lunes($festivo_mov);
                        $festivo_new = date("Y-m-d", mktime(0, 0, 0, $i, $i_day, $anio) + $num * 24 * 60 * 60);
                        list($f_anio, $f_mes, $f_dia) = parte_fecha($festivo_new);
                        if (substr($f_mes, 0, 1) == 0) {
                            $f_mes = substr($f_mes, 1, 2);
                        }
                        if (substr($f_dia, 0, 1) == 0) {
                            $f_dia = substr($f_dia, 1, 2);
                        }
                        $festivo_month = $festivos[$f_mes];
                        array_push($festivo_month, $f_dia);
                        $festivos[$f_mes] = $festivo_month;
                    } else {
                        array_push($festivo_month, $i_day);
                        $festivos[$i] = $festivo_month;
                    }
                }
            }
        }
    }
}
 function buscar_festivo($dia, $mes, $anno, $configuracion)
 {
     //Tipo
     //1:Fecha Fija
     //2:Lunes siguiente
     //3:Respecto a la Pascua Fijos
     //4:Respecto a la Pascua Lunes siguiente
     $pascua = pascua();
     $buscar = cadena_busqueda_calendario(1, $configuracion, $dia, $mes);
     //echo $buscar."<hr>";
     //echo $pascua["mes"];
     $nuestra_pascua = strtotime($pascua["mes"] . "/" . $pascua["dia"] . "/" . $anno);
     $esta_fecha = strtotime($mes . "/" . $dia . "/" . $anno);
     $acceso_db = new dbms($configuracion);
     $enlace = $acceso_db->conectar_db();
     if (is_resource($enlace)) {
         $acceso_db->registro_db($buscar, 0);
         $registro_festivo = $acceso_db->obtener_registro_db();
         $campos = $acceso_db->obtener_conteo_db();
     }
     if ($campos > 0) {
         if ($registro_festivo[0][0] == 2) {
             //Se corre al lunes siguiente.
             //Determinar el dia de la semana...
             $este_dia_semana = date("w", $esta_fecha);
             //echo $este_dia_semana;
             if ($este_dia_semana == 0) {
                 $suma = 1;
             } else {
                 if ($este_dia_semana == 1) {
                     $suma = 0;
                 } else {
                     $suma = 8 - $este_dia_semana;
                 }
             }
             $esta_fecha += $suma * 24 * 60 * 60;
             $el_dia = date("d", $esta_fecha);
             $el_mes = date("n", $esta_fecha);
             $el_anno = date("Y", $esta_fecha);
             $la_descripcion = $registro_festivo[0][3];
             if ($el_mes == $mes) {
                 $es_festivo["dia"] = $el_dia;
                 $es_festivo["descripcion"] = $la_descripcion;
                 $es_festivo["mes"] = $el_mes;
                 $es_festivo["anno"] = $el_anno;
                 return $es_festivo;
             } else {
                 return FALSE;
             }
         } else {
             $es_festivo["dia"] = $registro_festivo[0][1];
             $es_festivo["descripcion"] = $registro_festivo[0][3];
             $es_festivo["mes"] = $registro_festivo[0][2];
             $es_festivo["anno"] = $anno;
             return $es_festivo;
         }
     } else {
         if (date("d", $esta_fecha) == date("d", $nuestra_pascua + 43 * 24 * 60 * 60) && date("n", $esta_fecha) == date("n", $nuestra_pascua + 43 * 24 * 60 * 60)) {
             $es_festivo["descripcion"] = "Ascensi&oacute;n de Jes&uacute;s";
             $festivo = 1;
         } else {
             if (date("d", $esta_fecha) == date("d", $nuestra_pascua + 64 * 24 * 60 * 60) && date("n", $esta_fecha) == date("n", $nuestra_pascua + 64 * 24 * 60 * 60)) {
                 $es_festivo["descripcion"] = "Corpus Christi";
                 $festivo = 1;
             } else {
                 if (date("d", $esta_fecha) == date("d", $nuestra_pascua + 71 * 24 * 60 * 60) && date("n", $esta_fecha) == date("n", $nuestra_pascua + 71 * 24 * 60 * 60)) {
                     $es_festivo["descripcion"] = "Sagrado Coraz&oacute;n";
                     $festivo = 1;
                 } else {
                     if (date("d", $esta_fecha) == date("d", $nuestra_pascua - 3 * 24 * 60 * 60) && date("n", $esta_fecha) == date("n", $nuestra_pascua + -3 * 24 * 60 * 60)) {
                         $es_festivo["descripcion"] = "Viernes Santo";
                         $festivo = 1;
                     } else {
                         if (date("d", $esta_fecha) == date("d", $nuestra_pascua - 4 * 24 * 60 * 60) && date("n", $esta_fecha) == date("n", $nuestra_pascua - 4 * 24 * 60 * 60)) {
                             $es_festivo["descripcion"] = "Jueves Santo";
                             $festivo = 1;
                         } else {
                             $festivo = 0;
                         }
                     }
                 }
             }
         }
         if ($festivo == 1) {
             $este_dia_semana = date("w", $esta_fecha);
             if ($este_dia_semana == 0) {
                 $suma = 1;
             } else {
                 if ($este_dia_semana == 1) {
                     $suma = 0;
                 } else {
                     $suma = 8 - $este_dia_semana;
                 }
             }
             $esta_fecha += $suma;
             $el_dia = date("d", $esta_fecha);
             $el_mes = date("n", $esta_fecha);
             $el_anno = date("Y", $esta_fecha);
             $la_descripcion = $registro_festivo[0][3];
             if ($el_mes == $mes) {
                 $es_festivo["dia"] = $el_dia;
                 $es_festivo["descripcion"] = $la_descripcion;
                 $es_festivo["mes"] = $el_mes;
                 $es_festivo["anno"] = $el_anno;
                 return $es_festivo;
             } else {
                 return FALSE;
             }
         } else {
             return FALSE;
         }
     }
 }