184 lines
10 KiB
PHP
184 lines
10 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();
|
|
|
|
// Check if profile is complete (e.g., bio or interests)
|
|
if (empty($user['bio']) && empty($user['interests'])) {
|
|
if ($user['role'] === 'investor') {
|
|
header("Location: investor_onboarding.php");
|
|
} else {
|
|
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();
|
|
}
|
|
?>
|
|
<!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><?= htmlspecialchars($user['full_name']) ?> (<?= ucfirst($user['role']) ?>)</span>
|
|
<a href="logout.php" class="btn btn-secondary" style="padding: 8px 16px;">Log Out</a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="container" style="padding-top: 50px;">
|
|
<h1>Welcome, <?= htmlspecialchars($user['full_name']) ?>!</h1>
|
|
<p style="color: var(--text-secondary); margin-bottom: 40px;">Here is your startup ecosystem overview.</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: 20px;">
|
|
<h3 style="margin: 0;">My Startups</h3>
|
|
<a href="start_funding.php" class="btn btn-primary" style="padding: 8px 16px; font-size: 14px;">+ List Startup</a>
|
|
</div>
|
|
|
|
<?php if (empty($myStartups)): ?>
|
|
<div style="text-align: center; padding: 40px 0;">
|
|
<i class="fas fa-rocket" style="font-size: 48px; color: var(--accent-blue); opacity: 0.3; margin-bottom: 20px;"></i>
|
|
<p>You haven't listed any startups yet.</p>
|
|
<a href="start_funding.php" class="btn btn-primary" style="margin-top: 20px;">Start Funding Round</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div style="display: grid; grid-template-columns: 1fr; gap: 15px;">
|
|
<?php foreach ($myStartups as $startup): ?>
|
|
<div style="padding: 15px; background: var(--surface-color); border-radius: 12px; border: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center;">
|
|
<div>
|
|
<div style="font-weight: 600;"><?= htmlspecialchars($startup['name']) ?></div>
|
|
<div style="font-size: 12px; color: var(--text-secondary);"><?= htmlspecialchars($startup['status']) ?> • Raising £<?= number_get_formatted($startup['funding_target']) ?></div>
|
|
</div>
|
|
<div style="text-align: right;">
|
|
<div style="font-size: 14px; font-weight: 600; color: var(--accent-blue);">£<?= number_get_formatted($startup['funding_raised']) ?> raised</div>
|
|
<div style="font-size: 12px; color: var(--text-secondary);">of £<?= number_get_formatted($startup['funding_target']) ?></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: 20px;">
|
|
<h3 style="margin: 0;">My Portfolio</h3>
|
|
<a href="discover.php" class="btn btn-primary" style="padding: 8px 16px; font-size: 14px;">Explore Startups</a>
|
|
</div>
|
|
|
|
<?php if (empty($myInvestments)): ?>
|
|
<div style="text-align: center; padding: 40px 0;">
|
|
<i class="fas fa-chart-pie" style="font-size: 48px; color: var(--accent-blue); opacity: 0.3; margin-bottom: 20px;"></i>
|
|
<p>You haven't backed any student projects yet.</p>
|
|
<a href="discover.php" class="btn btn-primary" style="margin-top: 20px;">Discover Startups</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div style="display: grid; grid-template-columns: 1fr; gap: 15px;">
|
|
<?php foreach ($myInvestments as $inv): ?>
|
|
<div style="padding: 15px; background: var(--surface-color); border-radius: 12px; border: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center;">
|
|
<div>
|
|
<div style="font-weight: 600;"><?= htmlspecialchars($inv['startup_name']) ?></div>
|
|
<div style="font-size: 12px; color: var(--text-secondary);">Invested on <?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
|
|
</div>
|
|
<div style="text-align: right;">
|
|
<div style="font-size: 16px; font-weight: 700; color: var(--accent-blue);">£<?= number_get_formatted($inv['amount']) ?></div>
|
|
<div style="font-size: 12px; color: var(--text-secondary);"><?= ucfirst($inv['status']) ?></div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="card">
|
|
<h3>Latest Network Activity</h3>
|
|
<p style="color: var(--text-secondary);">Discover the latest student innovations and trends.</p>
|
|
<div style="margin-top: 20px; border-top: 1px solid var(--border-color); padding-top: 20px;">
|
|
<p style="color: var(--text-secondary); text-align: center;">No new activity in your network. Follow founders or startups to see updates.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="card" style="margin-bottom: 30px;">
|
|
<h3>Your Profile</h3>
|
|
<div style="display: flex; align-items: center; gap: 15px; margin-bottom: 20px;">
|
|
<div style="width: 60px; height: 60px; background: var(--surface-color); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--accent-blue); font-weight: bold; border: 1px solid var(--border-color);">
|
|
<?= substr($user['full_name'], 0, 1) ?>
|
|
</div>
|
|
<div>
|
|
<div style="font-weight: 600;"><?= htmlspecialchars($user['full_name']) ?></div>
|
|
<div style="font-size: 14px; color: var(--text-secondary);"><?= htmlspecialchars($user['university']) ?></div>
|
|
</div>
|
|
</div>
|
|
<div style="margin-bottom: 20px; font-size: 14px; line-height: 1.5; color: var(--text-secondary);">
|
|
<?= htmlspecialchars($user['bio'] ?? 'Tell the community about yourself.') ?>
|
|
</div>
|
|
<a href="edit_profile.php" class="btn btn-secondary" style="width: 100%; text-align: center;">Edit Profile</a>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>Networking</h3>
|
|
<p style="font-size: 14px; color: var(--text-secondary); margin-bottom: 20px;">Find the right people to build the future with.</p>
|
|
<a href="partners.php" class="btn btn-secondary" style="width: 100%; text-align: center;">Find Partners</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<?php
|
|
function number_get_formatted($num) {
|
|
return number_format((float)$num, 0, '.', ',');
|
|
}
|
|
?>
|
|
|
|
</body>
|
|
</html>
|