query("SELECT id, name, type, platform FROM recipients ORDER BY platform, type, name ASC"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { if ($row['platform'] === 'discord') { if ($row['type'] === 'channel') $discord_channels[] = $row; else $discord_users[] = $row; } elseif ($row['platform'] === 'telegram') { $telegram_chats[] = $row; } } } catch (PDOException $e) { die("Error: No se pudieron cargar los destinatarios."); } // Fetch templates $templates = []; try { $stmt = $pdo->query("SELECT id, name FROM recurrent_messages ORDER BY name ASC"); $templates = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { die("Error: No se pudieron cargar las plantillas."); } require_once __DIR__ . '/templates/header.php'; ?>