This commit is contained in:
Flatlogic Bot 2026-02-28 22:38:01 +00:00
parent 113fd9f5f9
commit fb4133a854
5 changed files with 423 additions and 578 deletions

View File

@ -1,6 +1,6 @@
<?php
session_start();
require_once 'db/config.php';
require_once __DIR__ . '/../db/config.php';
if (!isset($_SESSION['user_id'])) {
header('Content-Type: application/json');
@ -14,7 +14,7 @@ $amount = (float)($_POST['amount'] ?? 0);
if ($amount <= 0) {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => 'Invalid amount']);
echo json_encode(['success' => false, 'error' => 'Please enter a valid amount greater than zero.']);
exit;
}
@ -27,7 +27,7 @@ try {
$user = $stmt->fetch();
if (!$user) {
throw new Exception("User not found");
throw new Exception("User account not found.");
}
$current_balance = (float)$user['balance'];
@ -37,27 +37,35 @@ try {
$stmt = db()->prepare("UPDATE users SET balance = ? WHERE id = ?");
$stmt->execute([$new_balance, $user_id]);
// Log transaction (optional but good practice, maybe later)
// Log transaction
$stmt = db()->prepare("INSERT INTO wallet_transactions (user_id, amount, type, description) VALUES (?, ?, 'add', 'Added funds to wallet')");
$stmt->execute([$user_id, $amount]);
db()->commit();
echo json_encode(['success' => true, 'new_balance' => $new_balance]);
echo json_encode(['success' => true, 'new_balance' => $new_balance, 'message' => 'Funds added successfully!']);
} elseif ($action === 'withdraw') {
if ($current_balance < $amount) {
throw new Exception("Insufficient funds");
throw new Exception("Insufficient funds. You only have £" . number_format($current_balance, 2) . " available.");
}
$new_balance = $current_balance - $amount;
$stmt = db()->prepare("UPDATE users SET balance = ? WHERE id = ?");
$stmt->execute([$new_balance, $user_id]);
// Log transaction
$stmt = db()->prepare("INSERT INTO wallet_transactions (user_id, amount, type, description) VALUES (?, ?, 'withdraw', 'Withdrawn funds from wallet')");
$stmt->execute([$user_id, $amount]);
db()->commit();
echo json_encode(['success' => true, 'new_balance' => $new_balance]);
echo json_encode(['success' => true, 'new_balance' => $new_balance, 'message' => 'Withdrawal successful!']);
} else {
throw new Exception("Invalid action");
throw new Exception("Invalid action requested.");
}
} catch (Exception $e) {
db()->rollBack();
if (db()->inTransaction()) {
db()->rollBack();
}
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}
}

View File

