38873-vm/notifications.php
Flatlogic Bot 7fc6180066 v12
2026-02-28 17:28:03 +00:00

129 lines
5.3 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
require_once __DIR__ . '/db/config.php';
$current_user_id = $_SESSION['user_id'];
// Mark all as read if requested
if (isset($_POST['mark_read'])) {
$stmt = db()->prepare("UPDATE notifications SET is_read = 1 WHERE user_id = ?");
$stmt->execute([$current_user_id]);
}
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$current_user_id]);
$user = $stmt->fetch();
$stmt = db()->prepare("SELECT * FROM notifications WHERE user_id = ? ORDER BY created_at DESC");
$stmt->execute([$current_user_id]);
$notifications = $stmt->fetchAll();
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Notifications — <?= htmlspecialchars($platformName) ?></title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body>
<header>
<div class="container" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
<div class="logo"><?= htmlspecialchars($platformName) ?></div>
<nav class="nav-links">
<?php if ($user['role'] === 'founder'): ?>
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="startups.php">Browse Startups</a>
<a href="portfolio.php">Portfolio</a>
<?php endif; ?>
<a href="discover.php">Discovery Hub</a>
<a href="messages.php">Messages</a>
<a href="notifications.php" class="active">Notifications</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<a href="dashboard.php" style="color: var(--text-secondary);"><i class="fas fa-th-large"></i></a>
<a href="logout.php" class="btn btn-secondary" style="padding: 8px 16px; font-size: 13px;">Log Out</a>
</div>
</div>
</header>
<main class="container" style="padding-top: 50px; padding-bottom: 50px;">
<div class="hero-bg">
<div class="hero-blob" style="top: 10%; right: -10%;"></div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px;">
<h1>Notifications</h1>
<?php if (!empty($notifications)): ?>
<form method="POST">
<button type="submit" name="mark_read" class="btn btn-secondary" style="font-size: 13px;">Mark all as read</button>
</form>
<?php endif; ?>
</div>
<div class="card">
<?php if (empty($notifications)): ?>
<div style="text-align: center; padding: 60px 20px;">
<i class="fas fa-bell-slash" style="font-size: 48px; color: var(--accent-blue); opacity: 0.2; margin-bottom: 20px;"></i>
<p style="color: var(--text-secondary);">No notifications yet. We'll let you know when something happens!</p>
<a href="partners.php" class="btn btn-primary" style="margin-top: 25px;">Find Partners</a>
</div>
<?php else: ?>
<div style="display: flex; flex-direction: column; gap: 0;">
<?php foreach ($notifications as $n): ?>
<div style="padding: 20px; border-bottom: 1px solid var(--border-color); display: flex; align-items: flex-start; gap: 20px; <?= $n['is_read'] ? 'opacity: 0.6;' : 'background: rgba(0, 242, 255, 0.03);' ?>">
<div style="width: 40px; height: 40px; border-radius: 12px; background: <?= $n['is_read'] ? 'var(--surface-color)' : 'var(--gradient-primary)' ?>; display: flex; align-items: center; justify-content: center; color: #fff;">
<i class="fas fa-info-circle"></i>
</div>
<div style="flex: 1;">
<p style="margin: 0; font-size: 15px; color: #fff; font-weight: <?= $n['is_read'] ? '400' : '600' ?>;">
<?= htmlspecialchars($n['content']) ?>
</p>
<div style="font-size: 12px; color: var(--text-secondary); margin-top: 8px;">
<?= date('M d, Y • H:i', strtotime($n['created_at'])) ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</main>
<style>
header {
background: rgba(10, 10, 15, 0.8);
backdrop-filter: blur(20px);
border-bottom: 1px solid var(--border-color);
padding: 15px 0;
position: sticky;
top: 0;
z-index: 1000;
}
.nav-links a {
color: var(--text-secondary);
text-decoration: none;
margin: 0 15px;
font-size: 14px;
font-weight: 500;
transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active {
color: #fff;
}
</style>
</body>
</html>