This commit is contained in:
Flatlogic Bot 2026-02-28 22:20:09 +00:00
parent 98fedc4d56
commit d9f48ce404
6 changed files with 504 additions and 24 deletions

View File

@ -0,0 +1,63 @@
<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id'])) {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => 'Unauthorized']);
exit;
}
$user_id = $_SESSION['user_id'];
$action = $_POST['action'] ?? '';
$amount = (float)($_POST['amount'] ?? 0);
if ($amount <= 0) {
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => 'Invalid amount']);
exit;
}
try {
db()->beginTransaction();
// Fetch current balance
$stmt = db()->prepare("SELECT balance FROM users WHERE id = ? FOR UPDATE");
$stmt->execute([$user_id]);
$user = $stmt->fetch();
if (!$user) {
throw new Exception("User not found");
}
$current_balance = (float)$user['balance'];
if ($action === 'add') {
$new_balance = $current_balance + $amount;
$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");
}
$new_balance = $current_balance - $amount;
$stmt = db()->prepare("UPDATE users SET balance = ? WHERE id = ?");
$stmt->execute([$new_balance, $user_id]);
db()->commit();
echo json_encode(['success' => true, 'new_balance' => $new_balance]);
} else {
throw new Exception("Invalid action");
}
} catch (Exception $e) {
db()->rollBack();
header('Content-Type: application/json');
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}

View File

