151 lines
8.3 KiB
PHP
151 lines
8.3 KiB
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'founder') {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
$startup_id = (int)($_GET['id'] ?? 0);
|
|
if ($startup_id <= 0) {
|
|
header("Location: dashboard.php");
|
|
exit;
|
|
}
|
|
|
|
$stmt = db()->prepare("SELECT * FROM startups WHERE id = ? AND founder_id = ?");
|
|
$stmt->execute([$startup_id, $_SESSION['user_id']]);
|
|
$startup = $stmt->fetch();
|
|
|
|
if (!$startup) {
|
|
header("Location: dashboard.php");
|
|
exit;
|
|
}
|
|
|
|
// Check for existing active round
|
|
$stmt = db()->prepare("SELECT id FROM funding_rounds WHERE startup_id = ? AND status = 'Active'");
|
|
$stmt->execute([$startup_id]);
|
|
if ($stmt->fetch()) {
|
|
header("Location: startup_details.php?id=" . $startup_id);
|
|
exit;
|
|
}
|
|
|
|
$error = '';
|
|
$success = '';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$goal = (float)($_POST['funding_goal'] ?? 0);
|
|
$founder_rate = isset($_POST['founder_return_rate']) && $_POST['founder_return_rate'] !== '' ? (float)$_POST['founder_return_rate'] : null;
|
|
$status = $_POST['listing_status'] ?? 'public';
|
|
|
|
if ($goal < 100) {
|
|
$error = "Minimum funding goal is £100.";
|
|
}
|
|
$repayment_term = (int)($_POST["repayment_term"] ?? 12);
|
|
|
|
if (!$error) {
|
|
db()->beginTransaction();
|
|
try {
|
|
// Update startup with round-specific settings
|
|
// We also update funding_target so that general views show the current target
|
|
$stmt = db()->prepare("UPDATE startups SET status = ?, founder_return_rate = ?, funding_target = ?, repayment_term = ? WHERE id = ?");
|
|
$stmt->execute([$status, $founder_rate, $goal, $repayment_term, $startup_id]);
|
|
|
|
// Create the round
|
|
$stmt = db()->prepare("INSERT INTO funding_rounds (startup_id, funding_goal, status) VALUES (?, ?, 'Active')");
|
|
$stmt->execute([$startup_id, $goal]);
|
|
|
|
db()->commit();
|
|
$success = "Funding round launched successfully!";
|
|
header("refresh:2;url=startup_details.php?id=" . $startup_id);
|
|
} catch (Exception $e) {
|
|
db()->rollBack();
|
|
$error = "Error: " . $e->getMessage();
|
|
}
|
|
}
|
|
}
|
|
|
|
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Launch Funding Round — <?= htmlspecialchars($platformName) ?></title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&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 style="padding: 60px 20px; background: #0f0f13;">
|
|
|
|
<div class="container" style="max-width: 600px; margin: 0 auto;">
|
|
<div class="card" style="padding: 40px;">
|
|
<h1 style="font-size: 28px; font-weight: 800; margin-bottom: 10px;">Launch Funding Round</h1>
|
|
<p style="color: var(--text-secondary); margin-bottom: 30px;">
|
|
Set your investment targets and return rates for <strong><?= htmlspecialchars($startup['name']) ?></strong>.
|
|
</p>
|
|
|
|
<?php if ($error): ?>
|
|
<div style="background: rgba(255, 0, 0, 0.1); border: 1px solid rgba(255, 0, 0, 0.3); color: #ff5555; padding: 15px; border-radius: 12px; margin-bottom: 25px;">
|
|
<?= htmlspecialchars($error) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($success): ?>
|
|
<div style="background: rgba(0, 255, 0, 0.1); border: 1px solid rgba(0, 255, 0, 0.3); color: #55ff55; padding: 15px; border-radius: 12px; margin-bottom: 25px;">
|
|
<i class="fas fa-check-circle"></i> <?= htmlspecialchars($success) ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<div style="background: rgba(0, 242, 255, 0.05); border: 1px solid var(--accent-blue); padding: 20px; border-radius: 16px; margin-bottom: 30px; text-align: center;">
|
|
<div style="font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); margin-bottom: 5px;">AI Recommended Return Rate</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: 12px; color: var(--text-secondary); margin-top: 5px; line-height: 1.4;">Based on your company profile and historical financials.</div>
|
|
</div>
|
|
|
|
<form method="POST">
|
|
<div style="margin-bottom: 20px;">
|
|
<label style="display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px;">Funding Goal (£) *</label>
|
|
<input type="number" name="funding_goal" min="100" step="100" required placeholder="e.g. 50000"
|
|
value="<?= htmlspecialchars($startup['funding_target'] ?: '') ?>"
|
|
style="width: 100%; padding: 14px; background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 12px; color: #fff; font-size: 18px; font-weight: 700;">
|
|
</div>
|
|
|
|
<div style="margin-bottom: 20px;">
|
|
<label style="display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px;">Repayment Term (Months) *</label>
|
|
<input type="number" name="repayment_term" min="1" max="60" required placeholder="e.g. 12"
|
|
value="<?= htmlspecialchars($startup["repayment_term"] ?: "12") ?>"
|
|
style="width: 100%; padding: 14px; background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 12px; color: #fff; font-size: 16px; font-weight: 700;">
|
|
<small style="color: var(--text-secondary); display: block; margin-top: 8px; line-height: 1.4;">
|
|
The duration over which you will repay the investment plus interest.
|
|
</small>
|
|
</div>
|
|
<div style="margin-bottom: 25px;">
|
|
<label style="display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px;">Your Proposed Dividend (%) <span style="font-weight: 400; opacity: 0.6;">(Optional)</span></label>
|
|
<input type="number" name="founder_return_rate" step="0.1" min="0" max="100" placeholder="e.g. 8.5"
|
|
value="<?= htmlspecialchars($startup['founder_return_rate'] !== null ? $startup['founder_return_rate'] : '') ?>"
|
|
style="width: 100%; padding: 14px; background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 12px; color: #fff; font-size: 16px;">
|
|
<small style="color: var(--text-secondary); display: block; margin-top: 8px; line-height: 1.4;">
|
|
This is the annual return rate you propose to investors. It will be displayed alongside the platform recommendation.
|
|
</small>
|
|
</div>
|
|
|
|
<div style="margin-bottom: 30px;">
|
|
<label style="display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px;">Listing Status</label>
|
|
<select name="listing_status" style="width: 100%; padding: 14px; background: var(--surface-color); border: 1px solid var(--border-color); border-radius: 12px; color: #fff;">
|
|
<option value="public" <?= $startup['status'] === 'public' ? 'selected' : '' ?>>Public (Visible to all investors)</option>
|
|
<option value="private" <?= $startup['status'] === 'private' ? 'selected' : '' ?>>Private (Only visible via direct link)</option>
|
|
</select>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary" style="width: 100%; padding: 18px; font-weight: 800; font-size: 18px; border-radius: 16px;">
|
|
Go Live <i class="fas fa-rocket" style="margin-left: 10px;"></i>
|
|
</button>
|
|
<a href="startup_details.php?id=<?= $startup_id ?>" style="display: block; text-align: center; margin-top: 15px; color: var(--text-secondary); text-decoration: none; font-size: 14px;">Cancel</a>
|
|
</form>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|