@ -79,6 +79,11 @@ if ($user['role'] === 'founder') {
$myInvestments = $stmt->fetchAll();
}
// Fetch Wallet Transactions
$stmt = db()->prepare("SELECT * FROM wallet_transactions WHERE user_id = ? ORDER BY created_at DESC LIMIT 5");
$stmt->execute([$_SESSION['user_id']]);
$transactions = $stmt->fetchAll();
function number_get_formatted($num) {
return number_format((float)$num, 0, '.', ',');
}
@ -98,155 +103,106 @@ function number_get_formatted($num) {
.trending-pill {
background: linear-gradient(45deg, #FFD700, #FFA500);
color: #000;
padding: 2px 8px;
border-radius: 4px;
font-size: 10px;
padding: 4px 12px;
border-radius: 50px;
font-size: 11px;
font-weight: 800;
text-transform: uppercase;
letter-spacing: 0.5px;
display: inline-flex;
align-items: center;
gap: 3px;
margin-left: 8px;
vertical-align: middle;
gap: 5px;
}
.profile-link-card {
text-decoration: none;
color: inherit;
transition: transform 0.2s;
display: block;
.transaction-item {
padding: 12px 0;
border-bottom: 1px solid rgba(255,255,255,0.05);
display: flex;
justify-content: space-between;
align-items: center;
}
.profile-link-card:hover {
transform: translateY(-2px);
}
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.8);
backdrop-filter: blur(5px);
}
.modal-content {
background-color: #1a1a24;
margin: 10% auto;
padding: 40px;
border: 1px solid var(--border-color);
width: 400px;
border-radius: 32px;
box-shadow: 0 25px 50px rgba(0,0,0,0.5);
.transaction-item:last-child {
border-bottom: none;
}
</style>
</head>
<body>
<body style="background: #000; color: #fff; font-family: 'Inter', sans-serif;">
<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>
<nav style="padding: 20px 40px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.8); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 1000;">
<div style="display: flex; align-items: center; gap: 40px;">
<a href="index.php" style="text-decoration: none; display: flex; align-items: center; gap: 10px;">
<div style="width: 32px; height: 32px; background: var(--gradient-primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 18px;">G</div>
<span style="font-weight: 900; font-size: 22px; letter-spacing: -1px; color: #fff;"><?= 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">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 style="display: flex; gap: 25px;">
<a href="dashboard.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 700; opacity: 1;">Dashboard</a>
<a href="discover.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.6;">Discover</a>
<a href="messages.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.6;">Messages</a>
</div>
</div>
</header>
<div style="display: flex; align-items: center; gap: 20px;">
<div style="background: rgba(255,255,255,0.05); padding: 8px 16px; border-radius: 50px; border: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px;">
<i class="fas fa-wallet" style="color: var(--accent-blue); font-size: 12px;"></i>
<span id="header-wallet-balance" style="font-weight: 800; font-size: 13px;">£<?= number_format($user['balance'], 2) ?></span>
</div>
<a href="logout.php" style="color: #ff3b30; text-decoration: none; font-size: 13px; font-weight: 700;">Logout</a>
</div>
</nav>
<main class="container" style="padding-top: 60px; padding-bottom: 80px;">
<div class="hero-bg">
<div class="hero-blob" style="top: 5%; left: -15%;"></div>
<div class="hero-blob" style="bottom: 10%; right: -15%; width: 500px; height: 500px; background: radial-gradient(circle, rgba(138, 43, 226, 0.1) 0%, rgba(0, 242, 255, 0.1) 100%);"></div>
<main style="max-width: 1400px; margin: 40px auto; padding: 0 40px;">
<div style="margin-bottom: 40px;">
<h1 style="font-size: 42px; font-weight: 900; margin: 0; letter-spacing: -1.5px;">Welcome back, <?= explode(' ', htmlspecialchars($user['full_name']))[0] ?>!</h1>
<p style="color: var(--text-secondary); font-size: 18px; margin-top: 10px;">Here's what's happening in your venture ecosystem.</p>
</div>
<div style="margin-bottom: 60px;">
<div class="match-score-pill" style="margin-bottom: 20px;"><i class="fas fa-rocket"></i> Launchpad Active</div>
<h1 style="font-size: 56px; font-weight: 900; letter-spacing: -2px; line-height: 1.1;">Welcome back, <span style="background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent;"><?= htmlspecialchars(explode(' ', $user['full_name'])[0]) ?>.</span></h1>
<p style="color: var(--text-secondary); font-size: 20px; margin-top: 10px;">Your command center for the next big thing.</p>
</div>
<div style="display: grid; grid-template-columns: 2fr 1fr; gap: 40px;">
<div style="display: grid; grid-template-columns: 1fr 380px; gap: 40px;">
<div>
<?php if ($user['role'] === 'founder'): ?>
<div class="card" style="margin-bottom: 40px; padding: 35px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;">
<h3 style="margin: 0; font-size: 24px; font-weight: 800;">My Ventures</h3>
<div style="display: flex; gap: 10px;">
<a href="create_startup.php" class="btn btn-primary" style="padding: 12px 24px; font-size: 14px;">+ Launch Startup</a>
</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<h3 style="margin: 0; font-size: 24px; font-weight: 800;">My Ventures</h3>
<a href="create_startup.php" class="btn btn-primary" style="padding: 12px 24px; font-size: 14px;">+ Register New Startup</a>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 25px; margin-bottom: 40px;">
<?php if (empty($myStartups)): ?>
<div style="text-align: center; padding: 60px 0; background: rgba(255,255,255,0.02); border-radius: 32px; border: 1px dashed var(--border-color);">
<div class="card" style="grid-column: span 2; padding: 60px; text-align: center; border-style: dashed;">
<div class="card-icon" style="margin: 0 auto 20px; background: rgba(0, 242, 255, 0.1);"><i class="fas fa-rocket"></i></div>
<p style="color: var(--text-secondary); margin-bottom: 25px; font-size: 18px;">Ready to share your vision with the world?</p>
<a href="create_startup.php" class="btn btn-primary">Start Your First Round</a>
<h3 style="font-size: 22px; font-weight: 800; margin-bottom: 10px;">No startups registered</h3>
<p style="color: var(--text-secondary); margin-bottom: 25px;">Ready to change the world? Start by registering your venture.</p>
<a href="create_startup.php" class="btn btn-primary">Get Started</a>
</div>
<?php else: ?>
<div style="display: grid; grid-template-columns: 1fr; gap: 20px;">
<?php foreach ($myStartups as $startup):
$goal = $startup['active_goal'] ?? $startup['funding_target'];
$raised = $startup['active_raised'] ?? $startup['funding_raised'];
$isTrending = in_array($startup['id'], $trendingIds);
?>
<div class="candidate-card" style="padding: 25px; display: flex; justify-content: space-between; align-items: center; cursor: pointer;" onclick="window.location.href='startup_details.php?id=<?= $startup['id'] ?>'">
<div style="display: flex; align-items: center; gap: 20px;">
<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($startup['name'], 0, 1) ?>
</div>
<div>
<div style="font-weight: 800; font-size: 20px; margin-bottom: 6px;">
<?= htmlspecialchars($startup['name']) ?>
<?php if ($isTrending): ?>
<span class="trending-pill"><i class="fas fa-fire"></i> Trending</span>
<?php endif; ?>
</div>
<div style="font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; gap: 12px;">
<span style="padding: 4px 10px; background: rgba(0, 242, 255, 0.1); color: var(--accent-blue); border-radius: 8px; font-weight: 700; font-size: 12px; letter-spacing: 0.5px;">
<?= strtoupper($startup['round_status'] ?? 'Draft') ?>
</span>
<span style="opacity: 0.7;">Target: £<?= number_get_formatted($goal) ?></span>
</div>
</div>
</div>
<div style="display: flex; gap: 20px; align-items: center;">
<div style="text-align: right;">
<div style="font-size: 22px; font-weight: 900; color: #fff;">£<?= number_get_formatted($raised) ?></div>
<div style="font-size: 13px; color: var(--text-secondary); opacity: 0.6;">Funds Raised</div>
</div>
<?php if ($startup['round_status'] === 'Active'): ?>
<div style="display: flex; gap: 8px;">
<button onclick="event.stopPropagation(); updateRound(<?= $startup['round_id'] ?>, 'Closed')" class="btn" style="padding: 8px 12px; font-size: 11px; background: #28a745; color: #fff; border: none; border-radius: 8px;">Finish</button>
<button onclick="event.stopPropagation(); updateRound(<?= $startup['round_id'] ?>, 'Cancelled')" class="btn" style="padding: 8px 12px; font-size: 11px; background: #dc3545; color: #fff; border: none; border-radius: 8px;">Cancel</button>
</div>
<?php endif; ?>
<?php foreach ($myStartups as $startup): ?>
<div class="candidate-card" style="padding: 30px; cursor: pointer;" onclick="window.location.href='startup_details.php?id=<?= $startup['id'] ?>'">
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px;">
<div style="width: 64px; height: 64px; background: var(--surface-color); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 28px; border: 1px solid var(--border-color);">
<i class="fas fa-building" style="opacity: 0.5;"></i>
</div>
<span class="status-pill status-active" style="background: <?= $startup['status'] === 'public' ? 'rgba(76, 217, 100, 0.1)' : 'rgba(255, 255, 255, 0.05)' ?>; color: <?= $startup['status'] === 'public' ? '#4cd964' : '#999' ?>;">
<?= strtoupper($startup['status']) ?>
</span>
</div>
<?php endforeach; ?>
</div>
<h3 style="margin: 0 0 8px; font-size: 22px; font-weight: 900;"><?= htmlspecialchars($startup['name']) ?></h3>
<p style="color: var(--text-secondary); font-size: 14px; margin-bottom: 25px; line-height: 1.5; height: 42px; overflow: hidden;"><?= htmlspecialchars($startup['description']) ?></p>
<?php if ($startup['active_goal'] > 0): ?>
<div style="background: rgba(255,255,255,0.03); padding: 15px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.05);">
<div style="display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;">
<span style="color: var(--accent-blue);">Active Funding Round</span>
<span><?= round(($startup['active_raised'] / $startup['active_goal']) * 100) ?>%</span>
</div>
<div class="progress-bar" style="height: 6px; margin-bottom: 10px;">
<div class="progress-fill" style="width: <?= min(100, ($startup['active_raised'] / $startup['active_goal']) * 100) ?>%;"></div>
</div>
<div style="display: flex; justify-content: space-between; font-size: 14px; font-weight: 800;">
<span>£<?= number_get_formatted($startup['active_raised']) ?></span>
<span style="color: var(--text-secondary);">Target: £<?= number_get_formatted($startup['active_goal']) ?></span>
</div>
</div>
<?php else: ?>
<a href="start_funding_round.php?startup_id=<?= $startup['id'] ?>" class="btn" style="width: 100%; padding: 12px; font-size: 13px; font-weight: 800; background: rgba(0, 242, 255, 0.1); color: var(--accent-blue); border-radius: 12px; text-decoration: none; display: inline-block; text-align: center;">Start Funding Round</a>
<?php endif; ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php else: ?>
@ -313,6 +269,29 @@ function number_get_formatted($num) {
<i class="fas fa-minus-circle" style="margin-right: 5px;"></i> Withdraw
</button>
</div>
<!-- Recent Transactions -->
<div style="margin-top: 30px; border-top: 1px solid rgba(255,255,255,0.05); padding-top: 20px;">
<h4 style="font-size: 12px; font-weight: 800; color: #999; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 15px;">Recent Transactions</h4>
<?php if (empty($transactions)): ?>
<p style="font-size: 12px; color: var(--text-secondary); text-align: center; opacity: 0.5;">No transactions yet.</p>
<?php else: ?>
<div id="transaction-list">
<?php foreach ($transactions as $tx): ?>
<div class="transaction-item">
<div>
<div style="font-size: 13px; font-weight: 700; color: #fff;"><?= htmlspecialchars($tx['description']) ?></div>
<div style="font-size: 11px; color: #666;"><?= date('M d, H:i', strtotime($tx['created_at'])) ?></div>
</div>
<div style="font-size: 14px; font-weight: 900; color: <?= in_array($tx['type'], ['add', 'investment_in']) ? '#4cd964' : '#ff3b30' ?>;">
<?= in_array($tx['type'], ['add', 'investment_in']) ? '+' : '-' ?>£<?= number_format($tx['amount'], 2) ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<p style="font-size: 11px; color: var(--text-secondary); margin-top: 15px; text-align: center; opacity: 0.6;">
<?php if ($user['role'] === 'founder'): ?>
Manage your startup capital and dividend funds.
@ -330,11 +309,11 @@ function number_get_formatted($num) {
<a href="profile.php?id=<?= $user['id'] ?>" class="profile-link-card">
<div style="display: flex; align-items: center; gap: 20px; margin-bottom: 25px;">
<div style="width: 80px; height: 80px; background: var(--gradient-primary); border-radius: 24px; display: flex; align-items: center; justify-content: center; font-size: 32px; color: #fff; font-weight: 900; box-shadow: 0 15px 30px rgba(0, 122, 255, 0.2);">
<?= substr($user['full_name'], 0, 1) ?>
<?= substr($user['full_name'] ?? 'U', 0, 1) ?>
</div>
<div>
<div style="font-weight: 900; font-size: 22px; letter-spacing: -0.5px;"><?= htmlspecialchars($user['full_name']) ?></div>
<div style="font-size: 14px; color: var(--accent-blue); font-weight: 700; opacity: 0.8;"><?= htmlspecialchars($user['university']) ?></div>
<div style="font-weight: 900; font-size: 22px; letter-spacing: -0.5px;"><?= htmlspecialchars($user['full_name'] ?? 'User') ?></div>
<div style="font-size: 14px; color: var(--accent-blue); font-weight: 700; opacity: 0.8;"><?= htmlspecialchars($user['university'] ?? 'Student') ?></div>
</div>
</div>
</a>
@ -423,8 +402,9 @@ document.getElementById('wallet-form').addEventListener('submit', function(e) {
.then(data => {
if (data.success) {
document.getElementById('wallet-balance').innerText = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('header-wallet-balance').innerText = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
closeWalletModal();
alert(formData.get('action') === 'add' ? 'Funds added successfully!' : 'Withdrawal successful!');
location.reload(); // Reload to show new transaction
} else {
alert('Error: ' + data.error);
}

View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS wallet_transactions (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
amount DECIMAL(15,2) NOT NULL,
type ENUM('add', 'withdraw', 'investment_out', 'investment_in') NOT NULL,
description VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

View File

@ -30,6 +30,8 @@ if ($startup['round_status'] !== 'Active') {
die("This startup does not have an active funding round.");
}
$remaining = (float)($startup['funding_goal'] - $startup['funding_raised']);
$error = '';
$success = '';
@ -45,7 +47,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($amount <= 0) {
$error = "Please enter a valid investment amount.";
} elseif ($amount > $investor_balance) {
$error = "Insufficient funds in your money pot. Please add funds first.";
$error = "Insufficient funds in your money pot. Please add funds first. You currently have £" . number_format($investor_balance, 2) . ".";
} elseif ($amount > $remaining && $remaining > 0) {
$error = "The investment amount (£" . number_format($amount) . ") exceeds the remaining funding goal of £" . number_format($remaining) . ".";
} else {
db()->beginTransaction();
try {
@ -72,6 +76,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt = db()->prepare("UPDATE users SET balance = balance + ? WHERE id = ?");
$stmt->execute([$amount, $startup['founder_id']]);
// 5. Log transactions
$stmt = db()->prepare("INSERT INTO wallet_transactions (user_id, amount, type, description) VALUES (?, ?, 'investment_out', ?)");
$stmt->execute([$investor_id, $amount, "Investment in " . $startup['name']]);
$stmt = db()->prepare("INSERT INTO wallet_transactions (user_id, amount, type, description) VALUES (?, ?, 'investment_in', ?)");
$stmt->execute([$startup['founder_id'], $amount, "Investment received from investor for " . $startup['name']]);
db()->commit();
$success = "Investment of £" . number_format($amount) . " confirmed successfully! Funds moved to the founder's pot.";
header("refresh:3;url=portfolio.php");
@ -130,9 +141,6 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
<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>

View File

@ -1,26 +1,29 @@
<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
header("Location: login.php");
exit;
}
$user_id = $_SESSION['user_id'];
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
require_once __DIR__ . '/db/config.php';
$startupId = $_GET['id'] ?? null;
if (!$startupId) {
header('Location: startups.php');
header("Location: startups.php");
exit;
}
// Fetch user data
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$user = $stmt->fetch();
// Fetch startup data
$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
FROM startups s
SELECT s.*, u.full_name as founder_name, u.university as founder_university, u.bio as founder_bio, u.skills as founder_skills, u.profile_image as founder_image,
fr.funding_goal, fr.funding_raised as current_round_raised, fr.status as round_status, fr.id as round_id
FROM startups s
JOIN users u ON s.founder_id = u.id
LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active'
WHERE s.id = ?
");
@ -31,341 +34,163 @@ if (!$startup) {
die("Startup not found.");
}
// Check if user is the founder or an investor
$isFounder = ($_SESSION['user_id'] == $startup['founder_id']);
$isInvestor = ($user['role'] == 'investor');
$isFounder = ($startup['founder_id'] == $_SESSION['user_id']);
// Basic permissions check
if (!$isFounder && $startup['status'] === 'private' && !$isInvestor) {
die("You do not have permission to view this profile.");
}
// Fetch followers count
$stmt = db()->prepare("SELECT COUNT(*) FROM startup_followers WHERE startup_id = ?");
$stmt->execute([$startupId]);
$followersCount = $stmt->fetchColumn();
// Fetch funding history
$canSeeHistory = $isFounder || $isInvestor;
$fundingHistory = [];
if ($canSeeHistory) {
$stmt = db()->prepare("
SELECT i.*, u.full_name as investor_name, u.id as investor_user_id
FROM investments i
LEFT JOIN users u ON i.investor_id = u.id
WHERE i.startup_id = ? AND i.status != 'rejected'
ORDER BY i.created_at DESC
");
$stmt->execute([$startupId]);
$fundingHistory = $stmt->fetchAll();
}
// Check if current user follows
$isFollowing = false;
$stmt = db()->prepare("SELECT 1 FROM startup_followers WHERE startup_id = ? AND follower_id = ?");
$stmt->execute([$startupId, $_SESSION['user_id']]);
$isFollowing = (bool)$stmt->fetchColumn();
// Fetch approved investments for dividends calculation (Founder only)
// Fetch recent updates
$stmt = db()->prepare("SELECT * FROM startup_updates WHERE startup_id = ? ORDER BY created_at DESC LIMIT 5");
$stmt->execute([$startupId]);
$updates = $stmt->fetchAll();
// Fetch approved investments for founder view
$approvedInvestments = [];
if ($isFounder) {
$stmt = db()->prepare("
SELECT i.*, u.full_name as investor_name
FROM investments i
JOIN users u ON i.investor_id = u.id
SELECT i.*, u.full_name as investor_name, u.id as investor_user_id
FROM investments i
JOIN users u ON i.investor_id = u.id
WHERE i.startup_id = ? AND i.status = 'approved'
ORDER BY i.created_at DESC
");
$stmt->execute([$startupId]);
$approvedInvestments = $stmt->fetchAll();
// Fetch Wallet Transactions for Founder
$stmt = db()->prepare("SELECT * FROM wallet_transactions WHERE user_id = ? ORDER BY created_at DESC LIMIT 5");
$stmt->execute([$_SESSION['user_id']]);
$transactions = $stmt->fetchAll();
}
// Fetch founders
$stmt = db()->prepare("SELECT id, full_name FROM users WHERE id = ?");
$stmt->execute([$startup['founder_id']]);
$founder = $stmt->fetch();
function getNextDividendInfo($investmentDate) {
$nextDate = date('M d, Y', strtotime($investmentDate . ' + 1 month'));
return $nextDate;
}
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
// Calculate progress
$goal = $startup['active_goal'] ?: 0;
$raised = $startup['active_raised'] ?: 0;
$progress = ($goal > 0) ? round(($raised / $goal) * 100) : 0;
/**
* Helper to calculate time left for next dividend
*/
function getNextDividendInfo($createdAt) {
$created = new DateTime($createdAt);
$day = $created->format('d');
$now = new DateTime();
$thisMonth = new DateTime($now->format('Y-m-') . $day);
// If today is past the day, next is next month
if ($thisMonth <= $now) {
$next = clone $thisMonth;
$next->modify('+1 month');
} else {
$next = $thisMonth;
}
$interval = $now->diff($next);
$days = $interval->days;
return [
'date' => $next->format('M d, Y'),
'days_left' => $days
];
}
?>
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?= htmlspecialchars($startup['name']) ?> | Startup Details</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= htmlspecialchars($startup['name']) ?> — <?= 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.0.0/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--accent-blue: #00f2ff;
--surface-color: #1a1a1a;
--text-secondary: #999;
--border-color: rgba(255,255,255,0.1);
}
.card {
background: var(--surface-color);
border: 1px solid var(--border-color);
border-radius: 24px;
padding: 35px;
position: relative;
overflow: hidden;
}
.section-title {
font-size: 20px;
font-weight: 800;
margin-bottom: 25px;
display: flex; align-items: center;
gap: 12px;
}
.data-label {
font-size: 12px;
text-transform: uppercase;
letter-spacing: 1px;
color: var(--text-secondary);
margin-bottom: 8px;
}
.doc-link {
background: rgba(255,255,255,0.05);
padding: 12px 20px;
border-radius: 12px;
text-decoration: none;
color: #fff;
display: flex;
align-items: center;
gap: 10px;
font-size: 14px;
transition: all 0.2s;
border: 1px solid var(--border-color);
}
.doc-link:hover {
background: rgba(255,255,255,0.1);
transform: translateY(-2px);
}
.invest-btn {
background: var(--accent-blue);
color: #000;
padding: 16px 32px;
border-radius: 14px;
text-decoration: none;
font-weight: 800;
display: inline-flex;
align-items: center;
gap: 10px;
transition: all 0.3s;
box-shadow: 0 8px 24px rgba(0, 242, 255, 0.3);
}
.invest-btn:hover {
transform: scale(1.05);
box-shadow: 0 12px 32px rgba(0, 242, 255, 0.4);
}
.progress-bar-container {
width: 100%;
height: 12px;
background: rgba(255,255,255,0.05);
border-radius: 100px;
overflow: hidden;
margin: 20px 0;
border: 1px solid var(--border-color);
}
.progress-bar-fill {
height: 100%;
background: var(--gradient-primary);
box-shadow: 0 0 15px rgba(0, 242, 255, 0.3);
border-radius: 100px;
}
.dividend-item {
.transaction-item {
padding: 12px 0;
border-bottom: 1px solid rgba(255,255,255,0.05);
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
background: rgba(255,255,255,0.02);
border-radius: 16px;
border: 1px solid var(--border-color);
margin-bottom: 10px;
}
.btn-status-small {
padding: 10px 15px;
font-size: 12px;
font-weight: 700;
border-radius: 10px;
border: 1px solid transparent;
cursor: pointer;
transition: all 0.2s;
display: flex;
align-items: center;
gap: 6px;
background: transparent;
text-decoration: none;
}
.btn-cancel-small {
border-color: rgba(255, 59, 48, 0.3);
color: #ff3b30;
}
.btn-cancel-small:hover {
background: rgba(255, 59, 48, 0.1);
}
.btn-finish-small {
border-color: rgba(48, 209, 88, 0.3);
color: #30d158;
}
.btn-finish-small:hover {
background: rgba(48, 209, 88, 0.1);
}
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 2000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.85);
backdrop-filter: blur(8px);
}
.modal-content {
background-color: #1a1a24;
margin: 10% auto;
padding: 40px;
border: 1px solid var(--border-color);
width: 420px;
border-radius: 32px;
box-shadow: 0 25px 60px rgba(0,0,0,0.7);
.transaction-item:last-child {
border-bottom: none;
}
</style>
</head>
<body style="background: #000; color: #fff;">
<body style="background: #000; color: #fff; font-family: 'Inter', sans-serif;">
<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>
<nav style="padding: 20px 40px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.8); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 1000;">
<div style="display: flex; align-items: center; gap: 40px;">
<a href="index.php" style="text-decoration: none; display: flex; align-items: center; gap: 10px;">
<div style="width: 32px; height: 32px; background: var(--gradient-primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 18px;">G</div>
<span style="font-weight: 900; font-size: 22px; letter-spacing: -1px; color: #fff;"><?= 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">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;">
<!-- Money Pot Widget in Header -->
<div onclick="openWalletModal('add')" style="cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 5px 12px; background: rgba(0, 242, 255, 0.1); border-radius: 50px; border: 1px solid rgba(0, 242, 255, 0.2);">
<i class="fas fa-wallet" style="color: var(--accent-blue); font-size: 12px;"></i>
<span id="header-wallet-balance" style="font-size: 13px; font-weight: 800; color: #fff;">£<?= number_format($user['balance'], 2) ?></span>
</div>
<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 style="display: flex; gap: 25px;">
<a href="dashboard.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.6;">Dashboard</a>
<a href="discover.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.6;">Discover</a>
<a href="messages.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.6;">Messages</a>
</div>
</div>
</header>
<div class="container" style="padding: 60px 20px;">
<div style="max-width: 900px; margin: 0 auto;">
<?php if (isset($_GET['success'])): ?>
<div style="background: rgba(48, 209, 88, 0.1); border: 1px solid rgba(48, 209, 88, 0.3); color: #30d158; padding: 15px; border-radius: 12px; margin-bottom: 25px; font-size: 14px; text-align: center;">
Round status updated successfully!
</div>
<?php endif; ?>
<!-- Header Section -->
<div style="display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 50px;">
<div>
<div style="display: flex; align-items: center; gap: 15px; margin-bottom: 15px;">
<span style="background: rgba(0, 242, 255, 0.1); color: var(--accent-blue); padding: 6px 14px; border-radius: 100px; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;">
<?= htmlspecialchars($startup['industry']) ?>
</span>
<span style="color: var(--text-secondary); font-size: 13px;">
<i class="fas fa-map-marker-alt"></i> <?= htmlspecialchars($startup['country']) ?>
</span>
</div>
<h1 style="font-size: 48px; font-weight: 900; margin: 0; line-height: 1.1; letter-spacing: -1px;">
<?= htmlspecialchars($startup['name']) ?>
</h1>
<p style="color: var(--text-secondary); margin-top: 10px; font-size: 16px;">
Founded by <a href="profile.php?id=<?= $founder['id'] ?>" style="color: #fff; font-weight: 700; text-decoration: none; border-bottom: 1px dashed var(--accent-blue);"><?= htmlspecialchars($founder['full_name']) ?></a>
</p>
</div>
<?php if ($isInvestor): ?>
<div style="display: flex; gap: 15px;">
<a href="messages.php?chat_with=<?= $startup['founder_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="far fa-comment-dots"></i> Message Founder
</a>
<a href="invest.php?id=<?= $startup['id'] ?>" class="invest-btn">
<i class="fas fa-rocket"></i> Invest Now
</a>
</div>
<?php elseif ($isFounder): ?>
<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; ?>
<div style="display: flex; align-items: center; gap: 20px;">
<div style="background: rgba(255,255,255,0.05); padding: 8px 16px; border-radius: 50px; border: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px;">
<i class="fas fa-wallet" style="color: var(--accent-blue); font-size: 12px;"></i>
<span id="header-wallet-balance" style="font-weight: 800; font-size: 13px;">£<?= number_format($user['balance'], 2) ?></span>
</div>
<a href="logout.php" style="color: #ff3b30; text-decoration: none; font-size: 13px; font-weight: 700;">Logout</a>
</div>
</nav>
<?php if ($startup['round_status'] === 'Active'): ?>
<!-- Funding Progress -->
<section class="card" style="margin-bottom: 40px; border-color: rgba(0, 242, 255, 0.3); background: rgba(0, 242, 255, 0.02);">
<div style="display: flex; justify-content: space-between; align-items: center;">
<h2 class="section-title" style="margin-bottom: 0;"><i class="fas fa-chart-pie" style="color: var(--accent-blue);"></i> Active Funding Round</h2>
<span style="font-weight: 800; color: var(--accent-blue);"><?= $progress ?>% Complete</span>
</div>
<div class="progress-bar-container">
<div class="progress-bar-fill" style="width: <?= min(100, $progress) ?>%;"></div>
</div>
<div style="display: flex; justify-content: space-between; font-weight: 700;">
<div style="max-width: 1200px; margin: 40px auto; padding: 0 20px;">
<!-- Profile Header -->
<header class="card" style="margin-bottom: 40px; padding: 50px; position: relative; overflow: hidden;">
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 6px; background: var(--gradient-primary);"></div>
<div style="display: flex; justify-content: space-between; align-items: flex-start;">
<div style="display: flex; gap: 30px; align-items: center;">
<div style="width: 120px; height: 120px; background: var(--surface-color); border-radius: 32px; display: flex; align-items: center; justify-content: center; font-size: 52px; border: 1px solid var(--border-color); box-shadow: 0 20px 40px rgba(0,0,0,0.3);">
<i class="fas fa-building" style="opacity: 0.5;"></i>
</div>
<div>
<div style="font-size: 11px; color: var(--text-secondary); text-transform: uppercase;">Raised</div>
<div style="font-size: 20px;">£<?= number_format($raised) ?></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: 20px;">£<?= number_format($goal) ?></div>
<h1 style="font-size: 48px; font-weight: 900; margin: 0 0 10px; letter-spacing: -2px;"><?= htmlspecialchars($startup['name']) ?></h1>
<div style="display: flex; gap: 20px; color: var(--text-secondary); font-size: 16px; font-weight: 600;">
<span><i class="fas fa-tag" style="margin-right: 8px; color: var(--accent-blue);"></i> <?= htmlspecialchars($startup['industry']) ?></span>
<span><i class="fas fa-map-marker-alt" style="margin-right: 8px; color: var(--accent-blue);"></i> <?= htmlspecialchars($startup['country']) ?></span>
<span><i class="fas fa-users" style="margin-right: 8px; color: var(--accent-blue);"></i> <?= $followersCount ?> Followers</span>
</div>
</div>
</div>
<div style="display: flex; gap: 15px;">
<?php if ($isFounder): ?>
<a href="edit_startup.php?id=<?= $startupId ?>" class="btn btn-secondary" style="padding: 14px 28px; font-weight: 800;">Edit Startup</a>
<?php else: ?>
<form action="toggle_follow.php" method="POST" style="margin: 0;">
<input type="hidden" name="startup_id" value="<?= $startupId ?>">
<button type="submit" class="btn <?= $isFollowing ? 'btn-secondary' : 'btn-primary' ?>" style="padding: 14px 28px; font-weight: 800;">
<?= $isFollowing ? 'Unfollow' : 'Follow' ?>
</button>
</form>
<a href="messages.php?start_chat=<?= $startup['founder_id'] ?>" class="btn btn-secondary" style="padding: 14px 28px; font-weight: 800;">Message Founder</a>
<?php endif; ?>
</div>
</div>
</header>
<?php if ($isFounder): ?>
<div style="display: flex; gap: 15px; margin-top: 30px; border-top: 1px solid var(--border-color); padding-top: 25px;">
<form action="update_round_status.php" method="POST" style="margin: 0;" onsubmit="return confirm('Finish this round early?');">
<div style="display: grid; grid-template-columns: 1fr 400px; gap: 40px;">
<div class="content-main">
<!-- Investment Status -->
<?php if ($startup['round_status'] === 'Active'): ?>
<section class="card" style="margin-bottom: 40px; border-color: var(--accent-blue); background: rgba(0, 242, 255, 0.02);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<div>
<span style="font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent-blue);">Currently Fundraising</span>
<h2 style="font-size: 28px; font-weight: 900; margin: 5px 0 0;">Seed Round is LIVE</h2>
</div>
<?php if (!$isFounder): ?>
<a href="invest.php?id=<?= $startupId ?>" class="btn btn-primary" style="padding: 16px 32px; font-size: 16px;">Invest Now <i class="fas fa-rocket" style="margin-left: 10px;"></i></a>
<?php endif; ?>
</div>
<div style="margin-bottom: 30px;">
<div style="display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: 800; font-size: 14px;">
<span>£<?= number_format($startup['current_round_raised']) ?> raised</span>
<span style="color: var(--text-secondary);">Target: £<?= number_format($startup['funding_goal']) ?></span>
</div>
<div class="progress-bar" style="height: 12px;">
<div class="progress-fill" style="width: <?= min(100, ($startup['current_round_raised'] / $startup['funding_goal']) * 100) ?>%;"></div>
</div>
</div>
<?php if ($isFounder): ?>
<div style="display: flex; gap: 15px; padding-top: 20px; border-top: 1px solid var(--border-color);">
<form action="update_round_status.php" method="POST" style="margin: 0;" onsubmit="return confirm('Complete this funding round?');">
<input type="hidden" name="round_id" value="<?= $startup['round_id'] ?>">
<input type="hidden" name="status" value="Closed">
<button type="submit" class="btn-status-small btn-finish-small">
<i class="fas fa-check-circle"></i> Finish Round Early
<input type="hidden" name="status" value="Completed">
<button type="submit" class="btn-status-small btn-approve-small">
<i class="fas fa-check-circle"></i> Close Round (Goal Met)
</button>
</form>
<form action="update_round_status.php" method="POST" style="margin: 0;" onsubmit="return confirm('Cancel this funding round?');">
@ -390,7 +215,7 @@ function getNextDividendInfo($createdAt) {
<button onclick="openWalletModal('withdraw')" class="btn" style="padding: 10px 20px; font-size: 13px; font-weight: 800; background: rgba(255,255,255,0.05); color: #fff; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); cursor: pointer;">Withdraw</button>
</div>
</div>
<div style="display: flex; align-items: center; gap: 30px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 30px;">
<div>
<div style="font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px;">Available Capital</div>
<div id="startup-wallet-balance" style="font-size: 36px; font-weight: 900; color: #fff; margin-top: 5px;">£<?= number_format($user['balance'], 2) ?></div>
@ -400,6 +225,29 @@ function getNextDividendInfo($createdAt) {
<div style="font-size: 24px; font-weight: 900; color: var(--accent-blue); margin-top: 5px;">£<?= number_format($startup['funding_raised'], 2) ?></div>
</div>
</div>
<!-- Recent Transactions -->
<div style="border-top: 1px solid rgba(255,255,255,0.05); padding-top: 20px;">
<h4 style="font-size: 12px; font-weight: 800; color: #999; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 15px;">Recent Pot Transactions</h4>
<?php if (empty($transactions)): ?>
<p style="font-size: 12px; color: var(--text-secondary); text-align: center; opacity: 0.5;">No transactions yet.</p>
<?php else: ?>
<div id="transaction-list">
<?php foreach ($transactions as $tx): ?>
<div class="transaction-item">
<div>
<div style="font-size: 13px; font-weight: 700; color: #fff;"><?= htmlspecialchars($tx['description']) ?></div>
<div style="font-size: 11px; color: #666;"><?= date('M d, H:i', strtotime($tx['created_at'])) ?></div>
</div>
<div style="font-size: 14px; font-weight: 900; color: <?= in_array($tx['type'], ['add', 'investment_in']) ? '#4cd964' : '#ff3b30' ?>;">
<?= in_array($tx['type'], ['add', 'investment_in']) ? '+' : '-' ?>£<?= number_format($tx['amount'], 2) ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<p style="margin-top: 20px; color: var(--text-secondary); font-size: 13px; opacity: 0.8;">
<i class="fas fa-info-circle"></i> This pot holds all investments received. You can withdraw funds for business operations or add funds to cover investor dividends.
</p>
@ -418,15 +266,15 @@ function getNextDividendInfo($createdAt) {
$monthlyYield = ($inv['amount'] * ($startup['founder_return_rate'] ?? 0) / 100) / 12;
$nextPay = getNextDividendInfo($inv['created_at']);
?>
<div class="dividend-item">
<div>
<div style="font-weight: 700; font-size: 15px;"><?= htmlspecialchars($inv['investor_name']) ?></div>
<div style="font-size: 12px; color: var(--text-secondary);">Invested £<?= number_format($inv['amount']) ?></div>
</div>
<div style="text-align: right;">
<div style="font-size: 18px; font-weight: 900; color: #fff;">£<?= number_format($monthlyYield, 2) ?></div>
<div style="font-size: 11px; color: <?= $nextPay['days_left'] < 7 ? '#ff3b30' : '#30d158' ?>; font-weight: 700;">
<i class="far fa-clock"></i> <?= $nextPay['days_left'] ?> days left
<div class="candidate-card" style="padding: 20px; margin-bottom: 15px; border-color: rgba(48, 209, 88, 0.1);">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>
<div style="font-weight: 800; font-size: 18px; color: #fff;"><?= htmlspecialchars($inv['investor_name']) ?></div>
<div style="font-size: 12px; color: #999;">Investment: £<?= number_format($inv['amount']) ?></div>
</div>
<div style="text-align: right;">
<div style="font-size: 20px; font-weight: 900; color: #4cd964;">£<?= number_format($monthlyYield, 2) ?></div>
<div style="font-size: 11px; color: #999;">Next: <?= $nextPay ?></div>
</div>
</div>
</div>
@ -434,146 +282,117 @@ function getNextDividendInfo($createdAt) {
</section>
<?php endif; ?>
<!-- Product & Vision -->
<section class="card" style="margin-bottom: 40px;">
<h2 class="section-title"><i class="fas fa-eye" style="color: var(--accent-blue);"></i> Product & Vision</h2>
<p style="font-size: 18px; line-height: 1.6; color: rgba(255,255,255,0.9);">
<?= nl2br(htmlspecialchars($startup['product_service'])) ?>
</p>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 40px;">
<!-- About Section -->
<section class="card" style="margin-bottom: 40px; padding: 40px;">
<h2 class="section-title">The Vision</h2>
<div style="font-size: 18px; line-height: 1.8; color: var(--text-secondary);">
<?= nl2br(htmlspecialchars($startup['description'])) ?>
</div>
</section>
<!-- Business Details -->
<section class="card" style="margin-bottom: 40px; padding: 40px;">
<h2 class="section-title">Business Intelligence</h2>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 30px;">
<div>
<h4 style="color: var(--text-secondary); text-transform: uppercase; font-size: 12px; letter-spacing: 1px;">Business Model</h4>
<p style="font-weight: 700; font-size: 16px;"><?= htmlspecialchars($startup['business_model']) ?></p>
<h4 style="color: var(--accent-blue); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Business Model</h4>
<p style="font-size: 15px; color: var(--text-secondary);"><?= nl2br(htmlspecialchars($startup['business_model'])) ?></p>
</div>
<div>
<h4 style="color: var(--text-secondary); text-transform: uppercase; font-size: 12px; letter-spacing: 1px;">Operational Stage</h4>
<p style="font-weight: 700; font-size: 16px;"><?= htmlspecialchars($startup['operational_stage']) ?></p>
<h4 style="color: var(--accent-blue); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Product/Service</h4>
<p style="font-size: 15px; color: var(--text-secondary);"><?= nl2br(htmlspecialchars($startup['product_service'])) ?></p>
</div>
</div>
</section>
<section class="card" style="margin-bottom: 40px;">
<h2 class="section-title"><i class="fas fa-chart-line" style="color: var(--accent-blue);"></i> Financial Health</h2>
<div style="background: rgba(255,255,255,0.02); padding: 25px; border-radius: 20px; border: 1px solid var(--border-color); margin-bottom: 25px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<div>
<div class="data-label">Cash on Hand</div>
<div style="font-size: 24px; font-weight: 900; color: #4cd964;">£<?= number_format($startup['current_cash_balance']) ?></div>
</div>
<div>
<div class="data-label">Monthly Burn</div>
<div style="font-size: 24px; font-weight: 900; color: #ff3b30;">£<?= number_format($startup['burn_rate']) ?></div>
</div>
</div>
</div>
<div style="background: rgba(255,255,255,0.02); padding: 15px; border-radius: 12px; margin-bottom: 25px; border: 1px solid var(--border-color);">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px;">
<div>
<div class="data-label" style="font-size: 10px;">Outstanding Debt</div>
<div style="font-size: 14px;"><?= htmlspecialchars($startup['outstanding_debt'] ?: 'None') ?></div>
</div>
<div>
<div class="data-label" style="font-size: 10px;">Accounts Receivable/Payable</div>
<div style="font-size: 14px;"><?= htmlspecialchars($startup['accounts_receivable_payable'] ?: 'N/A') ?></div>
</div>
</div>
</div>
<h4 style="margin-bottom: 15px; font-size: 14px; text-transform: uppercase; color: var(--text-secondary); opacity: 0.7;">Historical Documentation</h4>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">
<!-- Financial Documents -->
<section class="card" style="margin-bottom: 40px; padding: 40px;">
<h2 class="section-title">Verified Data Rooms</h2>
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px;">
<?php
$docs = [
'Income Statements' => $startup['doc_income_statements'],
'Balance Sheets' => $startup['doc_balance_sheets'],
'Cash Flow' => $startup['doc_cash_flow_statements'],
'Revenue Breakdown' => $startup['doc_revenue_breakdown'],
'Gross Margin' => $startup['doc_gross_margin']
'income_statements' => 'Income Statements',
'balance_sheets' => 'Balance Sheets',
'cash_flow_statements' => 'Cash Flow Statements',
'revenue_breakdown' => 'Revenue Breakdown',
'gross_margin' => 'Gross Margin Analysis'
];
foreach ($docs as $label => $path): if ($path):
foreach ($docs as $key => $label):
$docPath = $startup['doc_' . $key] ?? '';
?>
<a href="<?= htmlspecialchars($path) ?>" target="_blank" class="doc-link">
<i class="fas fa-file-pdf"></i> <?= $label ?>
</a>
<?php endif; endforeach; ?>
<div style="padding: 20px; background: rgba(255,255,255,0.03); border-radius: 16px; border: 1px solid var(--border-color); text-align: center;">
<i class="far fa-file-excel" style="font-size: 32px; color: #2ecc71; margin-bottom: 15px;"></i>
<div style="font-size: 13px; font-weight: 700; margin-bottom: 10px;"><?= $label ?></div>
<?php if ($docPath): ?>
<a href="<?= htmlspecialchars($docPath) ?>" target="_blank" class="btn" style="font-size: 11px; padding: 8px 16px; background: rgba(0, 242, 255, 0.1); color: var(--accent-blue); width: 100%;">Download</a>
<?php else: ?>
<span style="font-size: 11px; color: #555;">Not uploaded</span>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</section>
</div>
<!-- Return Rates Comparison -->
<section class="card" style="margin-bottom: 40px; background: rgba(0, 242, 255, 0.03); border: 1px solid var(--accent-blue);">
<h2 style="margin-top: 0; margin-bottom: 25px; display: flex; align-items: center; gap: 12px;">
<i class="fas fa-percentage" style="color: var(--accent-blue);"></i> Expected Investor Returns
</h2>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<div style="padding: 20px; background: rgba(0,0,0,0.2); border-radius: 16px; border: 1px solid var(--border-color); text-align: center;">
<div style="font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Platform Recommendation</div>
<div style="font-size: 32px; font-weight: 900; color: var(--accent-blue);"><?= number_format($startup['recommended_return_rate'] ?? 5.0, 1) ?>%</div>
<div style="font-size: 11px; color: var(--text-secondary); margin-top: 5px;">AI analysis based on uploaded financials</div>
</div>
<div style="padding: 20px; background: rgba(0,0,0,0.2); border-radius: 16px; border: 1px solid var(--border-color); text-align: center;">
<div style="font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Founder's Proposal</div>
<div style="font-size: 32px; font-weight: 900; color: #fff;">
<?= $startup['founder_return_rate'] !== null ? number_format($startup['founder_return_rate'], 1) . '%' : 'N/A' ?>
</div>
<div style="font-size: 11px; color: var(--text-secondary); margin-top: 5px;">Target annual dividend yield set by founder</div>
</div>
<aside class="sidebar">
<!-- Founder Card -->
<section class="card" style="margin-bottom: 40px; padding: 30px; text-align: center;">
<h4 style="font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-secondary); margin-bottom: 25px;">The Visionary</h4>
<div style="width: 100px; height: 100px; background: var(--gradient-primary); border-radius: 30px; margin: 0 auto 20px; display: flex; align-items: center; justify-content: center; font-size: 42px; font-weight: 900; color: #fff; box-shadow: 0 15px 30px rgba(0, 122, 255, 0.2);">
<?= substr($startup['founder_name'], 0, 1) ?>
</div>
<?php if (!empty($startup['recommended_return_reasoning'])): ?>
<div style="margin-top: 20px; padding: 15px; background: rgba(255,255,255,0.03); border-radius: 12px; border: 1px solid rgba(0, 242, 255, 0.1); font-size: 13px; line-height: 1.5; color: rgba(255,255,255,0.8);">
<div style="font-weight: 700; margin-bottom: 5px; color: var(--accent-blue); text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px;">Calculation Reasoning</div>
<?= htmlspecialchars($startup['recommended_return_reasoning']) ?>
</div>
<?php endif; ?>
<h3 style="font-size: 22px; font-weight: 800; margin-bottom: 5px;"><?= htmlspecialchars($startup['founder_name']) ?></h3>
<p style="color: var(--accent-blue); font-weight: 700; font-size: 14px; margin-bottom: 20px;"><?= htmlspecialchars($startup['founder_university']) ?></p>
<div style="font-size: 14px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 25px;">
<?= htmlspecialchars($startup['founder_bio']) ?>
</div>
<div style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;">
<?php
$skills = explode(',', $startup['founder_skills'] ?? '');
foreach (array_slice($skills, 0, 3) as $skill): if(empty(trim($skill))) continue; ?>
<span style="font-size: 10px; padding: 5px 12px; background: rgba(255,255,255,0.05); border-radius: 50px; border: 1px solid var(--border-color); font-weight: 600;"><?= htmlspecialchars(trim($skill)) ?></span>
<?php endforeach; ?>
</div>
<a href="profile.php?id=<?= $startup['founder_id'] ?>" class="btn btn-secondary" style="width: 100%; margin-top: 30px; font-size: 13px; font-weight: 800;">View Founder Profile</a>
</section>
<!-- Funding History Section -->
<?php if ($canSeeHistory): ?>
<section class="card" style="margin-bottom: 40px;">
<h2 class="section-title"><i class="fas fa-history" style="color: var(--accent-blue);"></i> Funding History</h2>
<?php if (empty($fundingHistory)): ?>
<div style="padding: 40px; text-align: center; background: rgba(255,255,255,0.02); border-radius: 20px; border: 1px dashed var(--border-color);">
<p style="color: var(--text-secondary); margin: 0;">No investment history available yet.</p>
</div>
<?php else: ?>
<div style="display: flex; flex-direction: column; gap: 15px;">
<?php foreach ($fundingHistory as $inv):
$investorName = $inv['investor_name'] ?: 'Verified Investor';
?>
<div style="display: flex; align-items: center; justify-content: space-between; padding: 20px; background: rgba(255,255,255,0.03); border-radius: 18px; border: 1px solid var(--border-color);">
<div style="display: flex; align-items: center; gap: 15px;">
<?php if ($inv['investor_user_id']): ?>
<a href="profile.php?id=<?= $inv['investor_user_id'] ?>" style="text-decoration: none;">
<div style="width: 45px; height: 45px; border-radius: 12px; background: var(--surface-color); display: flex; align-items: center; justify-content: center;">
<span style="font-weight: 800; color: var(--accent-blue);"><?= substr($investorName, 0, 1) ?></span>
</div>
</a>
<?php else: ?>
<div style="width: 45px; height: 45px; border-radius: 12px; background: var(--surface-color); display: flex; align-items: center; justify-content: center;">
<span style="font-weight: 800; color: var(--accent-blue);"><?= substr($investorName, 0, 1) ?></span>
</div>
<?php endif; ?>
<div>
<div style="font-weight: 700;">
<?php if ($inv['investor_user_id']): ?>
<a href="profile.php?id=<?= $inv['investor_user_id'] ?>" style="color: inherit; text-decoration: none;"><?= htmlspecialchars($investorName) ?></a>
<?php else: ?>
<?= htmlspecialchars($investorName) ?>
<?php endif; ?>
</div>
<div style="font-size: 12px; color: var(--text-secondary);"><?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
<!-- Investors List -->
<?php if (!empty($approvedInvestments)): ?>
<section class="card" style="padding: 30px;">
<h3 style="font-size: 20px; font-weight: 800; margin-bottom: 25px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px;">Recent Investors</h3>
<div style="display: flex; flex-direction: column; gap: 20px;">
<?php foreach ($approvedInvestments as $inv):
$investorName = $inv['investor_name'] ?? 'Anonymous Investor';
?>
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="display: flex; align-items: center; gap: 15px;">
<?php if (!empty($inv['investor_image'])): ?>
<img src="<?= htmlspecialchars($inv['investor_image']) ?>" style="width: 45px; height: 45px; border-radius: 12px; object-fit: cover;">
<?php else: ?>
<div style="width: 45px; height: 45px; border-radius: 12px; background: var(--surface-color); display: flex; align-items: center; justify-content: center;">
<span style="font-weight: 800; color: var(--accent-blue);"><?= substr($investorName, 0, 1) ?></span>
</div>
</div>
<div style="text-align: right;">
<div style="font-weight: 900; color: #fff; font-size: 18px;">£<?= number_format($inv['amount']) ?></div>
<?php endif; ?>
<div>
<div style="font-weight: 700;">
<?php if ($inv['investor_user_id']): ?>
<a href="profile.php?id=<?= $inv['investor_user_id'] ?>" style="color: inherit; text-decoration: none;"><?= htmlspecialchars($investorName) ?></a>
<?php else: ?>
<?= htmlspecialchars($investorName) ?>
<?php endif; ?>
</div>
<div style="font-size: 12px; color: var(--text-secondary);"><?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div style="text-align: right;">
<div style="font-weight: 900; color: #fff; font-size: 18px;">£<?= number_format($inv['amount']) ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
</div>
</aside>
</div>
<!-- Wallet Modal -->
@ -641,7 +460,7 @@ document.getElementById('wallet-form').addEventListener('submit', function(e) {
document.getElementById('startup-wallet-balance').innerText = formattedBalance;
}
closeWalletModal();
alert(formData.get('action') === 'add' ? 'Funds added successfully!' : 'Withdrawal successful!');
location.reload(); // Reload to show new transaction
} else {
alert('Error: ' + data.error);
}
@ -652,6 +471,27 @@ document.getElementById('wallet-form').addEventListener('submit', function(e) {
});
});
function updateRound(roundId, status) {
if (confirm('Are you sure you want to ' + status.toLowerCase() + ' this funding round?')) {
const formData = new FormData();
formData.append('round_id', roundId);
formData.append('status', status);
fetch('update_round_status.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
location.reload();
} else {
alert('Error: ' + data.error);
}
});
}
}
// Close modal when clicking outside
window.onclick = function(event) {
const modal = document.getElementById('wallet-modal');
@ -662,4 +502,4 @@ window.onclick = function(event) {
</script>
</body>
</html>
</html>