@ -65,10 +65,10 @@ $myInvestments = [];
if ($user['role'] === 'founder') {
$stmt = db()->prepare("
SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status
SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status, fr.id as round_id
FROM startups s
LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active'
WHERE s.founder_id = ?
WHERE s.user_id = ?
ORDER BY s.created_at DESC
");
$stmt->execute([$_SESSION['user_id']]);
@ -118,6 +118,28 @@ function number_get_formatted($num) {
.profile-link-card:hover {
transform: translateY(-2px);
}
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.8);
backdrop-filter: blur(5px);
}
.modal-content {
background-color: #1a1a24;
margin: 10% auto;
padding: 40px;
border: 1px solid var(--border-color);
width: 400px;
border-radius: 32px;
box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}
</style>
</head>
<body>
@ -172,7 +194,9 @@ function number_get_formatted($num) {
<div class="card" style="margin-bottom: 40px; padding: 35px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;">
<h3 style="margin: 0; font-size: 24px; font-weight: 800;">My Ventures</h3>
<a href="create_startup.php" class="btn btn-primary" style="padding: 12px 24px; font-size: 14px;">+ Launch Startup</a>
<div style="display: flex; gap: 10px;">
<a href="create_startup.php" class="btn btn-primary" style="padding: 12px 24px; font-size: 14px;">+ Launch Startup</a>
</div>
</div>
<?php if (empty($myStartups)): ?>
@ -208,9 +232,17 @@ function number_get_formatted($num) {
</div>
</div>
</div>
<div style="text-align: right;">
<div style="font-size: 22px; font-weight: 900; color: #fff;">£<?= number_get_formatted($raised) ?></div>
<div style="font-size: 13px; color: var(--text-secondary); opacity: 0.6;">Funds Raised</div>
<div style="display: flex; gap: 20px; align-items: center;">
<div style="text-align: right;">
<div style="font-size: 22px; font-weight: 900; color: #fff;">£<?= number_get_formatted($raised) ?></div>
<div style="font-size: 13px; color: var(--text-secondary); opacity: 0.6;">Funds Raised</div>
</div>
<?php if ($startup['round_status'] === 'Active'): ?>
<div style="display: flex; gap: 8px;">
<button onclick="event.stopPropagation(); updateRound(<?= $startup['round_id'] ?>, 'Closed')" class="btn" style="padding: 8px 12px; font-size: 11px; background: #28a745; color: #fff; border: none; border-radius: 8px;">Finish</button>
<button onclick="event.stopPropagation(); updateRound(<?= $startup['round_id'] ?>, 'Cancelled')" class="btn" style="padding: 8px 12px; font-size: 11px; background: #dc3545; color: #fff; border: none; border-radius: 8px;">Cancel</button>
</div>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
@ -263,6 +295,33 @@ function number_get_formatted($num) {
</div>
<div>
<!-- Money Pot Section -->
<div class="card" style="margin-bottom: 30px; padding: 30px; background: linear-gradient(135deg, #1a1a24 0%, #101018 100%); border: 1px solid rgba(0, 242, 255, 0.1);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
<h3 style="margin: 0; font-size: 18px; font-weight: 800; color: var(--accent-blue);">My Money Pot</h3>
<i class="fas fa-wallet" style="color: var(--accent-blue); opacity: 0.5;"></i>
</div>
<div style="margin-bottom: 25px;">
<span style="font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; font-weight: 700;">Available Balance</span>
<div id="wallet-balance" style="font-size: 36px; font-weight: 900; color: #fff; margin-top: 5px;">£<?= number_format($user['balance'], 2) ?></div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px;">
<button onclick="openWalletModal('add')" class="btn btn-primary" style="padding: 12px; font-size: 13px; font-weight: 800; background: var(--accent-blue); color: #000; border-radius: 12px;">
<i class="fas fa-plus-circle" style="margin-right: 5px;"></i> Add Funds
</button>
<button onclick="openWalletModal('withdraw')" class="btn btn-secondary" style="padding: 12px; font-size: 13px; font-weight: 800; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;">
<i class="fas fa-minus-circle" style="margin-right: 5px;"></i> Withdraw
</button>
</div>
<p style="font-size: 11px; color: var(--text-secondary); margin-top: 15px; text-align: center; opacity: 0.6;">
<?php if ($user['role'] === 'founder'): ?>
Manage your startup capital and dividend funds.
<?php else: ?>
Manage your investment capital and earnings.
<?php endif; ?>
</p>
</div>
<div class="card" style="margin-bottom: 30px; padding: 30px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<h3 style="margin: 0; font-size: 20px; font-weight: 800;">My Profile</h3>
@ -304,15 +363,107 @@ function number_get_formatted($num) {
<?= $user['role'] === 'founder' ? 'Launch Matching' : 'Go to Discovery Hub' ?>
</a>
</div>
<div class="card" style="background: var(--glass-bg); color: #fff; border: 1px solid var(--glass-border); padding: 30px;">
<h3 style="color: #fff; margin-bottom: 12px; font-size: 18px; font-weight: 800;">Gatsby Premium</h3>
<p style="font-size: 14px; opacity: 0.7; margin-bottom: 20px;">Unlock direct access to institutional investors and exclusive demo days.</p>
<button class="btn btn-secondary" style="width: 100%; border-radius: 12px; font-size: 13px;">Upgrade Now</button>
</div>
</div>
</div>
</main>
<!-- Wallet Modal -->
<div id="wallet-modal" class="modal">
<div class="modal-content">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;">
<h2 id="modal-title" style="margin: 0; font-size: 24px; font-weight: 900; color: #fff;">Add Funds</h2>
<button onclick="closeWalletModal()" style="background: none; border: none; color: #999; cursor: pointer; font-size: 20px;"><i class="fas fa-times"></i></button>
</div>
<form id="wallet-form">
<input type="hidden" id="wallet-action" name="action" value="add">
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 10px; font-size: 12px; color: #999; text-transform: uppercase; letter-spacing: 1px; font-weight: 700;">Amount (£)</label>
<input type="number" id="wallet-amount" name="amount" min="1" step="0.01" required placeholder="0.00"
style="width: 100%; padding: 18px; background: #000; border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; color: #fff; font-size: 24px; font-weight: 800;">
</div>
<button type="submit" id="wallet-submit-btn" class="btn btn-primary" style="width: 100%; padding: 18px; font-size: 16px; font-weight: 800; border-radius: 16px; background: var(--accent-blue); color: #000;">Confirm</button>
</form>
</div>
</div>
<script>
function openWalletModal(action) {
const modal = document.getElementById('wallet-modal');
const title = document.getElementById('modal-title');
const actionInput = document.getElementById('wallet-action');
const submitBtn = document.getElementById('wallet-submit-btn');
actionInput.value = action;
if (action === 'add') {
title.innerText = 'Add Funds';
submitBtn.innerText = 'Confirm Deposit';
submitBtn.style.background = 'var(--accent-blue)';
} else {
title.innerText = 'Withdraw Funds';
submitBtn.innerText = 'Confirm Withdrawal';
submitBtn.style.background = '#fff';
}
modal.style.display = 'block';
}
function closeWalletModal() {
document.getElementById('wallet-modal').style.display = 'none';
}
document.getElementById('wallet-form').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
fetch('api/wallet_transaction.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
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);
}
})
.catch(error => {
console.error('Error:', error);
alert('An unexpected error occurred.');
});
});
function updateRound(roundId, status) {
if (confirm('Are you sure you want to ' + status.toLowerCase() + ' this funding round?')) {
const formData = new FormData();
formData.append('round_id', roundId);
formData.append('status', status);
fetch('update_round_status.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
location.reload();
} else {
alert('Error: ' + data.error);
}
});
}
}
// Close modal when clicking outside
window.onclick = function(event) {
const modal = document.getElementById('wallet-modal');
if (event.target == modal) {
closeWalletModal();
}
}
</script>
</body>
</html>
</html>

