This commit is contained in:
Flatlogic Bot 2026-02-28 20:00:36 +00:00
parent 017ad41531
commit 93e195d19b
12 changed files with 336 additions and 13 deletions

View File

@ -124,7 +124,7 @@ function number_get_formatted($num) {
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="startups.php">Browse Startups</a>
<a href="startups.php">Browse Startups</a><a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<?php endif; ?>

View File

@ -0,0 +1,2 @@
-- Migration: Add equity_pct to investments table
ALTER TABLE investments ADD COLUMN equity_pct DECIMAL(5, 2) DEFAULT 0.00 AFTER amount;

View File

@ -102,7 +102,7 @@ $browseStartups = $stmt->fetchAll();
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="startups.php">Browse Startups</a>
<a href="startups.php">Browse Startups</a><a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php" class="active">Discovery Hub</a>
<?php endif; ?>

View File

@ -78,7 +78,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="startups.php">Browse Startups</a>
<a href="startups.php">Browse Startups</a><a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<?php endif; ?>

146
funding_rounds.php Normal file
View File

@ -0,0 +1,146 @@
<?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';
// Fetch ONLY active funding rounds
$stmt = db()->prepare("
SELECT s.*, fr.id as round_id, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status, u.full_name as founder_name
FROM funding_rounds fr
JOIN startups s ON fr.startup_id = s.id
LEFT JOIN users u ON s.founder_id = u.id
WHERE fr.status = 'Active'
ORDER BY fr.created_at DESC
");
$stmt->execute();
$activeRounds = $stmt->fetchAll();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Active Funding Rounds <?= 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">
<a href="startups.php">Browse Startups</a>
<a href="funding_rounds.php" class="active">Funding Rounds</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<a href="messages.php">Messages</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<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="margin-bottom: 40px;">
<h1>Active Funding Rounds</h1>
<p style="color: var(--text-secondary);">Direct access to the most promising student startups seeking capital right now.</p>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 25px;">
<?php if (empty($activeRounds)): ?>
<div class="card" style="grid-column: 1 / -1; text-align: center; padding: 80px 20px;">
<i class="fas fa-coins" style="font-size: 64px; color: var(--accent-blue); opacity: 0.2; margin-bottom: 30px;"></i>
<h3>No active rounds at the moment</h3>
<p style="color: var(--text-secondary);">Check back soon for new opportunities or browse all startups.</p>
<a href="startups.php" class="btn btn-primary" style="margin-top: 25px;">Browse Startups</a>
</div>
<?php else: ?>
<?php foreach ($activeRounds as $round):
$goal = $round['active_goal'];
$raised = $round['active_raised'];
$progress = round(($raised / ($goal ?: 1)) * 100);
?>
<div class="card" style="position: relative; padding: 35px;">
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px;">
<div>
<div style="font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent-blue); font-weight: 800; margin-bottom: 5px;"><?= htmlspecialchars($round['industry']) ?></div>
<h3 style="margin: 0; font-size: 22px; font-weight: 800;"><?= htmlspecialchars($round['name']) ?></h3>
<div style="font-size: 13px; color: var(--text-secondary); margin-top: 4px;">by <?= htmlspecialchars($round['founder_name']) ?></div>
</div>
<div style="text-align: right;">
<div style="font-size: 11px; color: var(--text-secondary); text-transform: uppercase;">Goal</div>
<div style="font-size: 18px; font-weight: 900;">£<?= number_format($goal) ?></div>
</div>
</div>
<div style="margin-bottom: 12px; font-weight: 700; display: flex; justify-content: space-between; font-size: 14px;">
<span style="color: var(--accent-blue);">£<?= number_format($raised) ?> Secured</span>
<span style="color: var(--text-secondary);"><?= $progress ?>%</span>
</div>
<div style="width: 100%; height: 10px; background: rgba(255,255,255,0.05); border-radius: 5px; overflow: hidden; margin-bottom: 30px; border: 1px solid rgba(255,255,255,0.05);">
<div style="width: <?= min(100, $progress) ?>%; height: 100%; background: var(--gradient-primary); box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);"></div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 30px;">
<div style="background: rgba(255,255,255,0.02); padding: 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.05);">
<div style="font-size: 10px; color: var(--text-secondary); text-transform: uppercase; margin-bottom: 4px;">Platform Yield</div>
<div style="font-weight: 800; color: #fff;"><?= number_format($round['recommended_return_rate'] ?? 5.0, 1) ?>%</div>
</div>
<div style="background: rgba(255,255,255,0.02); padding: 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.05);">
<div style="font-size: 10px; color: var(--text-secondary); text-transform: uppercase; margin-bottom: 4px;">Founder Yield</div>
<div style="font-weight: 800; color: #fff;"><?= $round['founder_return_rate'] ? number_format($round['founder_return_rate'], 1) . '%' : 'N/A' ?></div>
</div>
</div>
<div style="display: flex; gap: 12px;">
<a href="startup_details.php?id=<?= $round['id'] ?>" class="btn btn-outline" style="flex: 1; text-align: center; padding: 14px; font-size: 14px; font-weight: 700;">View Profile</a>
<a href="invest.php?id=<?= $round['id'] ?>" class="btn btn-primary" style="flex: 1.2; text-align: center; padding: 14px; font-size: 14px; font-weight: 800; background: var(--accent-blue); color: #000; border: none;">Invest Now</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;">
<p style="color: var(--text-secondary); font-size: 14px;">&copy; <?= date('Y') ?> <?= htmlspecialchars($platformName) ?> Capitalist Platform. All rights reserved.</p>
</div>
</footer>
<script src="assets/js/main.js"></script>
</body>
</html>

136
invest.php Normal file
View File

@ -0,0 +1,136 @@
<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'investor') {
header('Location: login.php');
exit;
}
$startupId = $_GET['id'] ?? null;
if (!$startupId) {
header('Location: startups.php');
exit;
}
$stmt = db()->prepare("
SELECT s.*, fr.id as round_id, fr.funding_goal, fr.funding_raised, fr.status as round_status
FROM startups s
LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active'
WHERE s.id = ?
");
$stmt->execute([$startupId]);
$startup = $stmt->fetch();
if (!$startup) {
die("Startup not found.");
}
if ($startup['round_status'] !== 'Active') {
die("This startup does not have an active funding round.");
}
$error = '';
$success = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$amount = (float)($_POST['amount'] ?? 0);
$investor_id = $_SESSION['user_id'];
if ($amount <= 0) {
$error = "Please enter a valid investment amount.";
} else {
db()->beginTransaction();
try {
// 1. Create investment record
// Note: We'll assume 1% equity for every £1000 for simplicity or use a formula
// Actually let's look at the database schema for investments
$equity_pct = round(($amount / $startup['funding_goal']) * 10, 2); // Mock logic for equity
$stmt = db()->prepare("INSERT INTO investments (startup_id, investor_id, funding_round_id, amount, equity_pct, status) VALUES (?, ?, ?, ?, ?, 'pending')");
$stmt->execute([$startupId, $investor_id, $startup['round_id'], $amount, $equity_pct]);
// 2. Update funding_rounds raised amount
$stmt = db()->prepare("UPDATE funding_rounds SET funding_raised = funding_raised + ? WHERE id = ?");
$stmt->execute([$amount, $startup['round_id']]);
// 3. Update startup total raised
$stmt = db()->prepare("UPDATE startups SET funding_raised = funding_raised + ? WHERE id = ?");
$stmt->execute([$amount, $startupId]);
db()->commit();
$success = "Investment of £" . number_format($amount) . " submitted successfully! The founder will be notified.";
header("refresh:3;url=portfolio.php");
} catch (Exception $e) {
db()->rollBack();
$error = "Error: " . $e->getMessage();
}
}
}
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Invest in <?= htmlspecialchars($startup['name']) ?> | <?= htmlspecialchars($platformName) ?></title>
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</head>
<body style="background: #000; color: #fff; padding: 60px 20px;">
<div class="container" style="max-width: 600px; margin: 0 auto;">
<div class="card" style="padding: 40px; background: #1a1a1a; border-radius: 24px; border: 1px solid rgba(255,255,255,0.1);">
<h1 style="font-size: 32px; font-weight: 900; margin-bottom: 10px;">Back <?= htmlspecialchars($startup['name']) ?></h1>
<p style="color: #999; margin-bottom: 30px;">
You are participating in the active funding round for this startup.
</p>
<?php if ($error): ?>
<div style="background: rgba(255, 0, 0, 0.1); border: 1px solid rgba(255, 0, 0, 0.3); color: #ff5555; padding: 15px; border-radius: 12px; margin-bottom: 25px;">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<?php if ($success): ?>
<div style="background: rgba(0, 242, 255, 0.1); border: 1px solid var(--accent-blue); color: var(--accent-blue); padding: 15px; border-radius: 12px; margin-bottom: 25px;">
<?= htmlspecialchars($success) ?>
</div>
<?php else: ?>
<div style="background: rgba(255,255,255,0.03); padding: 25px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.05); margin-bottom: 30px;">
<div style="display: flex; justify-content: space-between; margin-bottom: 15px;">
<span style="color: #999;">Funding Goal</span>
<span style="font-weight: 700;">£<?= number_format($startup['funding_goal']) ?></span>
</div>
<div style="display: flex; justify-content: space-between; margin-bottom: 15px;">
<span style="color: #999;">Already Raised</span>
<span style="font-weight: 700;">£<?= number_format($startup['funding_raised']) ?></span>
</div>
<?php
$remaining = $startup['funding_goal'] - $startup['funding_raised'];
?>
<div style="display: flex; justify-content: space-between; padding-top: 15px; border-top: 1px solid rgba(255,255,255,0.05);">
<span style="color: #999;">Remaining</span>
<span style="font-weight: 900; color: var(--accent-blue);">£<?= number_format(max(0, $remaining)) ?></span>
</div>
</div>
<form method="POST">
<div style="margin-bottom: 30px;">
<label style="display: block; margin-bottom: 10px; font-weight: 600; color: #999; text-transform: uppercase; font-size: 12px; letter-spacing: 1px;">Investment Amount (£)</label>
<input type="number" name="amount" min="1" step="1" required placeholder="Enter amount..."
style="width: 100%; padding: 20px; background: #000; border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; color: #fff; font-size: 24px; font-weight: 900;">
</div>
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 20px; font-size: 18px; font-weight: 800; border-radius: 16px; background: var(--accent-blue); color: #000; border: none; cursor: pointer;">
Confirm Investment <i class="fas fa-rocket" style="margin-left: 10px;"></i>
</button>
<a href="startup_details.php?id=<?= $startupId ?>" style="display: block; text-align: center; margin-top: 20px; color: #999; text-decoration: none; font-size: 14px;">Back to Startup Profile</a>
</form>
<?php endif; ?>
</div>
</div>
</body>
</html>

View File

@ -138,7 +138,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['content']) && $active
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="startups.php">Browse Startups</a>
<a href="startups.php">Browse Startups</a><a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<?php endif; ?>

