v38
This commit is contained in:
parent
6171608c3c
commit
77ab52bc7f
@ -178,6 +178,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<div class="container" style="padding: 40px 20px;">
|
||||
<div style="max-width: 800px; margin: 0 auto;">
|
||||
<h1 style="font-weight: 900; font-size: 32px; margin-bottom: 30px;"><?= $existingStartup ? 'Edit' : 'Create' ?> Startup Profile</h1>
|
||||
<a href="startups.php" style="display: inline-block; margin-bottom: 20px; color: #aaa; text-decoration: none; font-size: 14px;"><i class="fas fa-arrow-left"></i> Back to Startups</a>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div style="background: rgba(255, 59, 48, 0.1); color: #ff3b30; padding: 15px; border-radius: 12px; border: 1px solid #ff3b30; margin-bottom: 25px;">
|
||||
|
||||
@ -102,6 +102,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
<main class="container" style="padding-top: 50px; padding-bottom: 80px;">
|
||||
<div style="max-width: 600px; margin: 0 auto;">
|
||||
<h1>Edit Profile</h1>
|
||||
<a href="dashboard.php" style="display: inline-block; margin-bottom: 20px; color: #aaa; text-decoration: none; font-size: 14px;"><i class="fas fa-arrow-left"></i> Back to Dashboard</a>
|
||||
<p style="color: var(--text-secondary); margin-bottom: 40px;">Manage your public presence in the <?= htmlspecialchars($platformName) ?> community.</p>
|
||||
|
||||
<?php if ($error): ?><div class="alert alert-danger" style="margin-bottom: 30px;"><?= htmlspecialchars($error) ?></div><?php endif; ?>
|
||||
|
||||
@ -87,7 +87,7 @@ function simulate_funding_progress() {
|
||||
continue;
|
||||
}
|
||||
|
||||
$status = (rand(0, 10) > 2) ? 'approved' : 'pending'; // 80% chance of being approved
|
||||
$status = 'approved'; // 80% chance of being approved
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO investments (investor_id, startup_id, funding_round_id, amount, status, created_at)
|
||||
VALUES (:iid, :sid, :frid, :amount, :status, :created)");
|
||||
|
||||
@ -47,7 +47,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Actually let's look at the database schema for investments
|
||||
$equity_pct = 0.00; // Mock logic for equity
|
||||
|
||||
$stmt = db()->prepare("INSERT INTO investments (startup_id, investor_id, funding_round_id, amount, equity_pct, status) VALUES (?, ?, ?, ?, ?, 'pending')");
|
||||
$stmt = db()->prepare("INSERT INTO investments (startup_id, investor_id, funding_round_id, amount, equity_pct, status) VALUES (?, ?, ?, ?, ?, 'approved')");
|
||||
$stmt->execute([$startupId, $investor_id, $startup['round_id'], $amount, $equity_pct]);
|
||||
|
||||
// 2. Update funding_rounds raised amount
|
||||
@ -59,7 +59,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$stmt->execute([$amount, $startupId]);
|
||||
|
||||
db()->commit();
|
||||
$success = "Investment of £" . number_format($amount) . " submitted successfully! The founder will be notified.";
|
||||
$success = "Investment of £" . number_format($amount) . " confirmed successfully!";
|
||||
header("refresh:3;url=portfolio.php");
|
||||
} catch (Exception $e) {
|
||||
db()->rollBack();
|
||||
|
||||
@ -7,22 +7,26 @@ echo "Recalculating funding totals...\n";
|
||||
db()->exec("UPDATE startups SET funding_raised = 0");
|
||||
db()->exec("UPDATE funding_rounds SET funding_raised = 0");
|
||||
|
||||
// 2. Fetch all approved/pending investments (usually we only count approved, but let's see)
|
||||
// Actually, let's count all investments that are not rejected
|
||||
$stmt = db()->query("SELECT startup_id, funding_round_id, SUM(amount) as total FROM investments WHERE status != 'rejected' GROUP BY startup_id, funding_round_id");
|
||||
$totals = $stmt->fetchAll();
|
||||
// 2. Update funding_rounds totals
|
||||
$stmt = db()->query("SELECT funding_round_id, SUM(amount) as total FROM investments WHERE status != 'rejected' GROUP BY funding_round_id");
|
||||
$roundTotals = $stmt->fetchAll();
|
||||
|
||||
foreach ($totals as $t) {
|
||||
echo "Updating Startup ID: {$t['startup_id']}, Round ID: {$t['funding_round_id']} with £{$t['total']}\n";
|
||||
|
||||
// Update funding_rounds
|
||||
foreach ($roundTotals as $t) {
|
||||
if (!$t['funding_round_id']) continue;
|
||||
echo "Updating Round ID: {$t['funding_round_id']} with £{$t['total']}\n";
|
||||
$stmt2 = db()->prepare("UPDATE funding_rounds SET funding_raised = ? WHERE id = ?");
|
||||
$stmt2->execute([$t['total'], $t['funding_round_id']]);
|
||||
|
||||
// Update startups
|
||||
}
|
||||
|
||||
// 3. Update startups totals (sum of all their rounds)
|
||||
$stmt = db()->query("SELECT startup_id, SUM(amount) as total FROM investments WHERE status != 'rejected' GROUP BY startup_id");
|
||||
$startupTotals = $stmt->fetchAll();
|
||||
|
||||
foreach ($startupTotals as $t) {
|
||||
if (!$t['startup_id']) continue;
|
||||
echo "Updating Startup ID: {$t['startup_id']} with £{$t['total']}\n";
|
||||
$stmt3 = db()->prepare("UPDATE startups SET funding_raised = ? WHERE id = ?");
|
||||
$stmt3->execute([$t['total'], $t['startup_id']]);
|
||||
}
|
||||
|
||||
echo "Done!\n";
|
||||
|
||||
echo "Done!\n";
|
||||
Loading…
x
Reference in New Issue
Block a user