View File

@ -0,0 +1,2 @@
-- Add balance to users table
ALTER TABLE users ADD COLUMN balance DECIMAL(15, 2) DEFAULT 0.00;

View File

@ -14,7 +14,7 @@ if (!$startupId) {
}
$stmt = db()->prepare("
SELECT s.*, fr.id as round_id, fr.funding_goal, fr.funding_raised, fr.status as round_status
SELECT s.*, fr.id as round_id, fr.funding_goal, fr.funding_raised, fr.status as round_status, s.user_id as founder_id
FROM startups s
LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active'
WHERE s.id = ?
@ -33,18 +33,23 @@ if ($startup['round_status'] !== 'Active') {
$error = '';
$success = '';
// Get investor's current balance
$stmt = db()->prepare("SELECT balance FROM users WHERE id = ?");
$stmt->execute([$_SESSION['user_id']]);
$investor_balance = (float)$stmt->fetchColumn();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$amount = (float)($_POST['amount'] ?? 0);
$investor_id = $_SESSION['user_id'];
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.";
} else {
db()->beginTransaction();
try {
// 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 = 0.00; // Mock logic for equity
$stmt = db()->prepare("INSERT INTO investments (startup_id, investor_id, funding_round_id, amount, equity_pct, status) VALUES (?, ?, ?, ?, ?, 'approved')");
@ -58,8 +63,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt = db()->prepare("UPDATE startups SET funding_raised = funding_raised + ? WHERE id = ?");
$stmt->execute([$amount, $startupId]);
// 4. TRANSFER MONEY: Investor pot -> Founder pot
// Deduct from investor
$stmt = db()->prepare("UPDATE users SET balance = balance - ? WHERE id = ?");
$stmt->execute([$amount, $investor_id]);
// Add to founder
$stmt = db()->prepare("UPDATE users SET balance = balance + ? WHERE id = ?");
$stmt->execute([$amount, $startup['founder_id']]);
db()->commit();
$success = "Investment of £" . number_format($amount) . " confirmed successfully!";
$success = "Investment of £" . number_format($amount) . " confirmed successfully! Funds moved to the founder's pot.";
header("refresh:3;url=portfolio.php");
} catch (Exception $e) {
db()->rollBack();
@ -87,6 +101,15 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
You are participating in the active funding round for this startup.
</p>
<!-- Wallet Info -->
<div style="background: rgba(0, 242, 255, 0.05); padding: 15px; border-radius: 12px; border: 1px solid rgba(0, 242, 255, 0.2); margin-bottom: 25px; display: flex; align-items: center; justify-content: space-between;">
<div>
<span style="font-size: 12px; color: #999; text-transform: uppercase;">Your Wallet Balance</span>
<div style="font-size: 18px; font-weight: 900; color: var(--accent-blue);">£<?= number_format($investor_balance, 2) ?></div>
</div>
<a href="dashboard.php" style="font-size: 12px; color: var(--accent-blue); text-decoration: none; font-weight: 600;">Add Funds <i class="fas fa-plus"></i></a>
</div>
<?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) ?>
@ -133,4 +156,4 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
</div>
</body>
</html>
</html>

View File

@ -42,6 +42,29 @@ foreach ($myInvestments as $inv) {
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&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">
<style>
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 2000;
left: 0;
top: 0;
width: 100%;
height: 100%;
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: 420px;
border-radius: 32px;
box-shadow: 0 25px 60px rgba(0,0,0,0.7);
}
</style>
</head>
<body>
@ -63,6 +86,12 @@ foreach ($myInvestments as $inv) {
<a href="messages.php">Messages</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<!-- Money Pot Widget in Header -->
<div onclick="openWalletModal('add')" style="cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 5px 12px; background: rgba(0, 242, 255, 0.1); border-radius: 50px; border: 1px solid rgba(0, 242, 255, 0.2);">
<i class="fas fa-wallet" style="color: var(--accent-blue); font-size: 12px;"></i>
<span id="header-wallet-balance" style="font-size: 13px; font-weight: 800; color: #fff;">£<?= number_format($user['balance'], 2) ?></span>
</div>
<a href="notifications.php" style="color: var(--text-secondary); position: relative; font-size: 18px;">
<i class="fas fa-bell"></i>
</a>
@ -140,6 +169,25 @@ foreach ($myInvestments as $inv) {
</div>
</main>
<!-- Wallet Modal -->
<div id="wallet-modal" class="modal">
<div class="modal-content">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;">
<h2 id="modal-title" style="margin: 0; font-size: 24px; font-weight: 900; color: #fff;">Add Funds</h2>
<button onclick="closeWalletModal()" style="background: none; border: none; color: #999; cursor: pointer; font-size: 20px;"><i class="fas fa-times"></i></button>
</div>
<form id="wallet-form">
<input type="hidden" id="wallet-action" name="action" value="add">
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 10px; font-size: 12px; color: #999; text-transform: uppercase; letter-spacing: 1px; font-weight: 700;">Amount (£)</label>
<input type="number" id="wallet-amount" name="amount" min="1" step="0.01" required placeholder="0.00"
style="width: 100%; padding: 18px; background: #000; border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; color: #fff; font-size: 24px; font-weight: 800;">
</div>
<button type="submit" id="wallet-submit-btn" class="btn btn-primary" style="width: 100%; padding: 18px; font-size: 16px; font-weight: 800; border-radius: 16px; background: var(--accent-blue); color: #000;">Confirm</button>
</form>
</div>
</div>
<footer style="margin-top: 80px; padding: 60px 0; border-top: 1px solid var(--border-color); background: rgba(0,0,0,0.2);">
<div class="container" style="text-align: center;">
<div class="logo-container" style="justify-content: center; margin-bottom: 25px;">
@ -150,6 +198,64 @@ foreach ($myInvestments as $inv) {
</div>
</footer>
<script src="assets/js/main.js"></script>
<script>
function openWalletModal(action) {
const modal = document.getElementById('wallet-modal');
const title = document.getElementById('modal-title');
const actionInput = document.getElementById('wallet-action');
const submitBtn = document.getElementById('wallet-submit-btn');
actionInput.value = action;
if (action === 'add') {
title.innerText = 'Add Funds';
submitBtn.innerText = 'Confirm Deposit';
submitBtn.style.background = 'var(--accent-blue)';
} else {
title.innerText = 'Withdraw Funds';
submitBtn.innerText = 'Confirm Withdrawal';
submitBtn.style.background = '#fff';
}
modal.style.display = 'block';
}
function closeWalletModal() {
document.getElementById('wallet-modal').style.display = 'none';
}
document.getElementById('wallet-form').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
fetch('api/wallet_transaction.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
const formattedBalance = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('header-wallet-balance').innerText = formattedBalance;
closeWalletModal();
alert(formData.get('action') === 'add' ? 'Funds added successfully!' : 'Withdrawal successful!');
} else {
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('An unexpected error occurred.');
});
});
// Close modal when clicking outside
window.onclick = function(event) {
const modal = document.getElementById('wallet-modal');
if (event.target == modal) {
closeWalletModal();
}
}
</script>
</body>
</html>
</html>

View File

@ -32,7 +32,7 @@ if (!$startup) {
}
// Check if user is the founder or an investor
$isFounder = ($_SESSION['user_id'] == $startup['founder_id']);
$isFounder = ($_SESSION['user_id'] == $startup['user_id']);
$isInvestor = ($user['role'] == 'investor');
// Basic permissions check
@ -70,7 +70,7 @@ if ($isFounder) {
// Fetch founders
$stmt = db()->prepare("SELECT id, full_name as name FROM users WHERE id = ?");
$stmt->execute([$startup['founder_id']]);
$stmt->execute([$startup['user_id']]);
$founder = $stmt->fetch();
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
@ -233,6 +233,28 @@ function getNextDividendInfo($createdAt) {
.btn-finish-small:hover {
background: rgba(48, 209, 88, 0.1);
}
/* Modal Styles */
.modal {
display: none;
position: fixed;
z-index: 2000;
left: 0;
top: 0;
width: 100%;
height: 100%;
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: 420px;
border-radius: 32px;
box-shadow: 0 25px 60px rgba(0,0,0,0.7);
}
</style>
</head>
<body style="background: #000; color: #fff;">
@ -255,6 +277,12 @@ function getNextDividendInfo($createdAt) {
<a href="messages.php">Messages</a>
</nav>
<div style="display: flex; align-items: center; gap: 15px;">
<!-- Money Pot Widget in Header -->
<div onclick="openWalletModal('add')" style="cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 5px 12px; background: rgba(0, 242, 255, 0.1); border-radius: 50px; border: 1px solid rgba(0, 242, 255, 0.2);">
<i class="fas fa-wallet" style="color: var(--accent-blue); font-size: 12px;"></i>
<span id="header-wallet-balance" style="font-size: 13px; font-weight: 800; color: #fff;">£<?= number_format($user['balance'], 2) ?></span>
</div>
<div style="display: flex; align-items: center; gap: 10px; padding: 5px 12px; background: rgba(255,255,255,0.05); border-radius: 50px; border: 1px solid var(--border-color);">
<div style="width: 24px; height: 24px; background: var(--gradient-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; font-weight: 800;">
<?= substr($user['full_name'], 0, 1) ?>
@ -296,7 +324,7 @@ function getNextDividendInfo($createdAt) {
<?php if ($isInvestor): ?>
<div style="display: flex; gap: 15px;">
<a href="messages.php?chat_with=<?= $startup['founder_id'] ?>" style="background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: #fff; padding: 16px 24px; border-radius: 14px; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 10px;">
<a href="messages.php?chat_with=<?= $startup['user_id'] ?>" style="background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); color: #fff; padding: 16px 24px; border-radius: 14px; text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 10px;">
<i class="far fa-comment-dots"></i> Message Founder
</a>
<a href="invest.php?id=<?= $startup['id'] ?>" class="invest-btn">
@ -352,6 +380,32 @@ function getNextDividendInfo($createdAt) {
</section>
<?php endif; ?>
<?php if ($isFounder): ?>
<!-- Money Pot (Founder View) -->
<section class="card" style="margin-bottom: 40px; background: linear-gradient(135deg, #1a1a24 0%, #101018 100%); border: 1px solid rgba(0, 242, 255, 0.2);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<h2 class="section-title" style="margin-bottom: 0;"><i class="fas fa-wallet" style="color: var(--accent-blue);"></i> Startup Money Pot</h2>
<div style="display: flex; gap: 10px;">
<button onclick="openWalletModal('add')" class="btn" style="padding: 10px 20px; font-size: 13px; font-weight: 800; background: var(--accent-blue); color: #000; border-radius: 12px; border: none; cursor: pointer;">Add Funds</button>
<button onclick="openWalletModal('withdraw')" class="btn" style="padding: 10px 20px; font-size: 13px; font-weight: 800; background: rgba(255,255,255,0.05); color: #fff; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); cursor: pointer;">Withdraw</button>
</div>
</div>
<div style="display: flex; align-items: center; gap: 30px;">
<div>
<div style="font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px;">Available Capital</div>
<div id="startup-wallet-balance" style="font-size: 36px; font-weight: 900; color: #fff; margin-top: 5px;">£<?= number_format($user['balance'], 2) ?></div>
</div>
<div style="padding-left: 30px; border-left: 1px solid var(--border-color);">
<div style="font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px;">Total Investments Received</div>
<div style="font-size: 24px; font-weight: 900; color: var(--accent-blue); margin-top: 5px;">£<?= number_format($startup['funding_raised'], 2) ?></div>
</div>
</div>
<p style="margin-top: 20px; color: var(--text-secondary); font-size: 13px; opacity: 0.8;">
<i class="fas fa-info-circle"></i> This pot holds all investments received. You can withdraw funds for business operations or add funds to cover investor dividends.
</p>
</section>
<?php endif; ?>
<?php if ($isFounder && !empty($approvedInvestments)): ?>
<!-- Dividend Management (Founder Only) -->
<section class="card" style="margin-bottom: 40px; border-color: rgba(48, 209, 88, 0.3);">
@ -522,9 +576,90 @@ function getNextDividendInfo($createdAt) {
</div>
</div>
<!-- Wallet Modal -->
<div id="wallet-modal" class="modal">
<div class="modal-content">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px;">
<h2 id="modal-title" style="margin: 0; font-size: 24px; font-weight: 900; color: #fff;">Add Funds</h2>
<button onclick="closeWalletModal()" style="background: none; border: none; color: #999; cursor: pointer; font-size: 20px;"><i class="fas fa-times"></i></button>
</div>
<form id="wallet-form">
<input type="hidden" id="wallet-action" name="action" value="add">
<div style="margin-bottom: 25px;">
<label style="display: block; margin-bottom: 10px; font-size: 12px; color: #999; text-transform: uppercase; letter-spacing: 1px; font-weight: 700;">Amount (£)</label>
<input type="number" id="wallet-amount" name="amount" min="1" step="0.01" required placeholder="0.00"
style="width: 100%; padding: 18px; background: #000; border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; color: #fff; font-size: 24px; font-weight: 800;">
</div>
<button type="submit" id="wallet-submit-btn" class="btn btn-primary" style="width: 100%; padding: 18px; font-size: 16px; font-weight: 800; border-radius: 16px; background: var(--accent-blue); color: #000;">Confirm</button>
</form>
</div>
</div>
<footer style="padding: 60px 0; border-top: 1px solid var(--border-color); margin-top: 100px; text-align: center;">
<p style="color: var(--text-secondary); font-size: 14px;">&copy; <?= date('Y') ?> Gatsby Capitalist Platform. All rights reserved.</p>
</footer>
<script>
function openWalletModal(action) {
const modal = document.getElementById('wallet-modal');
const title = document.getElementById('modal-title');
const actionInput = document.getElementById('wallet-action');
const submitBtn = document.getElementById('wallet-submit-btn');
actionInput.value = action;
if (action === 'add') {
title.innerText = 'Add Funds';
submitBtn.innerText = 'Confirm Deposit';
submitBtn.style.background = 'var(--accent-blue)';
} else {
title.innerText = 'Withdraw Funds';
submitBtn.innerText = 'Confirm Withdrawal';
submitBtn.style.background = '#fff';
}
modal.style.display = 'block';
}
function closeWalletModal() {
document.getElementById('wallet-modal').style.display = 'none';
}
document.getElementById('wallet-form').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
fetch('api/wallet_transaction.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
const formattedBalance = '£' + parseFloat(data.new_balance).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('header-wallet-balance').innerText = formattedBalance;
if (document.getElementById('startup-wallet-balance')) {
document.getElementById('startup-wallet-balance').innerText = formattedBalance;
}
closeWalletModal();
alert(formData.get('action') === 'add' ? 'Funds added successfully!' : 'Withdrawal successful!');
} else {
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('An unexpected error occurred.');
});
});
// Close modal when clicking outside
window.onclick = function(event) {
const modal = document.getElementById('wallet-modal');
if (event.target == modal) {
closeWalletModal();
}
}
</script>
</body>
</html>
</html>