diff --git a/api/menu/getForBuilder.cfm b/api/menu/getForBuilder.cfm
index 0b29468..fb8534d 100644
--- a/api/menu/getForBuilder.cfm
+++ b/api/menu/getForBuilder.cfm
@@ -82,6 +82,40 @@ try {
"MenuSortOrder": qMenus.MenuSortOrder[m]
});
}
+
+ // Auto-select menu based on current time when no specific menu requested
+ if (menuID == 0 && qMenus.recordCount > 1) {
+ now = timeFormat(now(), "HH:mm");
+ dayOfWeek = dayOfWeek(now()); // 1=Sun, 2=Mon, ... 7=Sat
+ dayBit = 2 ^ (dayOfWeek - 1); // bitmask: 1=Sun, 2=Mon, 4=Tue, etc.
+ activeMenuIds = [];
+
+ for (m = 1; m <= qMenus.recordCount; m++) {
+ // Check if menu is active today (days bitmask)
+ menuDays = qMenus.MenuDaysActive[m];
+ if (bitAnd(menuDays, dayBit) == 0) continue;
+
+ // Check time range
+ hasStart = !isNull(qMenus.MenuStartTime[m]);
+ hasEnd = !isNull(qMenus.MenuEndTime[m]);
+ if (hasStart && hasEnd) {
+ startT = timeFormat(qMenus.MenuStartTime[m], "HH:mm");
+ endT = timeFormat(qMenus.MenuEndTime[m], "HH:mm");
+ if (now >= startT && now <= endT) {
+ arrayAppend(activeMenuIds, qMenus.MenuID[m]);
+ }
+ } else {
+ // No time restriction = always active
+ arrayAppend(activeMenuIds, qMenus.MenuID[m]);
+ }
+ }
+
+ // If exactly one menu is active now, auto-select it
+ if (arrayLen(activeMenuIds) == 1) {
+ menuID = activeMenuIds[1];
+ }
+ // If multiple match (overlap) or none match, show all (menuID stays 0)
+ }
} catch (any e) {
// Menus table might not exist yet
}
diff --git a/portal/menu-builder.html b/portal/menu-builder.html
index 5001758..9700f81 100644
--- a/portal/menu-builder.html
+++ b/portal/menu-builder.html
@@ -3343,7 +3343,7 @@
const selector = document.getElementById('menuSelector');
if (!selector) return;
- let options = '';
+ let options = '';
for (const menu of this.menus) {
const selected = menu.MenuID === this.selectedMenuId ? 'selected' : '';
options += ``;