305 lines
16 KiB
PHP
305 lines
16 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';
|
|
|
|
// Identify Trending Startups (Top 3 in followers or funding this week)
|
|
$trendingIds = [];
|
|
|
|
// Top 3 Followed
|
|
$stmt = db()->prepare("
|
|
SELECT s.id
|
|
FROM startups s
|
|
JOIN startup_followers sf ON s.id = sf.startup_id
|
|
WHERE sf.created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
GROUP BY s.id
|
|
ORDER BY COUNT(sf.id) DESC
|
|
LIMIT 3
|
|
");
|
|
$stmt->execute();
|
|
$topFollowed = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
|
$trendingIds = array_merge($trendingIds, $topFollowed);
|
|
|
|
// Top 3 Funded
|
|
$stmt = db()->prepare("
|
|
SELECT s.id
|
|
FROM startups s
|
|
JOIN investments i ON s.id = i.startup_id
|
|
WHERE i.status = 'approved' AND i.created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
GROUP BY s.id
|
|
ORDER BY SUM(i.amount) DESC
|
|
LIMIT 3
|
|
");
|
|
$stmt->execute();
|
|
$topFunded = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
|
$trendingIds = array_unique(array_merge($trendingIds, $topFunded));
|
|
|
|
// Fetch user's data based on role
|
|
$myStartups = [];
|
|
$myInvestments = [];
|
|
|
|
if ($user['role'] === 'founder') {
|
|
// Fetch startups and their active round if any
|
|
$stmt = db()->prepare("
|
|
SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status
|
|
FROM startups s
|
|
LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active'
|
|
WHERE s.founder_id = ?
|
|
ORDER BY s.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">
|
|
<style>
|
|
.trending-pill {
|
|
background: linear-gradient(45deg, #FFD700, #FFA500);
|
|
color: #000;
|
|
padding: 2px 8px;
|
|
border-radius: 4px;
|
|
font-size: 10px;
|
|
font-weight: 800;
|
|
text-transform: uppercase;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 3px;
|
|
margin-left: 8px;
|
|
vertical-align: middle;
|
|
}
|
|
</style>
|
|
</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="discover.php">Find Partners</a>
|
|
<?php else: ?>
|
|
<a href="discover.php">Discovery</a>
|
|
<a href="startups.php">Browse Startups</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 New Startup</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):
|
|
$goal = $startup['active_goal'] ?? $startup['funding_target'];
|
|
$raised = $startup['active_raised'] ?? $startup['funding_raised'];
|
|
$isTrending = in_array($startup['id'], $trendingIds);
|
|
?>
|
|
<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']) ?>
|
|
<?php if ($isTrending): ?>
|
|
<span class="trending-pill"><i class="fas fa-fire"></i> Trending</span>
|
|
<?php endif; ?>
|
|
</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;">
|
|
<?= $startup['round_status'] === 'Active' ? 'ROUND ACTIVE' : 'NO ACTIVE ROUND' ?>
|
|
</span>
|
|
<span>Target: £<?= number_get_formatted($goal) ?></span>
|
|
</div>
|
|
</div>
|
|
<div style="text-align: right;">
|
|
<div style="font-size: 18px; font-weight: 700; color: #fff;">£<?= number_get_formatted($raised) ?></div>
|
|
<div style="font-size: 12px; color: var(--text-secondary);">Raised in round</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="startups.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="startups.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' : ($inv['status'] === 'Refunded' ? '#ff9500' : '#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; margin-bottom: 30px;">
|
|
<h3 style="color: #fff; margin-bottom: 10px;"><?= $user['role'] === 'founder' ? 'Find Partners' : 'Trending Startups' ?></h3>
|
|
<p style="font-size: 14px; opacity: 0.9; margin-bottom: 20px;">
|
|
<?= $user['role'] === 'founder' ? 'Ready to find your perfect co-founder? Start swiping through profiles.' : 'Check out the most followed and funded startups this week!' ?>
|
|
</p>
|
|
<a href="discover.php" class="btn" style="width: 100%; background: #fff; color: var(--accent-blue); font-weight: 700; text-align: center; display: block; text-decoration: none;">Explore Discovery Hub</a>
|
|
</div>
|
|
|
|
<div class="card" style="background: rgba(255,255,255,0.05); color: #fff; border: 1px solid var(--border-color);">
|
|
<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 btn-secondary" style="width: 100%;">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>
|