prepare( "SELECT s.id as schedule_id, s.send_time, s.status, s.is_recurring, s.recurring_days, s.recurring_time, m.id as message_id, m.content, r.name as recipient_name, r.type as recipient_type, r.platform, u.username as creator_username FROM schedules s JOIN messages m ON s.message_id = m.id LEFT JOIN recipients r ON s.recipient_id = r.id JOIN users u ON m.user_id = u.id WHERE s.status IN ('draft', 'pending', 'failed', 'processing', 'disabled') ORDER BY s.created_at DESC" ); $stmt->execute(); $messages = $stmt->fetchAll(); // Helper function to convert recurring days to names function getDayNames($daysString) { if (empty($daysString)) return 'No especificado'; $dayMap = [ 0 => 'Domingo', 1 => 'Lunes', 2 => 'Martes', 3 => 'Miércoles', 4 => 'Jueves', 5 => 'Viernes', 6 => 'Sábado' ]; $days = explode(',', $daysString); $names = array_map(fn($day) => $dayMap[(int)$day] ?? '', $days); return implode(', ', array_filter($names)); } $pageTitle = 'Mensajes Programados'; require_once __DIR__ . '/templates/header.php'; ?>
| Plataforma | Destinatario | Contenido | Programación | Estado | Creado por | Acciones |
|---|---|---|---|---|---|---|
| No hay mensajes aquí. | ||||||
| = htmlspecialchars(ucfirst($msg['platform'])) ?> N/A | = !empty($msg['recipient_name']) ? htmlspecialchars($msg['recipient_name']) . ' (' . $msg['recipient_type'] . ')' : 'No asignado' ?> | Semanal: ' . getDayNames($msg['recurring_days']) . ' a las ' . substr($msg['recurring_time'], 0, 5); else: echo $msg['send_time'] ? date('d/m/Y H:i', strtotime($msg['send_time'])) : '-'; endif; ?> | 'info text-dark', 'draft' => 'secondary', 'failed' => 'danger', 'processing' => 'warning text-dark', 'disabled' => 'light text-dark' ]; $badgeClass = $statusBadges[$msg['status']] ?? 'light'; ?> = ucfirst($msg['status']) ?> | = htmlspecialchars($msg['creator_username']) ?> | ||