up
This commit is contained in:
+36
-13
@@ -63,19 +63,38 @@ try {
|
|||||||
error_log("Estructura tabla menus: " . json_encode($tableStructure));
|
error_log("Estructura tabla menus: " . json_encode($tableStructure));
|
||||||
|
|
||||||
// Consulta adaptada a la estructura real de la tabla existente
|
// Consulta adaptada a la estructura real de la tabla existente
|
||||||
$menusQuery = "SELECT
|
// Incluir menu_type solo si la columna existe (migración puede no haberse ejecutado)
|
||||||
id,
|
$hasMenuType = !empty($db->fetchAll("SHOW COLUMNS FROM menus LIKE 'menu_type'"));
|
||||||
name,
|
if ($hasMenuType) {
|
||||||
title,
|
$menusQuery = "SELECT
|
||||||
description,
|
id,
|
||||||
welcome_message,
|
name,
|
||||||
parent_id,
|
title,
|
||||||
is_root,
|
description,
|
||||||
is_active,
|
welcome_message,
|
||||||
order_position,
|
parent_id,
|
||||||
created_at,
|
is_root,
|
||||||
updated_at
|
is_active,
|
||||||
FROM menus ORDER BY order_position ASC, id ASC";
|
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);
|
$menus = $db->fetchAll($menusQuery);
|
||||||
|
|
||||||
error_log("Menús obtenidos: " . count($menus) . " registros");
|
error_log("Menús obtenidos: " . count($menus) . " registros");
|
||||||
@@ -90,6 +109,10 @@ try {
|
|||||||
if (!isset($menu['welcome_message'])) {
|
if (!isset($menu['welcome_message'])) {
|
||||||
$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));
|
error_log("Menús encontrados: " . count($menus));
|
||||||
|
|||||||
@@ -1066,7 +1066,10 @@ class SimpleWhatsAppManager {
|
|||||||
<td><strong>${menu.name || menu.menu_name}</strong></td>
|
<td><strong>${menu.name || menu.menu_name}</strong></td>
|
||||||
<td><code>${menu.menu_key || menu.trigger}</code></td>
|
<td><code>${menu.menu_key || menu.trigger}</code></td>
|
||||||
<td>${this.truncateText(menu.description || '', 50)}</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>${menu.options_count || 0} opciones</td>
|
||||||
<td>${formatDate}</td>
|
<td>${formatDate}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user