194 lines
10 KiB
PHP
194 lines
10 KiB
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
$startup_id = (int)($_GET['id'] ?? 0);
|
|
if (!$startup_id) {
|
|
header("Location: startups.php");
|
|
exit;
|
|
}
|
|
|
|
$stmt = db()->prepare("SELECT s.*, u.full_name as founder_name, u.university as founder_uni, u.graduation_year FROM startups s JOIN users u ON s.founder_id = u.id WHERE s.id = ?");
|
|
$stmt->execute([$startup_id]);
|
|
$startup = $stmt->fetch();
|
|
|
|
if (!$startup) {
|
|
header("Location: startups.php");
|
|
exit;
|
|
}
|
|
|
|
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$user = $stmt->fetch();
|
|
|
|
$error = '';
|
|
$success = '';
|
|
|
|
// Handle Investment
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'invest') {
|
|
if ($user['role'] !== 'investor') {
|
|
$error = "Founders cannot make investments.";
|
|
} else {
|
|
$amount = (float)($_POST['amount'] ?? 0);
|
|
if ($amount < 50) {
|
|
$error = "Minimum investment is £50.";
|
|
} else {
|
|
db()->beginTransaction();
|
|
try {
|
|
$stmt = db()->prepare("INSERT INTO investments (investor_id, startup_id, amount, status) VALUES (?, ?, ?, 'approved')");
|
|
$stmt->execute([$_SESSION['user_id'], $startup_id, $amount]);
|
|
|
|
$stmt = db()->prepare("UPDATE startups SET funding_raised = funding_raised + ? WHERE id = ?");
|
|
$stmt->execute([$amount, $startup_id]);
|
|
|
|
$stmt = db()->prepare("INSERT INTO notifications (user_id, content) VALUES (?, ?)");
|
|
$stmt->execute([$startup['founder_id'], "New investment of £" . number_format($amount) . " in " . $startup['name'] . "!"]);
|
|
|
|
db()->commit();
|
|
$success = "Investment successful! You've successfully backed " . htmlspecialchars($startup['name']) . ".";
|
|
header("refresh:2;url=portfolio.php");
|
|
} catch (Exception $e) {
|
|
db()->rollBack();
|
|
$error = "Investment failed: " . $e->getMessage();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title><?= htmlspecialchars($startup['name']) ?> — <?= htmlspecialchars($platformName) ?></title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<div class="container" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
|
|
<div class="logo"><?= htmlspecialchars($platformName) ?></div>
|
|
<nav class="nav-links">
|
|
<?php if ($user['role'] === 'founder'): ?>
|
|
<a href="startups.php">My Startups</a>
|
|
<a href="discover.php">Find Partners</a>
|
|
<?php else: ?>
|
|
<a href="startups.php">Browse Startups</a>
|
|
<a href="portfolio.php">Portfolio</a>
|
|
<?php endif; ?>
|
|
<a href="messages.php">Messages</a>
|
|
<a href="notifications.php">Notifications</a>
|
|
</nav>
|
|
<div style="display: flex; align-items: center; gap: 15px;">
|
|
<a href="dashboard.php" style="color: var(--text-secondary);"><i class="fas fa-th-large"></i></a>
|
|
<a href="logout.php" class="btn btn-secondary" style="padding: 8px 16px;">Log Out</a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="container" style="padding-top: 50px; padding-bottom: 50px;">
|
|
<div style="display: grid; grid-template-columns: 2fr 1.2fr; gap: 40px;">
|
|
<div>
|
|
<div style="display: flex; align-items: center; gap: 20px; margin-bottom: 30px;">
|
|
<div style="width: 80px; height: 80px; background: var(--gradient-primary); border-radius: 24px; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 700; color: #fff; box-shadow: 0 10px 30px rgba(0, 122, 255, 0.3);">
|
|
<?= substr($startup['name'], 0, 1) ?>
|
|
</div>
|
|
<div>
|
|
<h1 style="margin-bottom: 5px;"><?= htmlspecialchars($startup['name']) ?></h1>
|
|
<div style="color: var(--text-secondary); font-size: 14px;">
|
|
Founded by <?= htmlspecialchars($startup['founder_name']) ?> (<?= htmlspecialchars($startup['founder_uni']) ?>)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card" style="margin-bottom: 30px;">
|
|
<h3>About Startup</h3>
|
|
<p style="color: var(--text-secondary); line-height: 1.8; white-space: pre-line;">
|
|
<?= htmlspecialchars($startup['description']) ?>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>Investment Terms (Dividend-Only Returns)</h3>
|
|
<div style="padding: 20px; background: rgba(0, 122, 255, 0.05); border: 1px solid rgba(0, 122, 255, 0.2); border-radius: 12px; margin-top: 15px;">
|
|
<p style="font-size: 14px; margin-bottom: 10px;"><i class="fas fa-info-circle"></i> <strong>How it works:</strong></p>
|
|
<ul style="font-size: 14px; color: var(--text-secondary); margin-left: 20px; line-height: 1.6;">
|
|
<li>Investors are entitled to a share of future profits as **dividends**.</li>
|
|
<li>No voting rights or equity control are granted to investors.</li>
|
|
<li>Returns are primarily distributed through profit-sharing mechanisms.</li>
|
|
<li>This model focuses on sustainable student-led business growth.</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="card" style="margin-bottom: 30px; background: var(--surface-color); border: 1px solid var(--border-color);">
|
|
<h3 style="margin-bottom: 25px;">Funding Progress</h3>
|
|
|
|
<div style="margin-bottom: 30px;">
|
|
<div style="display: flex; justify-content: space-between; margin-bottom: 10px;">
|
|
<span style="font-weight: 700; font-size: 24px;">£<?= number_format($startup['funding_raised'], 0) ?></span>
|
|
<span style="color: var(--text-secondary); font-size: 14px; align-self: flex-end;">of £<?= number_format($startup['funding_target'], 0) ?></span>
|
|
</div>
|
|
<div style="width: 100%; height: 12px; background: var(--border-color); border-radius: 6px; overflow: hidden;">
|
|
<div style="width: <?= min(100, ($startup['funding_raised'] / ($startup['funding_target'] ?: 1)) * 100) ?>%; height: 100%; background: var(--gradient-primary); box-shadow: 0 0 20px rgba(0, 122, 255, 0.5);"></div>
|
|
</div>
|
|
<div style="text-align: right; font-size: 12px; color: var(--text-secondary); margin-top: 8px;">
|
|
<?= round(($startup['funding_raised'] / ($startup['funding_target'] ?: 1)) * 100) ?>% Raised
|
|
</div>
|
|
</div>
|
|
|
|
<?php if ($success): ?>
|
|
<div style="background: rgba(0, 255, 0, 0.1); border: 1px solid rgba(0, 255, 0, 0.3); color: #55ff55; padding: 12px; border-radius: 8px;">
|
|
<?= htmlspecialchars($success) ?>
|
|
</div>
|
|
<?php elseif ($error): ?>
|
|
<div style="background: rgba(255, 0, 0, 0.1); border: 1px solid rgba(255, 0, 0, 0.3); color: #ff5555; padding: 12px; border-radius: 8px; margin-bottom: 20px;">
|
|
<?= htmlspecialchars($error) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!$success): ?>
|
|
<?php if ($user['role'] === 'investor'): ?>
|
|
<form method="POST">
|
|
<input type="hidden" name="action" value="invest">
|
|
<div style="margin-bottom: 20px;">
|
|
<label style="display: block; margin-bottom: 8px; font-size: 14px;">Investment Amount (£)</label>
|
|
<input type="number" name="amount" min="50" step="50" required style="width: 100%; padding: 12px; border-radius: 12px; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: #fff; font-size: 18px; font-weight: 700;">
|
|
</div>
|
|
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 15px;">Back This Project</button>
|
|
</form>
|
|
<?php elseif ($startup['founder_id'] == $_SESSION['user_id']): ?>
|
|
<div style="padding: 20px; text-align: center; border: 1px dashed var(--border-color); border-radius: 12px;">
|
|
<p style="font-size: 14px; color: var(--text-secondary); margin-bottom: 0;">This is your startup listing. You can't invest in your own project.</p>
|
|
</div>
|
|
<?php else: ?>
|
|
<div style="padding: 20px; text-align: center; border: 1px dashed var(--border-color); border-radius: 12px;">
|
|
<p style="font-size: 14px; color: var(--text-secondary); margin-bottom: 0;">Only verified investors can participate in funding rounds.</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<h3>Risk Disclosure</h3>
|
|
<p style="font-size: 12px; color: var(--text-secondary); line-height: 1.5;">
|
|
Student startups carry high risk. Dividends are not guaranteed and depend on the profitability of the venture. This is not financial advice. All student entrepreneurs are verified, but Gatsby does not conduct full financial audits of individual ideas.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
</body>
|
|
</html>
|