38873-vm/portfolio.php
Flatlogic Bot 21f3fc7eab v2
2026-02-28 15:08:46 +00:00

111 lines
5.5 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();
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
$myInvestments = [];
$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([$_SESSION['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>My Portfolio — <?= 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">
<a href="discover.php">Discover</a>
<a href="portfolio.php" class="active">Portfolio</a>
<a href="messages.php">Messages</a>
<a href="notifications.php">Notifications</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<a href="dashboard.php" style="color: var(--text-secondary);"><i class="fas fa-th-large"></i></a>
<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;">
<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: 15px 30px; display: flex; align-items: center; gap: 20px;">
<div>
<div style="font-size: 10px; text-transform: uppercase; color: var(--text-secondary);">Total Invested</div>
<div style="font-size: 24px; font-weight: 700; color: var(--accent-blue);">£<?= number_format($totalInvested, 0) ?></div>
</div>
<div>
<div style="font-size: 10px; text-transform: uppercase; color: var(--text-secondary);">Startups</div>
<div style="font-size: 24px; font-weight: 700; 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: 60px 20px;">
<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 building your portfolio by discovering startups.</p>
<a href="discover.php" class="btn btn-primary" style="margin-top: 25px;">Discover Startups</a>
</div>
<?php else: ?>
<?php foreach ($myInvestments as $inv): ?>
<div class="card" style="display: flex; justify-content: space-between; align-items: center; padding: 25px;">
<div>
<div style="font-size: 10px; text-transform: uppercase; color: var(--accent-blue); margin-bottom: 5px;">Invested on <?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
<h3 style="margin-bottom: 5px;"><?= htmlspecialchars($inv['startup_name']) ?></h3>
<p style="font-size: 14px; color: var(--text-secondary);"><?= htmlspecialchars(substr($inv['startup_desc'], 0, 80)) ?>...</p>
</div>
<div style="text-align: right; display: flex; align-items: center; gap: 40px;">
<div>
<div style="font-size: 10px; text-transform: uppercase; color: var(--text-secondary);">Amount</div>
<div style="font-size: 20px; font-weight: 700; color: #fff;">£<?= number_format($inv['amount'], 0) ?></div>
</div>
<div>
<div style="font-size: 10px; text-transform: uppercase; color: var(--text-secondary);">Status</div>
<div style="font-weight: 600; color: <?= $inv['status'] === 'approved' ? '#55ff55' : ($inv['status'] === 'pending' ? '#ffaa00' : '#ff5555') ?>;">
<?= ucfirst($inv['status']) ?>
</div>
</div>
<a href="startup_details.php?id=<?= $inv['startup_id'] ?>" class="btn btn-secondary" style="padding: 10px 20px;">View Startup</a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</main>
</body>
</html>