From 14db6fe27f8ab18b20ddb87d7cb03ba5eabb0f34 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 19 Jun 2026 22:10:38 -0500 Subject: [PATCH] fix: PHP heredoc interpretaba template literals JS como constantes PHP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Convierte backtick template literals con \${it.id} a concatenación de strings - Fix query de chatConversations: GROUP BY solo por phone_number, evita duplicados Co-Authored-By: Claude Sonnet 4.6 --- admin/DashboardController.php | 37 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/admin/DashboardController.php b/admin/DashboardController.php index e4d3adb..ba5bba8 100644 --- a/admin/DashboardController.php +++ b/admin/DashboardController.php @@ -675,20 +675,21 @@ async function refreshDrawer() { body.innerHTML = '
✅ Sin pendientes
'; return; } - body.innerHTML = items.map(it => ` -
-
- ${esc(it.phone)} - ${esc(it.contact_name || '')} - ${(it.created_at||'').substr(11,5)} -
-
↩ ${esc(it.incoming_message || '')}
-
🤖 ${esc(getPreview(it.bot_response))}
-
- - -
-
`).join(''); + body.innerHTML = items.map(function(it) { + return '
' + + '
' + + '' + esc(it.phone) + '' + + '' + esc(it.contact_name || '') + '' + + '' + (it.created_at||'').substr(11,5) + '' + + '
' + + '
↩ ' + esc(it.incoming_message || '') + '
' + + '
🤖 ' + esc(getPreview(it.bot_response)) + '
' + + '
' + + '' + + '' + + '
' + + '
'; + }).join(''); } catch(e) { body.innerHTML = '
Error al cargar
'; } @@ -1939,12 +1940,14 @@ HTML; $db = db(); // Get unique conversations with last message and unread count $rows = $db->query(" - SELECT c.phone_number, c.contact_name, c.company_id, - MAX(c.created_at) as last_time, + SELECT c.phone_number, + MAX(c.contact_name) as contact_name, + MAX(c.company_id) as company_id, + MAX(c.created_at) as last_time, (SELECT content FROM conversations c2 WHERE c2.phone_number = c.phone_number ORDER BY c2.id DESC LIMIT 1) as last_message, (SELECT COUNT(*) FROM conversations c3 WHERE c3.phone_number = c.phone_number AND c3.direction = 'inbound' AND c3.id > COALESCE((SELECT MAX(c4.id) FROM conversations c4 WHERE c4.phone_number = c.phone_number AND c4.direction = 'outbound'), 0)) as unread_count FROM conversations c - GROUP BY c.phone_number, c.contact_name, c.company_id + GROUP BY c.phone_number ORDER BY last_time DESC ")->fetchAll();