diff --git a/api/upload_media.php b/api/upload_media.php index adc81aa..e4c7244 100644 --- a/api/upload_media.php +++ b/api/upload_media.php @@ -82,7 +82,32 @@ try { if (!move_uploaded_file($fileTmpPath, $uploadPath)) { throw new Exception('Error al guardar el archivo en el servidor'); } - + + // Si es audio WebM, intentar convertir a OGG/Opus (formatos más compatibles con WhatsApp) + if (strpos($fileType, 'audio/webm') === 0) { + $ffmpeg = trim(@shell_exec('which ffmpeg 2>/dev/null')); + if ($ffmpeg) { + $convertedName = uniqid('media_', true) . '.ogg'; + $convertedPath = $uploadDir . $convertedName; + // Convertir a Opus (bitrate moderado) + $cmd = escapeshellcmd($ffmpeg) . ' -y -i ' . escapeshellarg($uploadPath) . ' -c:a libopus -b:a 64000 ' . escapeshellarg($convertedPath) . ' 2>&1'; + $out = shell_exec($cmd); + if (file_exists($convertedPath) && filesize($convertedPath) > 0) { + // Reemplazar archivo original por el convertido + @unlink($uploadPath); + $uploadPath = $convertedPath; + $uniqueName = $convertedName; + $fileType = 'audio/ogg'; + error_log('upload_media.php - Audio convertido a OGG/Opus: ' . $convertedName); + error_log('upload_media.php - ffmpeg output: ' . substr($out, 0, 2000)); + } else { + error_log('upload_media.php - Falló conversión con ffmpeg. Output: ' . substr($out, 0, 2000)); + } + } else { + error_log('upload_media.php - ffmpeg no encontrado, no se puede convertir audio/webm.'); + } + } + // Construir URL pública $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST']; diff --git a/assets/css/styles.css b/assets/css/styles.css index 7080a07..185d7fd 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -120,6 +120,18 @@ body { text-align: center; } +/* Small badge placed inside sidebar items */ +.sidebar-menu .nav-link .sidebar-badge { + position: absolute; + right: 14px; + top: 50%; + transform: translateY(-50%); + font-size: 0.72rem; + padding: 0.12rem 0.36rem; + border-radius: 999px; + line-height: 1; +} + /* Divisor del sidebar */ .sidebar-divider { margin: 10px 20px; diff --git a/assets/js/app.js b/assets/js/app.js index fcc44d8..6693801 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -193,6 +193,14 @@ class WhatsAppBotManager { document.getElementById('conversations-today').textContent = stats.conversations_today || 0; document.getElementById('active-users').textContent = stats.active_users || 0; document.getElementById('total-conversations').textContent = stats.total_conversations || 0; + + // Actualizar badge de conversaciones en el menú lateral + const convBadge = document.getElementById('conversations-count'); + if (convBadge) { + const val = stats.total_conversations || 0; + convBadge.textContent = val; + convBadge.style.display = val > 0 ? 'inline-block' : 'none'; + } } } diff --git a/assets/js/app_simple.js b/assets/js/app_simple.js index b794a1f..b6eacec 100644 --- a/assets/js/app_simple.js +++ b/assets/js/app_simple.js @@ -273,6 +273,14 @@ class SimpleWhatsAppManager { this.log(`Estadística actualizada: ${item.id} = ${item.value}`); } }); + + // Actualizar badge de conversaciones en el menú lateral (compatibilidad con versión simple) + const convBadge = document.getElementById('conversations-count'); + if (convBadge) { + const val = stats.total_conversations || 0; + convBadge.textContent = val; + convBadge.style.display = val > 0 ? 'inline-block' : 'none'; + } } } diff --git a/chat_window.php b/chat_window.php index 25a94b4..bfc06a7 100644 --- a/chat_window.php +++ b/chat_window.php @@ -25,19 +25,20 @@ if (empty($user_id)) { diff --git a/index.php b/index.php index ccb3ac8..d98090d 100644 --- a/index.php +++ b/index.php @@ -37,8 +37,8 @@ try { WhatsApp Bot Manager - - + + @@ -49,7 +49,7 @@ try {