38873-vm/startup_details.php
Flatlogic Bot fb4133a854 v50
2026-02-28 22:38:01 +00:00

505 lines
29 KiB
PHP

<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
require_once __DIR__ . '/db/config.php';
$startupId = $_GET['id'] ?? null;
if (!$startupId) {
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
LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active'
WHERE s.id = ?
");
$stmt->execute([$startupId]);
$startup = $stmt->fetch();
if (!$startup) {
die("Startup not found.");
}
$isFounder = ($startup['founder_id'] == $_SESSION['user_id']);
// Fetch followers count
$stmt = db()->prepare("SELECT COUNT(*) FROM startup_followers WHERE startup_id = ?");
$stmt->execute([$startupId]);
$followersCount = $stmt->fetchColumn();
// 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 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
$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
WHERE i.startup_id = ? AND i.status = 'approved'
ORDER BY i.created_at DESC
");
$stmt->execute([$startupId]);
$approvedInvestments = $stmt->fetchAll();
// Fetch Wallet Transactions for Founder
$stmt = db()->prepare("SELECT * FROM wallet_transactions WHERE user_id = ? ORDER BY created_at DESC LIMIT 5");
$stmt->execute([$_SESSION['user_id']]);
$transactions = $stmt->fetchAll();
}
function getNextDividendInfo($investmentDate) {
$nextDate = date('M d, Y', strtotime($investmentDate . ' + 1 month'));
return $nextDate;
}
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= htmlspecialchars($startup['name']) ?> — <?= htmlspecialchars($platformName) ?></title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<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>
.transaction-item {
padding: 12px 0;
border-bottom: 1px solid rgba(255,255,255,0.05);
display: flex;
justify-content: space-between;
align-items: center;
}
.transaction-item:last-child {
border-bottom: none;
}
</style>
</head>
<body style="background: #000; color: #fff; font-family: 'Inter', sans-serif;">
<nav style="padding: 20px 40px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); background: rgba(0,0,0,0.8); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 1000;">
<div style="display: flex; align-items: center; gap: 40px;">
<a href="index.php" style="text-decoration: none; display: flex; align-items: center; gap: 10px;">
<div style="width: 32px; height: 32px; background: var(--gradient-primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 18px;">G</div>
<span style="font-weight: 900; font-size: 22px; letter-spacing: -1px; color: #fff;"><?= htmlspecialchars($platformName) ?></span>
</a>
<div style="display: flex; gap: 25px;">
<a href="dashboard.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.6;">Dashboard</a>
<a href="discover.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.6;">Discover</a>
<a href="messages.php" style="color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; opacity: 0.6;">Messages</a>
</div>
</div>
<div style="display: flex; align-items: center; gap: 20px;">
<div style="background: rgba(255,255,255,0.05); padding: 8px 16px; border-radius: 50px; border: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px;">
<i class="fas fa-wallet" style="color: var(--accent-blue); font-size: 12px;"></i>
<span id="header-wallet-balance" style="font-weight: 800; font-size: 13px;">£<?= number_format($user['balance'], 2) ?></span>
</div>
<a href="logout.php" style="color: #ff3b30; text-decoration: none; font-size: 13px; font-weight: 700;">Logout</a>
</div>
</nav>
<div style="max-width: 1200px; margin: 40px auto; padding: 0 20px;">
<!-- Profile Header -->
<header class="card" style="margin-bottom: 40px; padding: 50px; position: relative; overflow: hidden;">
<div style="position: absolute; top: 0; left: 0; width: 100%; height: 6px; background: var(--gradient-primary);"></div>
<div style="display: flex; justify-content: space-between; align-items: flex-start;">
<div style="display: flex; gap: 30px; align-items: center;">
<div style="width: 120px; height: 120px; background: var(--surface-color); border-radius: 32px; display: flex; align-items: center; justify-content: center; font-size: 52px; border: 1px solid var(--border-color); box-shadow: 0 20px 40px rgba(0,0,0,0.3);">
<i class="fas fa-building" style="opacity: 0.5;"></i>
</div>
<div>
<h1 style="font-size: 48px; font-weight: 900; margin: 0 0 10px; letter-spacing: -2px;"><?= htmlspecialchars($startup['name']) ?></h1>
<div style="display: flex; gap: 20px; color: var(--text-secondary); font-size: 16px; font-weight: 600;">
<span><i class="fas fa-tag" style="margin-right: 8px; color: var(--accent-blue);"></i> <?= htmlspecialchars($startup['industry']) ?></span>
<span><i class="fas fa-map-marker-alt" style="margin-right: 8px; color: var(--accent-blue);"></i> <?= htmlspecialchars($startup['country']) ?></span>
<span><i class="fas fa-users" style="margin-right: 8px; color: var(--accent-blue);"></i> <?= $followersCount ?> Followers</span>
</div>
</div>
</div>
<div style="display: flex; gap: 15px;">
<?php if ($isFounder): ?>
<a href="edit_startup.php?id=<?= $startupId ?>" class="btn btn-secondary" style="padding: 14px 28px; font-weight: 800;">Edit Startup</a>
<?php else: ?>
<form action="toggle_follow.php" method="POST" style="margin: 0;">
<input type="hidden" name="startup_id" value="<?= $startupId ?>">
<button type="submit" class="btn <?= $isFollowing ? 'btn-secondary' : 'btn-primary' ?>" style="padding: 14px 28px; font-weight: 800;">
<?= $isFollowing ? 'Unfollow' : 'Follow' ?>
</button>
</form>
<a href="messages.php?start_chat=<?= $startup['founder_id'] ?>" class="btn btn-secondary" style="padding: 14px 28px; font-weight: 800;">Message Founder</a>
<?php endif; ?>
</div>
</div>
</header>
<div style="display: grid; grid-template-columns: 1fr 400px; gap: 40px;">
<div class="content-main">
<!-- Investment Status -->
<?php if ($startup['round_status'] === 'Active'): ?>
<section class="card" style="margin-bottom: 40px; border-color: var(--accent-blue); background: rgba(0, 242, 255, 0.02);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<div>
<span style="font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent-blue);">Currently Fundraising</span>
<h2 style="font-size: 28px; font-weight: 900; margin: 5px 0 0;">Seed Round is LIVE</h2>
</div>
<?php if (!$isFounder): ?>
<a href="invest.php?id=<?= $startupId ?>" class="btn btn-primary" style="padding: 16px 32px; font-size: 16px;">Invest Now <i class="fas fa-rocket" style="margin-left: 10px;"></i></a>
<?php endif; ?>
</div>
<div style="margin-bottom: 30px;">
<div style="display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: 800; font-size: 14px;">
<span>£<?= number_format($startup['current_round_raised']) ?> raised</span>
<span style="color: var(--text-secondary);">Target: £<?= number_format($startup['funding_goal']) ?></span>
</div>
<div class="progress-bar" style="height: 12px;">
<div class="progress-fill" style="width: <?= min(100, ($startup['current_round_raised'] / $startup['funding_goal']) * 100) ?>%;"></div>
</div>
</div>
<?php if ($isFounder): ?>
<div style="display: flex; gap: 15px; padding-top: 20px; border-top: 1px solid var(--border-color);">
<form action="update_round_status.php" method="POST" style="margin: 0;" onsubmit="return confirm('Complete this funding round?');">
<input type="hidden" name="round_id" value="<?= $startup['round_id'] ?>">
<input type="hidden" name="status" value="Completed">
<button type="submit" class="btn-status-small btn-approve-small">
<i class="fas fa-check-circle"></i> Close Round (Goal Met)
</button>
</form>
<form action="update_round_status.php" method="POST" style="margin: 0;" onsubmit="return confirm('Cancel this funding round?');">
<input type="hidden" name="round_id" value="<?= $startup['round_id'] ?>">
<input type="hidden" name="status" value="Cancelled">
<button type="submit" class="btn-status-small btn-cancel-small">
<i class="fas fa-times-circle"></i> Cancel Round
</button>
</form>
</div>
<?php endif; ?>
</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: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 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>
<!-- Recent Transactions -->
<div style="border-top: 1px solid rgba(255,255,255,0.05); padding-top: 20px;">
<h4 style="font-size: 12px; font-weight: 800; color: #999; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 15px;">Recent Pot Transactions</h4>
<?php if (empty($transactions)): ?>
<p style="font-size: 12px; color: var(--text-secondary); text-align: center; opacity: 0.5;">No transactions yet.</p>
<?php else: ?>
<div id="transaction-list">
<?php foreach ($transactions as $tx): ?>
<div class="transaction-item">
<div>
<div style="font-size: 13px; font-weight: 700; color: #fff;"><?= htmlspecialchars($tx['description']) ?></div>
<div style="font-size: 11px; color: #666;"><?= date('M d, H:i', strtotime($tx['created_at'])) ?></div>
</div>
<div style="font-size: 14px; font-weight: 900; color: <?= in_array($tx['type'], ['add', 'investment_in']) ? '#4cd964' : '#ff3b30' ?>;">
<?= in_array($tx['type'], ['add', 'investment_in']) ? '+' : '-' ?>£<?= number_format($tx['amount'], 2) ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</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);">
<h2 class="section-title"><i class="fas fa-hand-holding-usd" style="color: #30d158;"></i> Monthly Dividends Due</h2>
<div style="margin-bottom: 20px;">
<p style="color: var(--text-secondary); font-size: 14px;">Track upcoming monthly payments to your investors based on your <strong><?= number_format($startup['founder_return_rate'] ?? 0, 1) ?>%</strong> offered return.</p>
</div>
<?php foreach ($approvedInvestments as $inv):
$monthlyYield = ($inv['amount'] * ($startup['founder_return_rate'] ?? 0) / 100) / 12;
$nextPay = getNextDividendInfo($inv['created_at']);
?>
<div class="candidate-card" style="padding: 20px; margin-bottom: 15px; border-color: rgba(48, 209, 88, 0.1);">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>
<div style="font-weight: 800; font-size: 18px; color: #fff;"><?= htmlspecialchars($inv['investor_name']) ?></div>
<div style="font-size: 12px; color: #999;">Investment: £<?= number_format($inv['amount']) ?></div>
</div>
<div style="text-align: right;">
<div style="font-size: 20px; font-weight: 900; color: #4cd964;">£<?= number_format($monthlyYield, 2) ?></div>
<div style="font-size: 11px; color: #999;">Next: <?= $nextPay ?></div>
</div>
</div>
</div>
<?php endforeach; ?>
</section>
<?php endif; ?>
<!-- About Section -->
<section class="card" style="margin-bottom: 40px; padding: 40px;">
<h2 class="section-title">The Vision</h2>
<div style="font-size: 18px; line-height: 1.8; color: var(--text-secondary);">
<?= nl2br(htmlspecialchars($startup['description'])) ?>
</div>
</section>
<!-- Business Details -->
<section class="card" style="margin-bottom: 40px; padding: 40px;">
<h2 class="section-title">Business Intelligence</h2>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 30px;">
<div>
<h4 style="color: var(--accent-blue); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Business Model</h4>
<p style="font-size: 15px; color: var(--text-secondary);"><?= nl2br(htmlspecialchars($startup['business_model'])) ?></p>
</div>
<div>
<h4 style="color: var(--accent-blue); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;">Product/Service</h4>
<p style="font-size: 15px; color: var(--text-secondary);"><?= nl2br(htmlspecialchars($startup['product_service'])) ?></p>
</div>
</div>
</section>
<!-- Financial Documents -->
<section class="card" style="margin-bottom: 40px; padding: 40px;">
<h2 class="section-title">Verified Data Rooms</h2>
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px;">
<?php
$docs = [
'income_statements' => 'Income Statements',
'balance_sheets' => 'Balance Sheets',
'cash_flow_statements' => 'Cash Flow Statements',
'revenue_breakdown' => 'Revenue Breakdown',
'gross_margin' => 'Gross Margin Analysis'
];
foreach ($docs as $key => $label):
$docPath = $startup['doc_' . $key] ?? '';
?>
<div style="padding: 20px; background: rgba(255,255,255,0.03); border-radius: 16px; border: 1px solid var(--border-color); text-align: center;">
<i class="far fa-file-excel" style="font-size: 32px; color: #2ecc71; margin-bottom: 15px;"></i>
<div style="font-size: 13px; font-weight: 700; margin-bottom: 10px;"><?= $label ?></div>
<?php if ($docPath): ?>
<a href="<?= htmlspecialchars($docPath) ?>" target="_blank" class="btn" style="font-size: 11px; padding: 8px 16px; background: rgba(0, 242, 255, 0.1); color: var(--accent-blue); width: 100%;">Download</a>
<?php else: ?>
<span style="font-size: 11px; color: #555;">Not uploaded</span>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</section>
</div>
<aside class="sidebar">
<!-- Founder Card -->
<section class="card" style="margin-bottom: 40px; padding: 30px; text-align: center;">
<h4 style="font-size: 12px; text-transform: uppercase; letter-spacing: 2px; color: var(--text-secondary); margin-bottom: 25px;">The Visionary</h4>
<div style="width: 100px; height: 100px; background: var(--gradient-primary); border-radius: 30px; margin: 0 auto 20px; display: flex; align-items: center; justify-content: center; font-size: 42px; font-weight: 900; color: #fff; box-shadow: 0 15px 30px rgba(0, 122, 255, 0.2);">
<?= substr($startup['founder_name'], 0, 1) ?>
</div>
<h3 style="font-size: 22px; font-weight: 800; margin-bottom: 5px;"><?= htmlspecialchars($startup['founder_name']) ?></h3>
<p style="color: var(--accent-blue); font-weight: 700; font-size: 14px; margin-bottom: 20px;"><?= htmlspecialchars($startup['founder_university']) ?></p>
<div style="font-size: 14px; line-height: 1.6; color: var(--text-secondary); margin-bottom: 25px;">
<?= htmlspecialchars($startup['founder_bio']) ?>
</div>
<div style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;">
<?php
$skills = explode(',', $startup['founder_skills'] ?? '');
foreach (array_slice($skills, 0, 3) as $skill): if(empty(trim($skill))) continue; ?>
<span style="font-size: 10px; padding: 5px 12px; background: rgba(255,255,255,0.05); border-radius: 50px; border: 1px solid var(--border-color); font-weight: 600;"><?= htmlspecialchars(trim($skill)) ?></span>
<?php endforeach; ?>
</div>
<a href="profile.php?id=<?= $startup['founder_id'] ?>" class="btn btn-secondary" style="width: 100%; margin-top: 30px; font-size: 13px; font-weight: 800;">View Founder Profile</a>
</section>
<!-- Investors List -->
<?php if (!empty($approvedInvestments)): ?>
<section class="card" style="padding: 30px;">
<h3 style="font-size: 20px; font-weight: 800; margin-bottom: 25px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px;">Recent Investors</h3>
<div style="display: flex; flex-direction: column; gap: 20px;">
<?php foreach ($approvedInvestments as $inv):
$investorName = $inv['investor_name'] ?? 'Anonymous Investor';
?>
<div style="display: flex; justify-content: space-between; align-items: center;">
<div style="display: flex; align-items: center; gap: 15px;">
<?php if (!empty($inv['investor_image'])): ?>
<img src="<?= htmlspecialchars($inv['investor_image']) ?>" style="width: 45px; height: 45px; border-radius: 12px; object-fit: cover;">
<?php else: ?>
<div style="width: 45px; height: 45px; border-radius: 12px; background: var(--surface-color); display: flex; align-items: center; justify-content: center;">
<span style="font-weight: 800; color: var(--accent-blue);"><?= substr($investorName, 0, 1) ?></span>
</div>
<?php endif; ?>
<div>
<div style="font-weight: 700;">
<?php if ($inv['investor_user_id']): ?>
<a href="profile.php?id=<?= $inv['investor_user_id'] ?>" style="color: inherit; text-decoration: none;"><?= htmlspecialchars($investorName) ?></a>
<?php else: ?>
<?= htmlspecialchars($investorName) ?>
<?php endif; ?>
</div>
<div style="font-size: 12px; color: var(--text-secondary);"><?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
</div>
</div>
<div style="text-align: right;">
<div style="font-weight: 900; color: #fff; font-size: 18px;">£<?= number_format($inv['amount']) ?></div>
</div>
</div>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
</aside>
</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();
location.reload(); // Reload to show new transaction
} 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>