+
-
No startups registered
-
Ready to change the world? Start by registering your venture.
-
Get Started
+
Ready to share your vision with the world?
+
Start Your First Round
-
-
-
-
-
+
+
+
+
+
+ = substr($startup['name'], 0, 1) ?>
+
+
+
+ = htmlspecialchars($startup['name']) ?>
+
+ Trending
+
+
+
+
+ = strtoupper($startup['round_status'] ?? 'Draft') ?>
+
+ Target: £= number_get_formatted($goal) ?>
+
+
+
+
+
+
£= number_get_formatted($raised) ?>
+
Funds Raised
+
+
+
+
+
+
+
-
- = strtoupper($startup['status']) ?>
-
-
= htmlspecialchars($startup['name']) ?>
-
= htmlspecialchars($startup['description']) ?>
-
- 0): ?>
-
-
- Active Funding Round
- = round(($startup['active_raised'] / $startup['active_goal']) * 100) ?>%
-
-
-
- £= number_get_formatted($startup['active_raised']) ?>
- Target: £= number_get_formatted($startup['active_goal']) ?>
-
-
-
-
Start Funding Round
-
-
-
+
+
@@ -239,7 +313,6 @@ function number_get_formatted($num) {
Withdraw
-
Manage your startup capital and dividend funds.
@@ -257,11 +330,11 @@ function number_get_formatted($num) {
- = substr($user['full_name'] ?? 'U', 0, 1) ?>
+ = substr($user['full_name'], 0, 1) ?>
-
= htmlspecialchars($user['full_name'] ?? 'User') ?>
-
= htmlspecialchars($user['university'] ?? 'Student') ?>
+
= htmlspecialchars($user['full_name']) ?>
+
= htmlspecialchars($user['university']) ?>
@@ -349,10 +422,9 @@ document.getElementById('wallet-form').addEventListener('submit', function(e) {
.then(response => response.json())
.then(data => {
if (data.success) {
- const formattedBalance = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
- document.getElementById('wallet-balance').innerText = formattedBalance;
- document.getElementById('header-wallet-balance').innerText = formattedBalance;
+ document.getElementById('wallet-balance').innerText = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
closeWalletModal();
+ alert(formData.get('action') === 'add' ? 'Funds added successfully!' : 'Withdrawal successful!');
} else {
alert('Error: ' + data.error);
}
diff --git a/db/migrations/20_wallet_transactions.sql b/db/migrations/20_wallet_transactions.sql
deleted file mode 100644
index 152d6c0..0000000
--- a/db/migrations/20_wallet_transactions.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-CREATE TABLE IF NOT EXISTS wallet_transactions (
- id INT AUTO_INCREMENT PRIMARY KEY,
- user_id INT NOT NULL,
- amount DECIMAL(15,2) NOT NULL,
- type ENUM('add', 'withdraw', 'investment_out', 'investment_in') NOT NULL,
- description VARCHAR(255),
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
-);
diff --git a/invest.php b/invest.php
index 1e83e6f..2168d9f 100644
--- a/invest.php
+++ b/invest.php
@@ -30,8 +30,6 @@ if ($startup['round_status'] !== 'Active') {
die("This startup does not have an active funding round.");
}
-$remaining = (float)($startup['funding_goal'] - $startup['funding_raised']);
-
$error = '';
$success = '';
@@ -47,9 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($amount <= 0) {
$error = "Please enter a valid investment amount.";
} elseif ($amount > $investor_balance) {
- $error = "Insufficient funds in your money pot. Please add funds first. You currently have £" . number_format($investor_balance, 2) . ".";
- } elseif ($amount > $remaining && $remaining > 0) {
- $error = "The investment amount (£" . number_format($amount) . ") exceeds the remaining funding goal of £" . number_format($remaining) . ".";
+ $error = "Insufficient funds in your money pot. Please add funds first.";
} else {
db()->beginTransaction();
try {
@@ -76,13 +72,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt = db()->prepare("UPDATE users SET balance = balance + ? WHERE id = ?");
$stmt->execute([$amount, $startup['founder_id']]);
- // 5. Log transactions
- $stmt = db()->prepare("INSERT INTO wallet_transactions (user_id, amount, type, description) VALUES (?, ?, 'investment_out', ?)");
- $stmt->execute([$investor_id, $amount, "Investment in " . $startup['name']]);
-
- $stmt = db()->prepare("INSERT INTO wallet_transactions (user_id, amount, type, description) VALUES (?, ?, 'investment_in', ?)");
- $stmt->execute([$startup['founder_id'], $amount, "Investment received from investor for " . $startup['name']]);
-
db()->commit();
$success = "Investment of £" . number_format($amount) . " confirmed successfully! Funds moved to the founder's pot.";
header("refresh:3;url=portfolio.php");
@@ -141,6 +130,9 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
Already Raised
£= number_format($startup['funding_raised']) ?>
Remaining
£= number_format(max(0, $remaining)) ?>
diff --git a/startup_details.php b/startup_details.php
index a52fcd5..24c87a9 100644
--- a/startup_details.php
+++ b/startup_details.php
@@ -1,29 +1,26 @@
prepare("SELECT * FROM users WHERE id = ?");
+$stmt->execute([$user_id]);
+$user = $stmt->fetch();
$startupId = $_GET['id'] ?? null;
if (!$startupId) {
- header("Location: startups.php");
+ header('Location: startups.php');
exit;
}
-// Fetch user data
-$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
-$stmt->execute([$_SESSION['user_id']]);
-$user = $stmt->fetch();
-
-// Fetch startup data
$stmt = db()->prepare("
- SELECT s.*, u.full_name as founder_name, u.university as founder_university, u.bio as founder_bio, u.skills as founder_skills, u.profile_image as founder_image,
- fr.funding_goal, fr.funding_raised as current_round_raised, fr.status as round_status, fr.id as round_id
- FROM startups s
- JOIN users u ON s.founder_id = u.id
+ 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 = ?
");
@@ -34,146 +31,341 @@ if (!$startup) {
die("Startup not found.");
}
-$isFounder = ($startup['founder_id'] == $_SESSION['user_id']);
+// Check if user is the founder or an investor
+$isFounder = ($_SESSION['user_id'] == $startup['founder_id']);
+$isInvestor = ($user['role'] == 'investor');
-// Fetch followers count
-$stmt = db()->prepare("SELECT COUNT(*) FROM startup_followers WHERE startup_id = ?");
-$stmt->execute([$startupId]);
-$followersCount = $stmt->fetchColumn();
+// Basic permissions check
+if (!$isFounder && $startup['status'] === 'private' && !$isInvestor) {
+ die("You do not have permission to view this profile.");
+}
-// Check if current user follows
-$isFollowing = false;
-$stmt = db()->prepare("SELECT 1 FROM startup_followers WHERE startup_id = ? AND follower_id = ?");
-$stmt->execute([$startupId, $_SESSION['user_id']]);
-$isFollowing = (bool)$stmt->fetchColumn();
+// 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();
+}
-// Fetch recent updates
-$stmt = db()->prepare("SELECT * FROM startup_updates WHERE startup_id = ? ORDER BY created_at DESC LIMIT 5");
-$stmt->execute([$startupId]);
-$updates = $stmt->fetchAll();
-
-// Fetch approved investments for founder view
+// Fetch approved investments for dividends calculation (Founder only)
$approvedInvestments = [];
if ($isFounder) {
$stmt = db()->prepare("
- SELECT i.*, u.full_name as investor_name, u.id as investor_user_id
- FROM investments i
- JOIN users u ON i.investor_id = u.id
+ 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'
- ORDER BY i.created_at DESC
");
$stmt->execute([$startupId]);
$approvedInvestments = $stmt->fetchAll();
}
-function getNextDividendInfo($investmentDate) {
- $nextDate = date('M d, Y', strtotime($investmentDate . ' + 1 month'));
- return $nextDate;
-}
+// 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;
+
+/**
+ * Helper to calculate time left for next dividend
+ */
+function getNextDividendInfo($createdAt) {
+ $created = new DateTime($createdAt);
+ $day = $created->format('d');
+
+ $now = new DateTime();
+ $thisMonth = new DateTime($now->format('Y-m-') . $day);
+
+ // If today is past the day, next is next month
+ if ($thisMonth <= $now) {
+ $next = clone $thisMonth;
+ $next->modify('+1 month');
+ } else {
+ $next = $thisMonth;
+ }
+
+ $interval = $now->diff($next);
+ $days = $interval->days;
+
+ return [
+ 'date' => $next->format('M d, Y'),
+ 'days_left' => $days
+ ];
+}
?>
-
+
-
-
-
= htmlspecialchars($startup['name']) ?> — = htmlspecialchars($platformName) ?>
+
+
= htmlspecialchars($startup['name']) ?> | Startup Details
-
+
+
-
+
-