v37
This commit is contained in:
parent
eb6f8a216e
commit
6171608c3c
@ -89,7 +89,7 @@ $activeRounds = $stmt->fetchAll();
|
||||
<?php foreach ($activeRounds as $round):
|
||||
$goal = $round['active_goal'];
|
||||
$raised = $round['active_raised'];
|
||||
$progress = round(($raised / ($goal ?: 1)) * 100);
|
||||
$progress = ($raised > 0 && ($raised / ($goal ?: 1)) * 100 < 1) ? 1 : round(($raised / ($goal ?: 1)) * 100);
|
||||
?>
|
||||
<div class="card" style="position: relative; padding: 35px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px;">
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
session_start();
|
||||
require_once 'db/config.php';
|
||||
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'investor') {
|
||||
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'investor') {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
@ -45,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// 1. Create investment record
|
||||
// Note: We'll assume 1% equity for every £1000 for simplicity or use a formula
|
||||
// Actually let's look at the database schema for investments
|
||||
$equity_pct = round(($amount / $startup['funding_goal']) * 10, 2); // Mock logic for equity
|
||||
$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->execute([$startupId, $investor_id, $startup['round_id'], $amount, $equity_pct]);
|
||||
|
||||
@ -312,7 +312,6 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
||||
</div>
|
||||
<div style="text-align: right;">
|
||||
<div style="font-weight: 900; color: #fff; font-size: 18px;">£<?= number_format($inv['amount']) ?></div>
|
||||
<div style="font-size: 12px; color: var(--accent-blue); font-weight: 700;"><?= $inv['equity_pct'] ?>% Equity</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@ -127,7 +127,7 @@ $myStartups = $stmt->fetchAll();
|
||||
<?php foreach ($myStartups as $startup):
|
||||
$goal = $startup['active_goal'] ?? $startup['funding_target'];
|
||||
$raised = $startup['active_raised'] ?? $startup['funding_raised'];
|
||||
$progress = round(($raised / ($goal ?: 1)) * 100);
|
||||
$progress = ($raised > 0 && ($raised / ($goal ?: 1)) * 100 < 1) ? 1 : round(($raised / ($goal ?: 1)) * 100);
|
||||
$isTrending = in_array($startup['id'], $trendingIds);
|
||||
?>
|
||||
<div class="card" style="position: relative;">
|
||||
|
||||
28
sync_funding.php
Normal file
28
sync_funding.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
echo "Recalculating funding totals...\n";
|
||||
|
||||
// 1. Reset all funding_raised to 0
|
||||
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();
|
||||
|
||||
foreach ($totals as $t) {
|
||||
echo "Updating Startup ID: {$t['startup_id']}, Round ID: {$t['funding_round_id']} with £{$t['total']}\n";
|
||||
|
||||
// Update funding_rounds
|
||||
$stmt2 = db()->prepare("UPDATE funding_rounds SET funding_raised = ? WHERE id = ?");
|
||||
$stmt2->execute([$t['total'], $t['funding_round_id']]);
|
||||
|
||||
// Update startups
|
||||
$stmt3 = db()->prepare("UPDATE startups SET funding_raised = ? WHERE id = ?");
|
||||
$stmt3->execute([$t['total'], $t['startup_id']]);
|
||||
}
|
||||
|
||||
echo "Done!\n";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user