This commit is contained in:
Lizandro Guarnizo
2026-05-27 11:44:07 -05:00
parent 313e57aace
commit b8de9ee666
2 changed files with 40 additions and 14 deletions
+36 -13
View File
@@ -63,19 +63,38 @@ try {
error_log("Estructura tabla menus: " . json_encode($tableStructure));
// Consulta adaptada a la estructura real de la tabla existente
$menusQuery = "SELECT
id,
name,
title,
description,
welcome_message,
parent_id,
is_root,
is_active,
order_position,
created_at,
updated_at
FROM menus ORDER BY order_position ASC, id ASC";
// Incluir menu_type solo si la columna existe (migración puede no haberse ejecutado)
$hasMenuType = !empty($db->fetchAll("SHOW COLUMNS FROM menus LIKE 'menu_type'"));
if ($hasMenuType) {
$menusQuery = "SELECT
id,
name,
title,
description,
welcome_message,
parent_id,
is_root,
is_active,
order_position,
created_at,
updated_at,
menu_type
FROM menus ORDER BY order_position ASC, id ASC";
} else {
$menusQuery = "SELECT
id,
name,
title,
description,
welcome_message,
parent_id,
is_root,
is_active,
order_position,
created_at,
updated_at
FROM menus ORDER BY order_position ASC, id ASC";
}
$menus = $db->fetchAll($menusQuery);
error_log("Menús obtenidos: " . count($menus) . " registros");
@@ -90,6 +109,10 @@ try {
if (!isset($menu['welcome_message'])) {
$menu['welcome_message'] = '';
}
// menu_type: garantizar que siempre exista el campo
if (!isset($menu['menu_type'])) {
$menu['menu_type'] = 'main';
}
}
error_log("Menús encontrados: " . count($menus));
+4 -1
View File
@@ -1066,7 +1066,10 @@ class SimpleWhatsAppManager {
<td><strong>${menu.name || menu.menu_name}</strong></td>
<td><code>${menu.menu_key || menu.trigger}</code></td>
<td>${this.truncateText(menu.description || '', 50)}</td>
<td><span class="badge bg-${menu.status === 'active' ? 'success' : 'secondary'}">${menu.status || 'active'}</span></td>
<td>
<span class="badge bg-${menu.status === 'active' ? 'success' : 'secondary'}">${menu.status || 'active'}</span>
${(menu.menu_type || 'main') === 'no_advisor' ? '<br><span class="badge bg-danger mt-1">🔴 Asesor ausente</span>' : ''}
</td>
<td>${menu.options_count || 0} opciones</td>
<td>${formatDate}</td>
<td>