diff --git a/modules/turnero/views/chat.php b/modules/turnero/views/chat.php index 77e3acc..0497839 100644 --- a/modules/turnero/views/chat.php +++ b/modules/turnero/views/chat.php @@ -9,6 +9,22 @@ require_once __DIR__ . '/../../../config/config.php'; if (!isUserLoggedIn()) { header('Location: ' . BASE_URL . 'login.php'); exit; } $turneroPhoneId = getConfigFromDB('whatsapp_phone_number_id_turnero', ''); + +// Determinar URL de regreso según IP del cliente +$_chatBackUrl = BASE_URL . 'erp.php?m=turnero&v=dashboard'; +try { + $pdo = Database::getInstance()->getConnection(); + $st = $pdo->prepare( + "SELECT d.lugar_id FROM turnero_dispositivos d + JOIN turnero_lugares l ON l.id = d.lugar_id + WHERE d.ip = ? AND d.activo = 1 AND l.tipo = 'recepcion' LIMIT 1" + ); + $st->execute([$_SERVER['REMOTE_ADDR'] ?? '']); + $deskId = $st->fetchColumn(); + if ($deskId) { + $_chatBackUrl = BASE_URL . 'erp.php?m=turnero&v=recepcion&desk_id=' . (int)$deskId; + } +} catch (\Throwable $_) {} ?> @@ -319,7 +335,7 @@ html, body { height: 100%; overflow: hidden; font-family: -apple-system, BlinkMa