38873-vm/dashboard.php
Flatlogic Bot 392dc73382 v3
2026-02-28 15:38:54 +00:00

232 lines
12 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
require_once __DIR__ . '/db/config.php';
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
if (!$user) {
session_destroy();
header("Location: login.php");
exit;
}
// Security: Check if verified
if ($user['verified'] == 0) {
session_destroy();
header("Location: login.php?error=not_verified");
exit;
}
// Check if onboarding is complete
if ($user['role'] === 'founder' && $user['onboarding_completed'] == 0) {
header("Location: founder_onboarding.php");
exit;
}
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
// Fetch user's data based on role
$myStartups = [];
$myInvestments = [];
if ($user['role'] === 'founder') {
$stmt = db()->prepare("SELECT * FROM startups WHERE founder_id = ? ORDER BY created_at DESC");
$stmt->execute([$_SESSION['user_id']]);
$myStartups = $stmt->fetchAll();
} else {
$stmt = db()->prepare("SELECT i.*, s.name as startup_name FROM investments i JOIN startups s ON i.startup_id = s.id WHERE i.investor_id = ? ORDER BY i.created_at DESC");
$stmt->execute([$_SESSION['user_id']]);
$myInvestments = $stmt->fetchAll();
}
function number_get_formatted($num) {
return number_format((float)$num, 0, '.', ',');
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dashboard — <?= 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="discover.php">Discover</a>
<a href="portfolio.php">Portfolio</a>
<?php endif; ?>
<a href="messages.php">Messages</a>
<a href="notifications.php">Notifications</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<span style="font-size: 14px; font-weight: 500;"><?= htmlspecialchars($user['full_name']) ?> <span style="opacity: 0.6; font-weight: 400;">(<?= ucfirst($user['role']) ?>)</span></span>
<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;">
<h1>Welcome, <?= htmlspecialchars(explode(' ', $user['full_name'])[0]) ?>!</h1>
<p style="color: var(--text-secondary); margin-bottom: 40px;">Manage your projects and network from one place.</p>
<div style="display: grid; grid-template-columns: 2fr 1fr; gap: 30px;">
<div>
<?php if ($user['role'] === 'founder'): ?>
<div class="card" style="margin-bottom: 30px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<h3 style="margin: 0;">My Ventures</h3>
<a href="start_funding.php" class="btn btn-primary" style="padding: 10px 20px; font-size: 14px;">+ Launch Round</a>
</div>
<?php if (empty($myStartups)): ?>
<div style="text-align: center; padding: 50px 0; background: rgba(255,255,255,0.02); border-radius: 16px; border: 1px dashed var(--border-color);">
<i class="fas fa-rocket" style="font-size: 40px; color: var(--accent-blue); opacity: 0.5; margin-bottom: 15px;"></i>
<p style="color: var(--text-secondary); margin-bottom: 20px;">Ready to share your vision with the world?</p>
<a href="start_funding.php" class="btn btn-primary">Start Your First Round</a>
</div>
<?php else: ?>
<div style="display: grid; grid-template-columns: 1fr; gap: 15px;">
<?php foreach ($myStartups as $startup): ?>
<div style="padding: 20px; background: var(--surface-color); border-radius: 16px; border: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; transition: all 0.2s; cursor: pointer;" onclick="window.location.href='startup_details.php?id=<?= $startup['id'] ?>'">
<div>
<div style="font-weight: 600; font-size: 18px; margin-bottom: 4px;"><?= htmlspecialchars($startup['name']) ?></div>
<div style="font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 10px;">
<span style="padding: 2px 8px; background: rgba(0, 122, 255, 0.1); color: var(--accent-blue); border-radius: 4px; font-weight: 600;"><?= strtoupper($startup['status']) ?></span>
<span>Target: £<?= number_get_formatted($startup['funding_target']) ?></span>
</div>
</div>
<div style="text-align: right;">
<div style="font-size: 18px; font-weight: 700; color: #fff;">£<?= number_get_formatted($startup['funding_raised']) ?></div>
<div style="font-size: 12px; color: var(--text-secondary);">Raised so far</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php else: ?>
<div class="card" style="margin-bottom: 30px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<h3 style="margin: 0;">Portfolio Overview</h3>
<a href="discover.php" class="btn btn-primary" style="padding: 10px 20px; font-size: 14px;">Find New Deals</a>
</div>
<?php if (empty($myInvestments)): ?>
<div style="text-align: center; padding: 50px 0; background: rgba(255,255,255,0.02); border-radius: 16px; border: 1px dashed var(--border-color);">
<i class="fas fa-chart-line" style="font-size: 40px; color: var(--accent-blue); opacity: 0.5; margin-bottom: 15px;"></i>
<p style="color: var(--text-secondary); margin-bottom: 20px;">Browse the next generation of student-led innovation.</p>
<a href="discover.php" class="btn btn-primary">Start Investing</a>
</div>
<?php else: ?>
<div style="display: grid; grid-template-columns: 1fr; gap: 15px;">
<?php foreach ($myInvestments as $inv): ?>
<div style="padding: 20px; background: var(--surface-color); border-radius: 16px; border: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center;">
<div>
<div style="font-weight: 600; font-size: 18px; margin-bottom: 4px;"><?= htmlspecialchars($inv['startup_name']) ?></div>
<div style="font-size: 13px; color: var(--text-secondary);">Committed on <?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
</div>
<div style="text-align: right;">
<div style="font-size: 18px; font-weight: 700; color: var(--accent-blue);">£<?= number_get_formatted($inv['amount']) ?></div>
<div style="font-size: 12px; font-weight: 600; color: <?= $inv['status'] === 'approved' ? '#4cd964' : ($inv['status'] === 'rejected' ? '#ff3b30' : '#ffcc00') ?>;">
<?= strtoupper($inv['status']) ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="card">
<h3>Insights & Activity</h3>
<div style="padding: 30px; text-align: center; color: var(--text-secondary);">
<p>Coming soon: Real-time insights from your network and matching suggestions based on your profile.</p>
</div>
</div>
</div>
<div>
<div class="card" style="margin-bottom: 30px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
<h3 style="margin: 0;">My Profile</h3>
<a href="edit_profile.php" style="color: var(--accent-blue); font-size: 14px; text-decoration: none;">Edit</a>
</div>
<div style="display: flex; align-items: center; gap: 15px; margin-bottom: 25px;">
<div style="width: 64px; height: 64px; background: var(--gradient-primary); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; font-weight: 700; box-shadow: 0 10px 20px rgba(0, 122, 255, 0.2);">
<?= substr($user['full_name'], 0, 1) ?>
</div>
<div>
<div style="font-weight: 700; font-size: 18px;"><?= htmlspecialchars($user['full_name']) ?></div>
<div style="font-size: 13px; color: var(--text-secondary);"><?= htmlspecialchars($user['university']) ?> '<?= substr($user['graduation_year'], -2) ?></div>
</div>
</div>
<div style="margin-bottom: 25px; font-size: 14px; line-height: 1.6; color: var(--text-secondary);">
<?= htmlspecialchars($user['bio'] ?: 'No bio provided yet.') ?>
</div>
<?php if ($user['role'] === 'founder'): ?>
<div style="display: flex; flex-wrap: wrap; gap: 8px;">
<?php
$skills = explode(',', $user['skills'] ?? '');
foreach (array_slice($skills, 0, 3) as $skill): if(empty($skill)) continue; ?>
<span style="font-size: 11px; padding: 4px 10px; background: rgba(255,255,255,0.05); border-radius: 20px; border: 1px solid var(--border-color);"><?= htmlspecialchars(trim($skill)) ?></span>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div class="card" style="background: var(--gradient-primary); color: #fff; border: none;">
<h3 style="color: #fff; margin-bottom: 10px;">Gatsby Pro</h3>
<p style="font-size: 14px; opacity: 0.9; margin-bottom: 20px;">Get advanced analytics and direct intros to top-tier VC scouts.</p>
<button class="btn" style="width: 100%; background: #fff; color: var(--accent-blue); font-weight: 700;">Learn More</button>
</div>
</div>
</div>
</main>
<style>
header {
background: rgba(10, 10, 10, 0.8);
backdrop-filter: blur(20px);
-webkit-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 {
color: #fff;
}
</style>
</body>
</html>