38873-vm/startup_details.php
Flatlogic Bot 4716313903 v78
2026-03-01 10:16:51 +00:00

762 lines
38 KiB
PHP

<?php
session_start();
require_once 'db/config.php';
require_once __DIR__ . "/sync_funding.php";
syncRepayments();
if (!isset($_SESSION['user_id'])) {
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();
$startupId = $_GET['id'] ?? null;
if (!$startupId) {
header('Location: startups.php');
exit;
}
$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
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.");
}
// Check if user is the founder or an investor
$isFounder = ($_SESSION['user_id'] == $startup['founder_id']);
$isInvestor = ($user['role'] == 'investor');
$isAnyFounder = ($user['role'] == 'founder');
// Basic permissions check
// Allow if: is the founder, OR is an investor, OR is any founder (for partnership), OR startup is public
if (!$isFounder && !$isInvestor && !$isAnyFounder && $startup['status'] === 'private') {
die("You do not have permission to view this profile.");
}
// Check if following
$stmt = db()->prepare("SELECT 1 FROM startup_followers WHERE user_id = ? AND startup_id = ?");
$stmt->execute([$user_id, $startupId]);
$isFollowing = (bool)$stmt->fetch();
// 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 the current user (investor) has an investment here
$myInvestment = null;
if ($isInvestor) {
$stmt = db()->prepare("SELECT * FROM investments WHERE investor_id = ? AND startup_id = ? AND status != 'rejected' LIMIT 1");
$stmt->execute([$user_id, $startupId]);
$myInvestment = $stmt->fetch();
}
// Fetch approved investments for dividends calculation (Founder only)
$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
WHERE i.startup_id = ? AND i.status = 'approved'
");
$stmt->execute([$startupId]);
$approvedInvestments = $stmt->fetchAll();
}
// Fetch founders
$stmt = db()->prepare("SELECT id, full_name FROM users WHERE id = ?");
$stmt->execute([$startup['founder_id']]);
$founder = $stmt->fetch();
$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;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?= htmlspecialchars($startup['name']) ?> | Startup Details</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">
<style>
.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: var(--elevated-color);
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 {
border-color: var(--accent-primary);
transform: translateY(-2px);
}
.invest-btn {
background: var(--accent-primary);
color: #000;
padding: 16px 32px;
border-radius: 999px;
text-decoration: none;
font-weight: 800;
display: inline-flex;
align-items: center;
gap: 10px;
transition: all 0.3s;
text-transform: uppercase;
font-size: 14px;
letter-spacing: 0.5px;
}
.invest-btn:hover {
background: var(--accent-secondary);
transform: scale(1.05);
}
.progress-bar-container {
width: 100%;
height: 10px;
background: var(--bg-color);
border-radius: 100px;
overflow: hidden;
margin: 20px 0;
border: 1px solid var(--border-color);
}
.progress-bar-fill {
height: 100%;
background: var(--accent-primary);
border-radius: 100px;
}
.dividend-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
background: var(--elevated-color);
border-radius: 12px;
border: 1px solid var(--border-color);
margin-bottom: 10px;
}
.btn-status-small {
padding: 10px 15px;
font-size: 12px;
font-weight: 700;
border-radius: 999px;
border: 1px solid transparent;
cursor: pointer;
transition: all 0.2s;
display: flex;
align-items: center;
gap: 6px;
background: transparent;
text-decoration: none;
text-transform: uppercase;
}
.btn-cancel-small {
border-color: var(--error-color);
color: var(--error-color);
}
.btn-cancel-small:hover {
background: var(--error-color);
color: #fff;
}
.btn-finish-small {
border-color: var(--success-color);
color: var(--success-color);
}
.btn-finish-small:hover {
background: var(--success-color);
color: #000;
}
.modal {
display: none;
position: fixed;
z-index: 2000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.9);
backdrop-filter: blur(4px);
}
.follow-btn {
padding: 16px 24px;
border-radius: 999px;
font-weight: 800;
text-transform: uppercase;
font-size: 14px;
letter-spacing: 0.5px;
cursor: pointer;
transition: all 0.3s;
display: inline-flex;
align-items: center;
gap: 10px;
border: 1px solid var(--border-color);
}
.follow-btn.following {
background: var(--accent-primary);
color: #000;
border-color: var(--accent-primary);
}
.follow-btn.not-following {
background: transparent;
color: var(--text-primary);
}
.follow-btn.not-following:hover {
border-color: var(--accent-primary);
color: var(--accent-primary);
}
.follow-btn:hover {
transform: translateY(-2px);
box-shadow: 0 4px 15px rgba(0, 255, 128, 0.2);
}
</style>
</head>
<body style="background: var(--bg-color); color: var(--text-primary);">
<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?v=<?php echo time(); ?>" alt="<?= htmlspecialchars($platformName) ?> Logo" class="logo-img">
<span class="logo-text"><?= htmlspecialchars($platformName) ?></span>
</a>
<nav class="nav-links">
<?php if ($user['role'] === 'founder'): ?>
<a href="startups.php">My Startups</a>
<a href="partners.php">Find Partners</a>
<?php else: ?>
<a href="funding_rounds.php">Founding Rounds</a>
<a href="portfolio.php">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 onclick="openWalletModal('add')" style="cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--surface-color); border-radius: 50px; border: 1px solid var(--border-color);">
<i class="fas fa-wallet" style="color: var(--accent-primary); font-size: 14px;"></i>
<span id="header-wallet-balance" style="font-size: 14px; font-weight: 800; color: #fff;">£<?= number_format($user['balance'], 2) ?></span>
</div>
<div style="display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--surface-color); border-radius: 50px; border: 1px solid var(--border-color);">
<div style="width: 24px; height: 24px; background: var(--accent-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #000; 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;">Log Out</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(0, 200, 83, 0.1); border: 1px solid var(--success-color); color: var(--success-color); padding: 15px; border-radius: 12px; margin-bottom: 25px; font-size: 14px; text-align: center; font-weight: 600;">
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: var(--surface-color); color: var(--accent-primary); padding: 6px 14px; border-radius: 100px; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; border: 1px solid var(--border-color);">
<?= 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>
<span style="color: var(--text-secondary); font-size: 13px;">
<i class="fas fa-users"></i> <span id="follower-count"><?= number_format($startup['followers_count']) ?></span> Followers
</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: var(--accent-primary); font-weight: 700; text-decoration: none; border-bottom: 1px dashed var(--accent-primary);"><?= htmlspecialchars($founder['full_name']) ?></a>
</p>
</div>
<div style="display: flex; gap: 15px;">
<?php if (!$isFounder): ?>
<button id="main-follow-btn" class="follow-btn <?= $isFollowing ? 'following' : 'not-following' ?>" onclick="toggleFollow(<?= $startup['id'] ?>)">
<i class="fas <?= $isFollowing ? 'fa-check' : 'fa-plus' ?>"></i>
<span><?= $isFollowing ? 'Following' : 'Follow' ?></span>
</button>
<?php endif; ?>
<?php if ($isInvestor): ?>
<a href="messages.php?chat_with=<?= $startup['founder_id'] ?>" class="btn btn-secondary" style="padding: 16px 24px;">
<i class="far fa-comment-dots"></i> Message Founder
</a>
<?php if ($startup['round_status'] === 'Active'): ?>
<a href="invest.php?id=<?= $startup['id'] ?>" class="invest-btn">
<i class="fas fa-rocket"></i> Invest Now
</a>
<?php endif; ?>
<?php elseif ($isFounder): ?>
<a href="create_startup.php?id=<?= $startup['id'] ?>" class="btn btn-secondary" style="padding: 16px 24px;">
<i class="fas fa-edit"></i> Edit Profile
</a>
<?php endif; ?>
</div>
</div>
<?php if ($myInvestment): ?>
<!-- My Investment Card -->
<section class="card" style="margin-bottom: 40px; border: 2px solid var(--accent-primary) !important; background: linear-gradient(145deg, rgba(0, 242, 255, 0.05), transparent);">
<h2 class="section-title"><i class="fas fa-piggy-bank" style="color: var(--accent-primary);"></i> My Investment</h2>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px;">
<div>
<div class="data-label">Invested</div>
<div style="font-size: 20px; font-weight: 900;">£<?= number_format($myInvestment['amount'], 2) ?></div>
</div>
<div>
<div class="data-label">Total Return</div>
<div style="font-size: 20px; font-weight: 900; color: var(--accent-primary);">£<?= number_format($myInvestment['total_return'], 2) ?></div>
</div>
<div>
<div class="data-label">Monthly Div</div>
<div style="font-size: 20px; font-weight: 900; color: #4cd964;">£<?= number_format($myInvestment['monthly_dividend'], 2) ?></div>
</div>
<div>
<div class="data-label">Next Payment</div>
<div style="font-size: 16px; font-weight: 900;"><?= date('M d, Y', strtotime($myInvestment['next_payment_date'])) ?></div>
</div>
</div>
<div style="margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.05); display: flex; justify-content: space-between; align-items: center;">
<div style="font-size: 13px; color: var(--text-secondary);">
Interest: <strong><?= number_format($myInvestment['interest_rate'], 1) ?>%</strong> |
Term: <strong><?= $myInvestment['repayment_term'] ?> Months</strong> |
Status: <strong style="color: var(--accent-primary);"><?= ($myInvestment['status'] === 'approved' ? 'ACTIVE' : strtoupper($myInvestment['status'])) ?></strong>
</div>
<a href="portfolio.php" class="btn btn-secondary" style="padding: 8px 16px; font-size: 12px;">Full Portfolio</a>
</div>
</section>
<?php endif; ?>
<?php if ($startup['round_status'] === 'Active'): ?>
<!-- Funding Progress -->
<section class="card" style="margin-bottom: 40px;">
<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-primary);"></i> Active Funding Round</h2>
<span style="font-weight: 800; color: var(--accent-primary);"><?= $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>
<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>
</div>
</div>
<?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?');">
<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
</button>
</form>
<form action="update_round_status.php" method="POST" style="margin: 0;" onsubmit="return confirm('Cancel this funding round?');">
<input type="hidden" name="round_id" value="<?= $startup['round_id'] ?>">
<input type="hidden" name="status" value="Cancelled">
<button type="submit" class="btn-status-small btn-cancel-small">
<i class="fas fa-times-circle"></i> Cancel Round
</button>
</form>
</div>
<?php endif; ?>
</section>
<?php endif; ?>
<?php if ($isFounder): ?>
<!-- Money Pot (Founder View) -->
<section class="card" style="margin-bottom: 40px; background: var(--elevated-color) !important;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<h2 class="section-title" style="margin-bottom: 0;"><i class="fas fa-wallet" style="color: var(--accent-primary);"></i> Startup Money Pot</h2>
<div style="display: flex; gap: 10px;">
<button onclick="openWalletModal('add')" class="btn btn-primary" style="padding: 10px 20px; font-size: 13px;">Add Funds</button>
<button onclick="openWalletModal('withdraw')" class="btn btn-secondary" style="padding: 10px 20px; font-size: 13px;">Withdraw</button>
</div>
</div>
<div style="display: flex; align-items: center; gap: 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>
</div>
<div style="padding-left: 30px; border-left: 1px solid var(--border-color);">
<div style="font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px;">Total Investments Received</div>
<div style="font-size: 24px; font-weight: 900; color: var(--accent-primary); margin-top: 5px;">£<?= number_format($startup['funding_raised'], 2) ?></div>
</div>
</div>
</section>
<?php endif; ?>
<?php if ($isFounder && !empty($approvedInvestments)): ?>
<!-- Dividend Management (Founder Only) -->
<section class="card" style="margin-bottom: 40px; border-color: var(--success-color) !important;">
<h2 class="section-title"><i class="fas fa-hand-holding-usd" style="color: var(--success-color);"></i> Active Repayments</h2>
<div style="margin-bottom: 20px;">
<p style="color: var(--text-secondary); font-size: 14px;">Tracking monthly payments to your active investors.</p>
</div>
<?php foreach ($approvedInvestments as $inv):
$monthlyYield = $inv['monthly_dividend'];
$nextPayDate = $inv['next_payment_date'];
$daysLeft = (new DateTime())->diff(new DateTime($nextPayDate))->format("%r%a");
?>
<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);">
£<?= number_format($inv['amount']) ?> @ <?= number_format($inv['interest_rate'] ?: 0, 1) ?>% over <?= $inv['repayment_term'] ?: 12 ?>mo
</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: <?= $daysLeft < 7 ? 'var(--error-color)' : 'var(--success-color)' ?>; font-weight: 700;">
<i class="far fa-clock"></i> Next: <?= date('M d', strtotime($nextPayDate)) ?> (<?= $daysLeft ?>d)
</div>
</div>
</div>
<?php endforeach; ?>
</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-primary);"></i> Product & Vision</h2>
<p style="font-size: 18px; line-height: 1.6; color: var(--text-primary);">
<?= nl2br(htmlspecialchars($startup['product_service'])) ?>
</p>
</section>
<!-- Partnership & Co-founder Info -->
<?php if (!empty($startup["cofounder_equity_pct"]) || !empty($startup["cofounder_responsibilities"])): ?>
<section class="card" style="margin-bottom: 40px; border-color: var(--accent-secondary) !important;">
<h2 class="section-title"><i class="fas fa-handshake" style="color: var(--accent-secondary);"></i> Partnership & Co-founder Info</h2>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px;">
<div style="padding: 20px; background: var(--bg-color); border-radius: 12px; border: 1px solid var(--border-color);">
<div style="font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;">Co-founder Equity</div>
<div style="font-size: 24px; font-weight: 900; color: var(--accent-secondary);"><?= number_format($startup["cofounder_equity_pct"] ?? 0, 1) ?>%</div>
</div>
<div style="padding: 20px; background: var(--bg-color); border-radius: 12px; border: 1px solid var(--border-color);">
<div style="font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;">Equity Type</div>
<div style="font-size: 24px; font-weight: 900; color: #fff;"><?= htmlspecialchars($startup["cofounder_equity_type"] ?: "Ordinary") ?></div>
</div>
</div>
<?php if ($startup["cofounder_responsibilities"]): ?>
<div style="margin-bottom: 20px;">
<div class="data-label" style="color: var(--accent-secondary);">Core Responsibilities</div>
<div style="font-size: 15px; line-height: 1.6; color: var(--text-primary); background: var(--bg-color); padding: 15px; border-radius: 12px; border: 1px solid var(--border-color);">
<?= nl2br(htmlspecialchars($startup["cofounder_responsibilities"])) ?>
</div>
</div>
<?php endif; ?>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<?php if ($startup["desired_cofounder_experience"]): ?>
<div>
<div class="data-label">Desired Experience</div>
<div style="font-size: 14px; color: var(--text-secondary);"><?= htmlspecialchars($startup["desired_cofounder_experience"]) ?></div>
</div>
<?php endif; ?>
<?php if ($startup["cofounder_commitment"]): ?>
<div>
<div class="data-label">Commitment Required</div>
<div style="font-size: 14px; color: var(--text-secondary);"><?= htmlspecialchars($startup["cofounder_commitment"]) ?></div>
</div>
<?php endif; ?>
</div>
<?php if ($startup["other_partnership_details"]): ?>
<div style="margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-color);">
<div class="data-label">Other Details</div>
<div style="font-size: 14px; color: var(--text-secondary);"><?= nl2br(htmlspecialchars($startup["other_partnership_details"])) ?></div>
</div>
<?php endif; ?>
</section>
<?php endif; ?>
<!-- Financial Health -->
<section class="card" style="margin-bottom: 40px;">
<h2 class="section-title"><i class="fas fa-chart-line" style="color: var(--accent-primary);"></i> Financial Health</h2>
<div style="background: var(--bg-color); padding: 25px; border-radius: 12px; 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: var(--success-color);">£<?= 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: var(--error-color);">£<?= number_format($startup['burn_rate']) ?></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;">
<?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']
];
foreach ($docs as $label => $path): if ($path):
?>
<a href="<?= htmlspecialchars($path) ?>" target="_blank" class="doc-link">
<i class="fas fa-file-pdf"></i> <?= $label ?>
</a>
<?php endif; endforeach; ?>
</div>
</section>
<!-- Return Rates Comparison -->
<section class="card" style="margin-bottom: 40px; border-color: var(--accent-primary) !important;">
<h2 style="margin-top: 0; margin-bottom: 25px; display: flex; align-items: center; gap: 12px;">
<i class="fas fa-percentage" style="color: var(--accent-primary);"></i> Investment Terms
</h2>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px;">
<div style="padding: 20px; background: var(--bg-color); border-radius: 12px; border: 1px solid var(--border-color); text-align: center;">
<div style="font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Interest Rate</div>
<div style="font-size: 28px; font-weight: 900; color: var(--accent-primary);"><?= number_format($startup['founder_return_rate'] ?? 0, 1) ?>%</div>
</div>
<div style="padding: 20px; background: var(--bg-color); border-radius: 12px; border: 1px solid var(--border-color); text-align: center;">
<div style="font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Repayment Term</div>
<div style="font-size: 28px; font-weight: 900; color: #fff;"><?= $startup['repayment_term'] ?? 12 ?> Mo</div>
</div>
<div style="padding: 20px; background: var(--bg-color); border-radius: 12px; border: 1px solid var(--border-color); text-align: center;">
<div style="font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Min Invest</div>
<div style="font-size: 28px; font-weight: 900; color: #fff;">£50</div>
</div>
</div>
<?php if (!empty($startup['recommended_return_reasoning'])): ?>
<div style="margin-top: 20px; padding: 15px; background: var(--surface-color); border-radius: 12px; border: 1px solid var(--border-color); font-size: 13px; line-height: 1.5; color: var(--text-secondary);">
<div style="font-weight: 700; margin-bottom: 5px; color: var(--accent-primary); text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px;">AI Yield Recommendation: <?= number_format($startup['recommended_return_rate'] ?? 5.0, 1) ?>%</div>
<?= htmlspecialchars($startup['recommended_return_reasoning']) ?>
</div>
<?php endif; ?>
</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-primary);"></i> Funding History</h2>
<?php if (empty($fundingHistory)): ?>
<div style="padding: 40px; text-align: center; background: var(--bg-color); border-radius: 12px; 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: var(--elevated-color); border-radius: 12px; border: 1px solid var(--border-color);">
<div style="display: flex; align-items: center; gap: 15px;">
<div style="width: 45px; height: 45px; border-radius: 8px; background: var(--surface-color); display: flex; align-items: center; justify-content: center;">
<span style="font-weight: 800; color: var(--accent-primary);"><?= substr($investorName, 0, 1) ?></span>
</div>
<div>
<div style="font-weight: 700; color: var(--text-primary);"><?= htmlspecialchars($investorName) ?></div>
<div style="font-size: 12px; color: var(--text-secondary);"><?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
</div>
</div>
<div style="text-align: right;">
<div style="font-weight: 900; color: var(--text-primary); font-size: 18px;">£<?= number_format($inv['amount']) ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
<?php endif; ?>
</div>
</div>
<!-- Wallet Modal -->
<div id="wallet-modal" class="modal">
<div class="modal-content" style="max-width: 420px; margin: 10% auto;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;">
<h2 id="modal-title" style="margin: 0; font-size: 24px; font-weight: 900; color: #fff;">Add Funds</h2>
<button onclick="closeWalletModal()" style="background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 20px;"><i class="fas fa-times"></i></button>
</div>
<form id="wallet-form">
<input type="hidden" id="wallet-action" name="action" value="add">
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 12px; font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; font-weight: 700;">Amount (£)</label>
<input type="number" id="wallet-amount" name="amount" min="1" step="0.01" required placeholder="0.00"
style="width: 100%; padding: 18px; background: var(--bg-color); border: 1px solid var(--border-color); border-radius: 12px; color: #fff; font-size: 24px; font-weight: 800;">
</div>
<button type="submit" id="wallet-submit-btn" class="btn btn-primary" style="width: 100%; padding: 18px; font-size: 16px;">Confirm</button>
</form>
</div>
</div>
<footer style="padding: 60px 0; border-top: 1px solid var(--border-color); margin-top: 100px; text-align: center;">
<p style="color: var(--text-secondary); font-size: 14px;">&copy; <?= date('Y') ?> <?= htmlspecialchars($platformName) ?>. All rights reserved.</p>
</footer>
<script>
function openWalletModal(action) {
const modal = document.getElementById('wallet-modal');
const title = document.getElementById('modal-title');
const actionInput = document.getElementById('wallet-action');
const submitBtn = document.getElementById('wallet-submit-btn');
actionInput.value = action;
if (action === 'add') {
title.innerText = 'Add Funds';
submitBtn.innerText = 'Confirm Deposit';
submitBtn.className = 'btn btn-primary';
} else {
title.innerText = 'Withdraw Funds';
submitBtn.innerText = 'Confirm Withdrawal';
submitBtn.className = 'btn btn-secondary';
}
modal.style.display = 'block';
}
function closeWalletModal() {
document.getElementById('wallet-modal').style.display = 'none';
}
document.getElementById('wallet-form').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
fetch('api/wallet_transaction.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
const formattedBalance = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('header-wallet-balance').innerText = formattedBalance;
if (document.getElementById('startup-wallet-balance')) {
document.getElementById('startup-wallet-balance').innerText = formattedBalance;
}
closeWalletModal();
alert(formData.get('action') === 'add' ? 'Funds added successfully!' : 'Withdrawal successful!');
} else {
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('An unexpected error occurred.');
});
});
window.onclick = function(event) {
const modal = document.getElementById('wallet-modal');
if (event.target == modal) {
closeWalletModal();
}
}
function toggleFollow(startupId) {
const btn = document.getElementById('main-follow-btn');
const icon = btn.querySelector('i');
const span = btn.querySelector('span');
const countSpan = document.getElementById('follower-count');
const formData = new FormData();
formData.append('startup_id', startupId);
fetch('api/follow_startup.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
if (data.action === 'followed') {
btn.classList.remove('not-following');
btn.classList.add('following');
icon.classList.remove('fa-plus');
icon.classList.add('fa-check');
span.innerText = 'Following';
} else {
btn.classList.remove('following');
btn.classList.add('not-following');
icon.classList.remove('fa-check');
icon.classList.add('fa-plus');
span.innerText = 'Follow';
}
if (countSpan && (data.new_count !== undefined)) {
countSpan.innerText = data.new_count.toLocaleString();
}
} else {
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
});
}
</script>
</body>
</html>