130 lines
7.5 KiB
PHP
130 lines
7.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%;">
|
|
<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">
|
|
<a href="startups.php">Browse Startups</a>
|
|
<a href="portfolio.php" class="active">Portfolio</a>
|
|
<a href="discover.php">Discovery Hub</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; font-size: 13px;">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 building your portfolio by discovering promising 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: 30px; transition: all 0.3s;" onclick="location.href='startup_details.php?id=<?= $inv['startup_id'] ?>'" style="cursor: pointer;">
|
|
<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>
|
|
|
|
<style>
|
|
header { background: rgba(10, 10, 15, 0.8); 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, .nav-links a.active { color: #fff; }
|
|
</style>
|
|
|
|
</body>
|
|
</html>
|