From cab62424f83bcfe6110bbf9c36d09f3a2ca5a50a Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 28 Feb 2026 22:48:17 +0000 Subject: [PATCH] v56 --- api/wallet_transaction.php | 12 +++++------- dashboard.php | 26 +++++++++++++++++++------- invest.php | 18 ++++++++++++------ 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/api/wallet_transaction.php b/api/wallet_transaction.php index d5fa388..afed15a 100644 --- a/api/wallet_transaction.php +++ b/api/wallet_transaction.php @@ -14,7 +14,7 @@ $amount = (float)($_POST['amount'] ?? 0); if ($amount <= 0) { header('Content-Type: application/json'); - echo json_encode(['success' => false, 'error' => 'Invalid amount']); + echo json_encode(['success' => false, 'error' => 'Please enter a valid amount greater than zero.']); exit; } @@ -27,7 +27,7 @@ try { $user = $stmt->fetch(); if (!$user) { - throw new Exception("User not found"); + throw new Exception("User account not found."); } $current_balance = (float)$user['balance']; @@ -37,13 +37,11 @@ try { $stmt = db()->prepare("UPDATE users SET balance = ? WHERE id = ?"); $stmt->execute([$new_balance, $user_id]); - // Log transaction (optional but good practice, maybe later) - db()->commit(); echo json_encode(['success' => true, 'new_balance' => $new_balance]); } elseif ($action === 'withdraw') { if ($current_balance < $amount) { - throw new Exception("Insufficient funds"); + throw new Exception("Insufficient funds. Your current balance is £" . number_format($current_balance, 2) . "."); } $new_balance = $current_balance - $amount; @@ -53,11 +51,11 @@ try { db()->commit(); echo json_encode(['success' => true, 'new_balance' => $new_balance]); } else { - throw new Exception("Invalid action"); + throw new Exception("Invalid wallet action requested."); } } catch (Exception $e) { db()->rollBack(); header('Content-Type: application/json'); echo json_encode(['success' => false, 'error' => $e->getMessage()]); -} +} \ No newline at end of file diff --git a/dashboard.php b/dashboard.php index 53a0e44..c9a3661 100644 --- a/dashboard.php +++ b/dashboard.php @@ -123,22 +123,22 @@ function number_get_formatted($num) { .modal { display: none; position: fixed; - z-index: 1000; + z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; - background-color: rgba(0,0,0,0.8); - backdrop-filter: blur(5px); + background-color: rgba(0,0,0,0.85); + backdrop-filter: blur(8px); } .modal-content { background-color: #1a1a24; margin: 10% auto; padding: 40px; border: 1px solid var(--border-color); - width: 400px; + width: 420px; border-radius: 32px; - box-shadow: 0 25px 50px rgba(0,0,0,0.5); + box-shadow: 0 25px 60px rgba(0,0,0,0.7); } @@ -162,6 +162,12 @@ function number_get_formatted($num) { Messages
+ +
+ + £ +
+ @@ -422,7 +428,13 @@ document.getElementById('wallet-form').addEventListener('submit', function(e) { .then(response => response.json()) .then(data => { if (data.success) { - document.getElementById('wallet-balance').innerText = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}); + const formattedBalance = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}); + if (document.getElementById('wallet-balance')) { + document.getElementById('wallet-balance').innerText = formattedBalance; + } + if (document.getElementById('header-wallet-balance')) { + document.getElementById('header-wallet-balance').innerText = formattedBalance; + } closeWalletModal(); alert(formData.get('action') === 'add' ? 'Funds added successfully!' : 'Withdrawal successful!'); } else { @@ -466,4 +478,4 @@ window.onclick = function(event) { - \ No newline at end of file + diff --git a/invest.php b/invest.php index 2168d9f..069e73c 100644 --- a/invest.php +++ b/invest.php @@ -41,11 +41,14 @@ $investor_balance = (float)$stmt->fetchColumn(); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $amount = (float)($_POST['amount'] ?? 0); $investor_id = $_SESSION['user_id']; + $remaining = $startup['funding_goal'] - $startup['funding_raised']; 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."; + } elseif ($amount > $remaining) { + $error = "You cannot invest more than the remaining goal (£" . number_format($remaining, 2) . ")."; } else { db()->beginTransaction(); try { @@ -73,7 +76,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt->execute([$amount, $startup['founder_id']]); db()->commit(); - $success = "Investment of £" . number_format($amount) . " confirmed successfully! Funds moved to the founder's pot."; + $success = "Investment of £" . number_format($amount, 2) . " confirmed successfully! Funds moved to the founder's pot."; header("refresh:3;url=portfolio.php"); } catch (Exception $e) { db()->rollBack(); @@ -89,6 +92,9 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; Invest in <?= htmlspecialchars($startup['name']) ?> | <?= htmlspecialchars($platformName) ?> + + + @@ -124,25 +130,25 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
Funding Goal - £ + £
Already Raised - £ + £
Remaining - £ + £
-
@@ -156,4 +162,4 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
- \ No newline at end of file +