38873-vm/portfolio.php
Flatlogic Bot eb6f8a216e v35
2026-02-28 20:07:53 +00:00

155 lines
9.0 KiB
PHP

<?php
require_once 'db/config.php';
session_start();
$user_id = $_SESSION['user_id'] ?? null;
if (!$user_id) { header('Location: login.php'); exit; }
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
if (!$user) { header('Location: login.php'); exit; }
if ($user['role'] !== 'investor') { header('Location: dashboard.php'); exit; }
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
$stmt = db()->prepare("
SELECT i.*, s.name as startup_name, s.description as startup_desc
FROM investments i
JOIN startups s ON i.startup_id = s.id
WHERE i.investor_id = ?
ORDER BY i.created_at DESC
");
$stmt->execute([$user_id]);
$myInvestments = $stmt->fetchAll();
$totalInvested = 0;
foreach ($myInvestments as $inv) {
if ($inv['status'] === 'approved') {
$totalInvested += $inv['amount'];
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Investment Portfolio — <?= htmlspecialchars($platformName) ?></title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&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%;">
<a href="dashboard.php" class="logo-container">
<img src="assets/images/logo.svg" alt="<?= htmlspecialchars($platformName) ?> Logo" class="logo-img">
<span class="logo-text"><?= htmlspecialchars($platformName) ?></span>
</a>
<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="funding_rounds.php">Founding Rounds</a>
<a href="portfolio.php" class="active">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<?php endif; ?>
<a href="messages.php">Messages</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<a href="notifications.php" style="color: var(--text-secondary); position: relative; font-size: 18px;">
<i class="fas fa-bell"></i>
</a>
<div style="display: flex; align-items: center; gap: 10px; padding: 5px 12px; background: rgba(255,255,255,0.05); border-radius: 50px; border: 1px solid var(--border-color);">
<div style="width: 24px; height: 24px; background: var(--gradient-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; font-weight: 800;">
<?= substr($user['full_name'], 0, 1) ?>
</div>
<span style="font-size: 13px; font-weight: 600;"><?= htmlspecialchars(explode(' ', $user['full_name'])[0]) ?></span>
</div>
<a href="logout.php" class="btn btn-secondary" style="padding: 8px 16px; font-size: 12px; border-radius: 10px;">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;">
<div>
<h1>Investment Portfolio</h1>
<p style="color: var(--text-secondary);">Manage your stakes in student-led startups.</p>
</div>
<div class="card" style="padding: 20px 30px; display: flex; align-items: center; gap: 30px; border: 1px solid var(--border-color); background: var(--card-bg);">
<div>
<div style="font-size: 10px; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; letter-spacing: 1px; margin-bottom: 5px;">Total Invested</div>
<div style="font-size: 28px; font-weight: 900; color: var(--accent-blue);">£<?= number_format($totalInvested, 0) ?></div>
</div>
<div style="width: 1px; height: 40px; background: var(--border-color);"></div>
<div>
<div style="font-size: 10px; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; letter-spacing: 1px; margin-bottom: 5px;">Startups</div>
<div style="font-size: 28px; font-weight: 900; color: #fff;"><?= count($myInvestments) ?></div>
</div>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr; gap: 20px;">
<?php if (empty($myInvestments)): ?>
<div class="card" style="text-align: center; padding: 80px 20px; border: 1px dashed var(--border-color);">
<i class="fas fa-chart-line" style="font-size: 64px; color: var(--accent-blue); opacity: 0.2; margin-bottom: 30px;"></i>
<h3>No investments yet</h3>
<p style="color: var(--text-secondary);">Start your journey by backing the next generation of founders.</p>
<a href="discover.php" class="btn btn-primary" style="margin-top: 25px;">Go to Discovery Hub</a>
</div>
<?php else: ?>
<?php foreach ($myInvestments as $inv): ?>
<div class="card" style="display: flex; justify-content: space-between; align-items: center; padding: 30px; transition: all 0.3s; cursor: pointer;" onclick="location.href='startup_details.php?id=<?= $inv['startup_id'] ?>'">
<div style="display: flex; align-items: center; gap: 25px;">
<div style="width: 60px; height: 60px; background: var(--gradient-primary); border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; font-weight: 800;">
<?= substr($inv['startup_name'], 0, 1) ?>
</div>
<div>
<div style="font-size: 11px; text-transform: uppercase; color: var(--accent-blue); margin-bottom: 5px; font-weight: 700;">Invested on <?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
<h3 style="margin-bottom: 5px; font-size: 22px; font-weight: 800;"><?= htmlspecialchars($inv['startup_name']) ?></h3>
<p style="font-size: 14px; color: var(--text-secondary); margin: 0; opacity: 0.8;"><?= htmlspecialchars(substr($inv['startup_desc'], 0, 100)) ?>...</p>
</div>
</div>
<div style="text-align: right; display: flex; align-items: center; gap: 50px;">
<div>
<div style="font-size: 10px; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; letter-spacing: 1px; margin-bottom: 5px;">Amount</div>
<div style="font-size: 22px; font-weight: 900; color: #fff;">£<?= number_format($inv['amount'], 0) ?></div>
</div>
<div style="min-width: 100px;">
<div style="font-size: 10px; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; letter-spacing: 1px; margin-bottom: 5px;">Status</div>
<div style="font-size: 13px; font-weight: 800; color: <?= $inv['status'] === 'approved' ? '#4cd964' : ($inv['status'] === 'pending' ? '#ffcc00' : '#ff3b30') ?>; letter-spacing: 1px;">
<?= strtoupper($inv['status']) ?>
</div>
</div>
<a href="startup_details.php?id=<?= $inv['startup_id'] ?>" class="btn btn-secondary" style="padding: 10px 20px; border-radius: 12px; font-size: 13px; font-weight: 700;">Details</a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</main>
<footer style="margin-top: 80px; padding: 60px 0; border-top: 1px solid var(--border-color); background: rgba(0,0,0,0.2);">
<div class="container" style="text-align: center;">
<div class="logo-container" style="justify-content: center; margin-bottom: 25px;">
<img src="assets/images/logo.svg" alt="<?= htmlspecialchars($platformName) ?> Logo" class="logo-img" style="width: 30px; height: 30px;">
<span class="logo-text" style="font-size: 20px;"><?= htmlspecialchars($platformName) ?></span>
</div>
<p style="color: var(--text-secondary); font-size: 14px;">&copy; <?= date('Y') ?> <?= htmlspecialchars($platformName) ?>. All rights reserved.</p>
</div>
</footer>
<script src="assets/js/main.js"></script>
</body>
</html>