prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
if (!$user) {
session_destroy();
header("Location: login.php");
exit;
}
if ($user['verified'] == 0) {
session_destroy();
header("Location: login.php?error=not_verified");
exit;
}
if ($user['role'] === 'founder' && $user['onboarding_completed'] == 0) {
header("Location: founder_onboarding.php");
exit;
}
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
$trendingIds = [];
$stmt = db()->prepare("
SELECT s.id
FROM startups s
LEFT JOIN startup_followers sf ON s.id = sf.startup_id
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);
$stmt = db()->prepare("
SELECT id
FROM startups
ORDER BY funding_raised DESC
LIMIT 3
");
$stmt->execute();
$topFunded = $stmt->fetchAll(PDO::FETCH_COLUMN);
$trendingIds = array_unique(array_merge($trendingIds, $topFunded));
$myStartups = [];
$myInvestments = [];
$repaymentSummary = [
'total_raised' => 0,
'total_obligation' => 0,
'monthly_outgoing' => 0,
'active_investors' => 0,
'next_payment_date' => null
];
if ($user['role'] === 'founder') {
$stmt = db()->prepare("
SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status, fr.id as round_id
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();
// Repayment Summary Calculation
$stmt = db()->prepare("
SELECT
SUM(i.amount) as total_raised,
SUM(i.total_return) as total_obligation,
SUM(CASE WHEN i.status = 'approved' THEN i.monthly_dividend ELSE 0 END) as monthly_outgoing,
COUNT(DISTINCT CASE WHEN i.status = 'approved' THEN i.investor_id END) as active_investors,
MIN(CASE WHEN i.status = 'approved' THEN i.next_payment_date END) as next_payment_date
FROM investments i
JOIN startups s ON i.startup_id = s.id
WHERE s.founder_id = ?
");
$stmt->execute([$_SESSION['user_id']]);
$repaymentSummary = $stmt->fetch();
} 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, '.', ',');
}
?>
Dashboard — = htmlspecialchars($platformName) ?>
Launchpad Active
Welcome back, = htmlspecialchars(explode(' ', $user['full_name'])[0]) ?>.
Your command center for the next big thing.
Funding & Repayment Overview
Total Raised
£= number_format($repaymentSummary['total_raised'] ?? 0, 0) ?>
Total Obligation
£= number_format($repaymentSummary['total_obligation'] ?? 0, 0) ?>
Monthly Outgoing
£= number_format($repaymentSummary['monthly_outgoing'] ?? 0, 0) ?>
Active Investors
= $repaymentSummary['active_investors'] ?? 0 ?>
Next Due Date
= $repaymentSummary['next_payment_date'] ? date('M d, Y', strtotime($repaymentSummary['next_payment_date'])) : 'None' ?>
= substr($startup['name'], 0, 1) ?>
= htmlspecialchars($startup['name']) ?>
Trending
= strtoupper($startup['round_status'] ?? 'Draft') ?>
Target: £= number_get_formatted($goal) ?>
£= number_get_formatted($raised) ?>
Funds Raised
= htmlspecialchars($inv['startup_name']) ?>
Committed on = date('M d, Y', strtotime($inv['created_at'])) ?>
£= number_get_formatted($inv['amount']) ?>
= strtoupper($inv['status']) ?>
Ecosystem Activity
Insights from your network and trending matches will appear here.
My Money Pot
Available Balance
£= number_format($user['balance'], 2) ?>