"Enero",
2 => "Febrero",
3 => "Marzo",
4 => "Abril",
5 => "Mayo",
6 => "Junio",
7 => "Julio",
8 => "Agosto",
9 => "Septiembre",
10 => "Octubre",
11 => "Noviembre",
12 => "Diciembre"
];
$dow = [
1 => "Lunes",
2 => "Martes",
3 => "Miércoles",
4 => "Jueves",
5 => "Viernes",
6 => "Sábado",
7 => "Domingo"
];
$month = $_GET['month'] ?? date('n');
$year = $_GET['year'] ?? date('Y');
$MENUTY = $_GET['menu'] ?? "basal";
$parsedTable = null;
function getMenuForDay(string $pageText, string $day)
{
global $parsedTable;
// ---------------------------------------------
// 1. Parse table only once
// ---------------------------------------------
if ($parsedTable === null) {
$lines = preg_split("/\R/", $pageText);
$rows = [];
foreach ($lines as $line) {
$trim = trim($line);
// Only lines that start with "|" and are table rows
if (strpos($trim, "|") === 0 && substr($trim, -1) === "|") {
// Remove leading and trailing |, then split
$cols = explode("|", trim($trim, "|"));
$cols = array_map("trim", $cols);
if (count($cols) >= 4) {
$rows[] = [
"fecha" => $cols[0],
"plato1" => $cols[1],
"plato2" => $cols[2],
"postre" => $cols[3]
];
}
}
}
$parsedTable = $rows; // store result (parsed only once)
}
// ---------------------------------------------
// 2. Look for the requested date
// ---------------------------------------------
foreach ($parsedTable as $row) {
if ($row["fecha"] === $day) {
return $row;
}
}
return null; // not found
}
$MENUDATA = file_get_contents("https://aularios.tech.eus/aldamiz_ortuella/menu_comedor/tabla/$MENUTY?do=export_raw");
// Solo semana actual, botones. cuando se pulse el botón del dia actual, se enviara un POST ?form=menu con los valores del menu
$weeknow = date('W');
?>
Menú del Comedor
5) {
continue; // Skip weekends
}
if ($weekofmonth != $weeknow) {
continue; // Only current week
}
$menuForDay = getMenuForDay($MENUDATA, $dateStr);
if ($menuForDay === null) {
continue; // No menu for this day
}
?>
Calendario
Aquí podrás ver y gestionar el calendario de actividades del aulario.
5) {
?>
Calendario - Día de la Semana
Has seleccionado el día correcto. ¡Ahora pon el dia de la semana!