65 lines
2.0 KiB
PHP
65 lines
2.0 KiB
PHP
<?php
|
|
require_once 'config/config.php';
|
|
|
|
$db = Database::getInstance();
|
|
|
|
echo "<h2>Últimos 10 mensajes multimedia en la BD</h2>";
|
|
echo "<style>
|
|
table { border-collapse: collapse; width: 100%; }
|
|
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
|
|
th { background-color: #4CAF50; color: white; }
|
|
tr:nth-child(even) { background-color: #f2f2f2; }
|
|
pre { background: #f4f4f4; padding: 10px; overflow-x: auto; }
|
|
</style>";
|
|
|
|
$conversations = $db->fetchAll("
|
|
SELECT
|
|
c.id,
|
|
c.user_id,
|
|
u.phone_number,
|
|
c.direction,
|
|
c.message_type,
|
|
c.content,
|
|
c.media_url,
|
|
c.created_at
|
|
FROM conversations c
|
|
LEFT JOIN users u ON c.user_id = u.id
|
|
WHERE c.message_type IN ('image', 'audio', 'video', 'document')
|
|
ORDER BY c.created_at DESC
|
|
LIMIT 10
|
|
");
|
|
|
|
echo "<table>";
|
|
echo "<tr>
|
|
<th>ID</th>
|
|
<th>Teléfono</th>
|
|
<th>Dir</th>
|
|
<th>Tipo</th>
|
|
<th>Content</th>
|
|
<th>Media URL</th>
|
|
<th>Fecha</th>
|
|
</tr>";
|
|
|
|
foreach ($conversations as $msg) {
|
|
echo "<tr>";
|
|
echo "<td>{$msg['id']}</td>";
|
|
echo "<td>{$msg['phone_number']}</td>";
|
|
echo "<td>{$msg['direction']}</td>";
|
|
echo "<td><strong>{$msg['message_type']}</strong></td>";
|
|
echo "<td><pre>" . htmlspecialchars(substr($msg['content'], 0, 200)) . "</pre></td>";
|
|
echo "<td><pre>" . htmlspecialchars(substr($msg['media_url'], 0, 100)) . "</pre></td>";
|
|
echo "<td>" . date('H:i:s', strtotime($msg['created_at'])) . "</td>";
|
|
echo "</tr>";
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
echo "<h3>Análisis:</h3>";
|
|
echo "<ul>";
|
|
echo "<li>Si 'Content' tiene JSON → Problema: se guardó la respuesta de WhatsApp en lugar del caption</li>";
|
|
echo "<li>Si 'Media URL' está vacía o tiene JSON → Problema: no se guardó correctamente la URL</li>";
|
|
echo "<li>Si 'Media URL' tiene un ID (sin http) → Problema: es el media_id de WhatsApp, no la URL local</li>";
|
|
echo "<li>Correcto: Media URL debería tener http://localhost/uploads/...</li>";
|
|
echo "</ul>";
|
|
?>
|