View File

@ -46,7 +46,7 @@ $notifications = $stmt->fetchAll();
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="startups.php">Browse Startups</a>
<a href="startups.php">Browse Startups</a><a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<?php endif; ?>

View File

@ -123,7 +123,7 @@ if (!$search) { usort($browseCandidates, function($a, $b) { return $b['score'] <
<a href="startups.php">My Startups</a>
<a href="partners.php" class="active">Find Partners</a>
<?php else: ?>
<a href="startups.php">Browse Startups</a>
<a href="startups.php">Browse Startups</a><a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<?php endif; ?>

View File

@ -56,7 +56,7 @@ foreach ($myInvestments as $inv) {
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="startups.php">Browse Startups</a>
<a href="startups.php">Browse Startups</a><a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php" class="active">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<?php endif; ?>

View File

@ -7,6 +7,11 @@ if (!isset($_SESSION['user_id'])) {
exit;
}
$user_id = $_SESSION['user_id'];
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
$startupId = $_GET['id'] ?? null;
if (!$startupId) {
header('Location: startups.php');
@ -23,7 +28,7 @@ if (!$startup) {
// Check if user is the founder or an investor
$isFounder = ($_SESSION['user_id'] == $startup['founder_id']);
$isInvestor = ($_SESSION['user_role'] == 'investor');
$isInvestor = ($user['role'] == 'investor');
// Basic permissions check
if (!$isFounder && $startup['status'] === 'private' && !$isInvestor) {
@ -34,23 +39,27 @@ if (!$isFounder && $startup['status'] === 'private' && !$isInvestor) {
$canSeeHistory = $isFounder || $isInvestor;
$fundingHistory = [];
if ($canSeeHistory) {
$stmt = db()->prepare("SELECT i.*, u.name as investor_name FROM investments i JOIN users u ON i.investor_id = u.id WHERE i.startup_id = ? ORDER BY i.created_at DESC");
$stmt = db()->prepare("SELECT i.*, u.full_name as investor_name FROM investments i JOIN users u ON i.investor_id = u.id WHERE i.startup_id = ? ORDER BY i.created_at DESC");
$stmt->execute([$startupId]);
$fundingHistory = $stmt->fetchAll();
}
// Fetch founders
$stmt = db()->prepare("SELECT name FROM users WHERE id = ?");
$stmt = db()->prepare("SELECT full_name as name FROM users WHERE id = ?");
$stmt->execute([$startup['founder_id']]);
$founder = $stmt->fetch();
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?= htmlspecialchars($startup['name']) ?> | Startup Details</title>
<link rel="stylesheet" href="assets/css/custom.css">
<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.0.0/css/all.min.css">
<style>
:root {
@ -120,6 +129,35 @@ $founder = $stmt->fetch();
</head>
<body style="background: #000; color: #fff;">
<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="startups.php">Browse Startups</a><a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php">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;">
<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>
<div class="container" style="padding: 60px 20px;">
<div style="max-width: 900px; margin: 0 auto;">
@ -152,7 +190,7 @@ $founder = $stmt->fetch();
</a>
</div>
<?php elseif ($isFounder): ?>
<a href="create_startup.php" style="background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: #fff; padding: 16px 24px; border-radius: 14px; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 10px;">
<a href="create_startup.php?id=<?= $startup['id'] ?>" style="background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: #fff; padding: 16px 24px; border-radius: 14px; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 10px;">
<i class="fas fa-edit"></i> Edit Profile
</a>
<?php endif; ?>
@ -290,4 +328,4 @@ $founder = $stmt->fetch();
</footer>
</body>
</html>
</html>

View File

@ -96,6 +96,7 @@ if ($user['role'] === 'founder') {
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="startups.php" class="active">Browse Startups</a>
<a href="funding_rounds.php">Funding Rounds</a>
<a href="portfolio.php">Portfolio</a>
<a href="discover.php">Discovery Hub</a>
<?php endif; ?>