510 lines
28 KiB
PHP
510 lines
28 KiB
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/db/config.php';
|
|
require_once __DIR__ . "/sync_funding.php";
|
|
syncRepayments();
|
|
|
|
$stmt = db()->prepare("SELECT * FROM users WHERE id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$user = $stmt->fetch();
|
|
|
|
if (!$user) {
|
|
session_destroy();
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
if ($user['verified'] == 0) {
|
|
session_destroy();
|
|
header("Location: login.php?error=not_verified");
|
|
exit;
|
|
}
|
|
|
|
if ($user['role'] === 'founder' && $user['onboarding_completed'] == 0) {
|
|
header("Location: founder_onboarding.php");
|
|
exit;
|
|
}
|
|
|
|
$platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby';
|
|
|
|
$trendingIds = [];
|
|
$stmt = db()->prepare("
|
|
SELECT s.id
|
|
FROM startups s
|
|
LEFT JOIN startup_followers sf ON s.id = sf.startup_id
|
|
GROUP BY s.id
|
|
ORDER BY COUNT(sf.id) DESC
|
|
LIMIT 3
|
|
");
|
|
$stmt->execute();
|
|
$topFollowed = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
|
$trendingIds = array_merge($trendingIds, $topFollowed);
|
|
|
|
$stmt = db()->prepare("
|
|
SELECT id
|
|
FROM startups
|
|
ORDER BY funding_raised DESC
|
|
LIMIT 3
|
|
");
|
|
$stmt->execute();
|
|
$topFunded = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
|
$trendingIds = array_unique(array_merge($trendingIds, $topFunded));
|
|
|
|
$myStartups = [];
|
|
$myInvestments = [];
|
|
$repaymentSummary = [
|
|
'total_raised' => 0,
|
|
'total_obligation' => 0,
|
|
'monthly_outgoing' => 0,
|
|
'active_investors' => 0,
|
|
'next_payment_date' => null
|
|
];
|
|
|
|
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, 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 = ?
|
|
ORDER BY s.created_at DESC
|
|
");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$myStartups = $stmt->fetchAll();
|
|
|
|
// Repayment Summary Calculation
|
|
$stmt = db()->prepare("
|
|
SELECT
|
|
SUM(CASE WHEN i.status IN ('approved', 'completed') THEN i.amount ELSE 0 END) as total_raised,
|
|
SUM(CASE WHEN i.status IN ('approved', 'completed') THEN i.total_return ELSE 0 END) as total_obligation,
|
|
SUM(CASE WHEN i.status = 'approved' THEN i.monthly_dividend ELSE 0 END) as monthly_outgoing,
|
|
COUNT(DISTINCT CASE WHEN i.status = 'approved' THEN i.investor_id END) as active_investors,
|
|
MIN(CASE WHEN i.status = 'approved' THEN i.next_payment_date END) as next_payment_date
|
|
FROM investments i
|
|
JOIN startups s ON i.startup_id = s.id
|
|
WHERE s.founder_id = ?
|
|
");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$repaymentSummary = $stmt->fetch();
|
|
} else {
|
|
$stmt = db()->prepare("SELECT i.*, s.name as startup_name FROM investments i JOIN startups s ON i.startup_id = s.id WHERE i.investor_id = ? ORDER BY i.created_at DESC");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$myInvestments = $stmt->fetchAll();
|
|
}
|
|
|
|
function number_get_formatted($num) {
|
|
return number_format((float)$num, 0, '.', ',');
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Dashboard — <?= 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>
|
|
.profile-link-card {
|
|
text-decoration: none;
|
|
color: inherit;
|
|
transition: transform 0.2s;
|
|
display: block;
|
|
}
|
|
.profile-link-card:hover {
|
|
transform: translateY(-2px);
|
|
}
|
|
.modal {
|
|
display: none;
|
|
position: fixed;
|
|
z-index: 2000;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgba(0,0,0,0.9);
|
|
backdrop-filter: blur(4px);
|
|
}
|
|
.repayment-stat-card {
|
|
background: rgba(255,255,255,0.03);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 16px;
|
|
padding: 20px;
|
|
text-align: left;
|
|
}
|
|
.repayment-stat-label {
|
|
font-size: 11px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
color: var(--text-secondary);
|
|
font-weight: 700;
|
|
margin-bottom: 8px;
|
|
}
|
|
.repayment-stat-value {
|
|
font-size: 20px;
|
|
font-weight: 900;
|
|
color: #fff;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<div class="container" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
|
|
<a href="dashboard.php" class="logo-container">
|
|
<img src="assets/images/logo.svg?v=<?php echo time(); ?>" alt="<?= htmlspecialchars($platformName) ?> Logo" class="logo-img">
|
|
<span class="logo-text"><?= htmlspecialchars($platformName) ?></span>
|
|
</a>
|
|
<nav class="nav-links">
|
|
<?php if ($user['role'] === 'founder'): ?>
|
|
<a href="startups.php">My Startups</a>
|
|
<a href="partners.php">Find Partners</a>
|
|
<?php else: ?>
|
|
<a href="funding_rounds.php">Founding Rounds</a>
|
|
<a href="portfolio.php">Portfolio</a>
|
|
<a href="discover.php">Discovery Hub</a>
|
|
<?php endif; ?>
|
|
<a href="messages.php">Messages</a>
|
|
</nav>
|
|
<div style="display: flex; align-items: center; gap: 15px;">
|
|
<div onclick="openWalletModal('add')" style="cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--surface-color); border-radius: 50px; border: 1px solid var(--border-color);">
|
|
<i class="fas fa-wallet" style="color: var(--accent-primary); font-size: 14px;"></i>
|
|
<span id="header-wallet-balance" style="font-size: 14px; 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>
|
|
<div style="display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--surface-color); border-radius: 50px; border: 1px solid var(--border-color);">
|
|
<div style="width: 24px; height: 24px; background: var(--accent-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #000; font-weight: 800;">
|
|
<?= substr($user['full_name'], 0, 1) ?>
|
|
</div>
|
|
<span style="font-size: 13px; font-weight: 600;"><?= htmlspecialchars(explode(' ', $user['full_name'])[0]) ?></span>
|
|
</div>
|
|
<a href="logout.php" class="btn btn-secondary" style="padding: 8px 16px; font-size: 12px;">Log Out</a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="container" style="padding-top: 60px; padding-bottom: 80px;">
|
|
<div style="margin-bottom: 60px;">
|
|
<div class="match-score-pill" style="margin-bottom: 24px; color: var(--accent-primary); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 1px;">
|
|
<i class="fas fa-rocket"></i> Launchpad Active
|
|
</div>
|
|
<h1 style="font-size: 56px; font-weight: 900; letter-spacing: -2px; line-height: 1.1;">Welcome back, <span style="color: var(--accent-primary);"><?= htmlspecialchars(explode(' ', $user['full_name'])[0]) ?>.</span></h1>
|
|
<p style="color: var(--text-secondary); font-size: 20px; margin-top: 10px;">Your command center for the next big thing.</p>
|
|
</div>
|
|
|
|
<?php if ($user['role'] === 'founder'): ?>
|
|
<!-- Founder Repayment Dashboard -->
|
|
<div class="card" style="margin-bottom: 40px; padding: 35px; border: 1px solid var(--accent-primary)33; background: linear-gradient(145deg, rgba(0, 242, 255, 0.05), transparent);">
|
|
<h3 style="margin-bottom: 25px; font-size: 22px; font-weight: 800;"><i class="fas fa-chart-pie" style="color: var(--accent-primary); margin-right: 10px;"></i> Funding & Repayment Overview</h3>
|
|
<div style="display: grid; grid-template-columns: repeat(5, 1fr); gap: 15px;">
|
|
<div class="repayment-stat-card">
|
|
<div class="repayment-stat-label">Total Raised</div>
|
|
<div class="repayment-stat-value">£<?= number_format($repaymentSummary['total_raised'] ?? 0, 0) ?></div>
|
|
</div>
|
|
<div class="repayment-stat-card">
|
|
<div class="repayment-stat-label">Total Obligation</div>
|
|
<div class="repayment-stat-value" style="color: var(--error-color);">£<?= number_format($repaymentSummary['total_obligation'] ?? 0, 0) ?></div>
|
|
</div>
|
|
<div class="repayment-stat-card">
|
|
<div class="repayment-stat-label">Monthly Outgoing</div>
|
|
<div class="repayment-stat-value" style="color: var(--warning-color);">£<?= number_format($repaymentSummary['monthly_outgoing'] ?? 0, 0) ?></div>
|
|
</div>
|
|
<div class="repayment-stat-card">
|
|
<div class="repayment-stat-label">Active Investors</div>
|
|
<div class="repayment-stat-value"><?= $repaymentSummary['active_investors'] ?? 0 ?></div>
|
|
</div>
|
|
<div class="repayment-stat-card">
|
|
<div class="repayment-stat-label">Next Due Date</div>
|
|
<div class="repayment-stat-value" style="font-size: 16px;"><?= $repaymentSummary['next_payment_date'] ? date('M d, Y', strtotime($repaymentSummary['next_payment_date'])) : 'None' ?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div style="display: grid; grid-template-columns: 2fr 1fr; gap: 40px;">
|
|
<div>
|
|
<?php if ($user['role'] === 'founder'): ?>
|
|
<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>
|
|
<div style="display: flex; gap: 10px;">
|
|
<a href="create_startup.php" class="btn btn-primary" style="padding: 12px 24px; font-size: 13px;">+ Launch Startup</a>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (empty($myStartups)): ?>
|
|
<div style="text-align: center; padding: 60px 0; background: var(--elevated-color); border-radius: 16px; border: 1px dashed var(--border-color);">
|
|
<div class="card-icon" style="margin: 0 auto 20px;"><i class="fas fa-rocket"></i></div>
|
|
<p style="color: var(--text-secondary); margin-bottom: 25px; font-size: 18px;">Ready to share your vision with the world?</p>
|
|
<a href="create_startup.php" class="btn btn-primary">Start Your First Round</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div style="display: grid; grid-template-columns: 1fr; gap: 20px;">
|
|
<?php foreach ($myStartups as $startup):
|
|
$goal = $startup['active_goal'] ?? $startup['funding_target'];
|
|
$raised = $startup['active_raised'] ?? $startup['funding_raised'];
|
|
$isTrending = in_array($startup['id'], $trendingIds);
|
|
?>
|
|
<div class="candidate-card" style="padding: 25px; display: flex; justify-content: space-between; align-items: center; cursor: pointer;" onclick="window.location.href='startup_details.php?id=<?= $startup['id'] ?>'">
|
|
<div style="display: flex; align-items: center; gap: 20px;">
|
|
<div style="width: 60px; height: 60px; background: var(--accent-primary); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #000; font-weight: 800;">
|
|
<?= substr($startup['name'], 0, 1) ?>
|
|
</div>
|
|
<div>
|
|
<div style="font-weight: 800; font-size: 20px; margin-bottom: 6px;">
|
|
<?= htmlspecialchars($startup['name']) ?>
|
|
<?php if ($isTrending): ?>
|
|
<span class="trending-pill"><i class="fas fa-fire"></i> Trending</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div style="font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; gap: 12px;">
|
|
<span style="padding: 4px 10px; background: var(--surface-color); color: var(--accent-primary); border-radius: 6px; font-weight: 700; font-size: 11px; letter-spacing: 0.5px; border: 1px solid var(--border-color);">
|
|
<?= strtoupper($startup['round_status'] ?? 'Draft') ?>
|
|
</span>
|
|
<span style="opacity: 0.7;">Target: £<?= number_get_formatted($goal) ?></span>
|
|
</div>
|
|
</div>
|
|
</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 14px; font-size: 11px; background: var(--success-color); color: #000;">Finish</button>
|
|
<button onclick="event.stopPropagation(); updateRound(<?= $startup['round_id'] ?>, 'Cancelled')" class="btn" style="padding: 8px 14px; font-size: 11px; background: var(--error-color); color: #fff;">Cancel</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php else: ?>
|
|
<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;">Portfolio Overview</h3>
|
|
<a href="funding_rounds.php" class="btn btn-primary" style="padding: 12px 24px; font-size: 13px;">Find New Deals</a>
|
|
</div>
|
|
|
|
<?php if (empty($myInvestments)): ?>
|
|
<div style="text-align: center; padding: 60px 0; background: var(--elevated-color); border-radius: 16px; border: 1px dashed var(--border-color);">
|
|
<div class="card-icon" style="margin: 0 auto 20px;"><i class="fas fa-chart-line"></i></div>
|
|
<p style="color: var(--text-secondary); margin-bottom: 25px; font-size: 18px;">Start backing the next generation of founders.</p>
|
|
<a href="funding_rounds.php" class="btn btn-primary">Start Investing</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div style="display: grid; grid-template-columns: 1fr; gap: 20px;">
|
|
<?php foreach ($myInvestments as $inv): ?>
|
|
<div class="candidate-card" style="padding: 25px; display: flex; justify-content: space-between; align-items: center; cursor: pointer;" onclick="window.location.href='startup_details.php?id=<?= $inv['startup_id'] ?>'">
|
|
<div style="display: flex; align-items: center; gap: 20px;">
|
|
<div style="width: 60px; height: 60px; background: var(--surface-color); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; border: 1px solid var(--border-color);">
|
|
<i class="fas fa-building" style="opacity: 0.5;"></i>
|
|
</div>
|
|
<div>
|
|
<div style="font-weight: 800; font-size: 20px; margin-bottom: 6px;"><?= htmlspecialchars($inv['startup_name']) ?></div>
|
|
<div style="font-size: 14px; color: var(--text-secondary);">Committed on <?= date('M d, Y', strtotime($inv['created_at'])) ?></div>
|
|
</div>
|
|
</div>
|
|
<div style="text-align: right;">
|
|
<div style="font-size: 22px; font-weight: 900; color: var(--accent-primary);">£<?= number_get_formatted($inv['amount']) ?></div>
|
|
<div style="font-size: 13px; font-weight: 800; color: <?= $inv['status'] === 'approved' ? 'var(--success-color)' : ($inv['status'] === 'rejected' ? 'var(--error-color)' : 'var(--warning-color)') ?>; letter-spacing: 1px;">
|
|
<?= strtoupper($inv['status']) ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="card" style="padding: 40px; text-align: center; border-style: dashed;">
|
|
<h3 style="font-size: 22px; font-weight: 800; margin-bottom: 10px;">Ecosystem Activity</h3>
|
|
<p style="color: var(--text-secondary); font-size: 16px;">Insights from your network and trending matches will appear here.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<!-- Money Pot Section -->
|
|
<div class="card" style="margin-bottom: 30px; padding: 30px; background: var(--elevated-color);">
|
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;">
|
|
<h3 style="margin: 0; font-size: 18px; font-weight: 800; color: var(--accent-primary);">My Money Pot</h3>
|
|
<i class="fas fa-wallet" style="color: var(--accent-primary); opacity: 0.5;"></i>
|
|
</div>
|
|
<div style="margin-bottom: 32px;">
|
|
<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: 40px; font-weight: 900; color: #fff; margin-top: 5px; letter-spacing: -1px;">£<?= number_format($user['balance'], 2) ?></div>
|
|
</div>
|
|
<div style="display: grid; grid-template-columns: 1fr; gap: 12px;">
|
|
<button onclick="openWalletModal('add')" class="btn btn-primary" style="padding: 14px; font-size: 13px;">
|
|
<i class="fas fa-plus-circle" style="margin-right: 8px;"></i> Add Funds
|
|
</button>
|
|
<button onclick="openWalletModal('withdraw')" class="btn btn-secondary" style="padding: 14px; font-size: 13px;">
|
|
<i class="fas fa-minus-circle" style="margin-right: 8px;"></i> Withdraw
|
|
</button>
|
|
</div>
|
|
</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>
|
|
<a href="edit_profile.php" style="color: var(--accent-primary); font-size: 13px; font-weight: 700; text-decoration: none; padding: 6px 14px; background: var(--surface-color); border-radius: 50px; border: 1px solid var(--border-color);">Edit</a>
|
|
</div>
|
|
<a href="profile.php?id=<?= $user['id'] ?>" class="profile-link-card">
|
|
<div style="display: flex; align-items: center; gap: 20px; margin-bottom: 25px;">
|
|
<div style="width: 80px; height: 80px; background: var(--accent-primary); border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 32px; color: #000; font-weight: 900;">
|
|
<?= substr($user['full_name'], 0, 1) ?>
|
|
</div>
|
|
<div>
|
|
<div style="font-weight: 900; font-size: 22px; letter-spacing: -0.5px;"><?= htmlspecialchars($user['full_name']) ?></div>
|
|
<div style="font-size: 14px; color: var(--accent-primary); font-weight: 700; opacity: 0.8;"><?= htmlspecialchars($user['university']) ?></div>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
<div style="margin-bottom: 25px; font-size: 15px; line-height: 1.6; color: var(--text-secondary);">
|
|
<?= htmlspecialchars($user['bio'] ?: 'No bio provided yet.') ?>
|
|
</div>
|
|
|
|
<?php if ($user['role'] === 'founder'): ?>
|
|
<div style="display: flex; flex-wrap: wrap; gap: 10px;">
|
|
<?php
|
|
$skills = explode(',', $user['skills'] ?? '');
|
|
foreach (array_slice($skills, 0, 3) as $skill): if(empty(trim($skill))) continue; ?>
|
|
<span style="font-size: 11px; padding: 6px 14px; background: var(--surface-color); border-radius: 50px; border: 1px solid var(--border-color); font-weight: 600; color: var(--text-secondary);"><?= htmlspecialchars(trim($skill)) ?></span>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="card" style="background: var(--accent-primary); color: #000; border: none; margin-bottom: 30px; padding: 30px;">
|
|
<h3 style="color: #000; margin-bottom: 12px; font-size: 22px; font-weight: 800;"><?= $user['role'] === 'founder' ? 'Find Your Team' : 'Discover Talent' ?></h3>
|
|
<p style="font-size: 15px; opacity: 0.8; margin-bottom: 25px; font-weight: 500;">
|
|
<?= $user['role'] === 'founder' ? 'Start swiping to find co-founders with complementary skills.' : 'Explore the most promising student startups today.' ?>
|
|
</p>
|
|
<a href="<?= $user['role'] === 'founder' ? 'partners.php' : 'discover.php' ?>" class="btn" style="width: 100%; background: #000; color: var(--accent-primary); font-weight: 800; text-align: center;">
|
|
<?= $user['role'] === 'founder' ? 'Launch Matching' : 'Go to Discovery Hub' ?>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<!-- Wallet Modal -->
|
|
<div id="wallet-modal" class="modal">
|
|
<div class="modal-content" style="width: 100%; max-width: 420px; margin: 10% auto;">
|
|
<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: var(--text-secondary); 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: 12px; font-size: 12px; color: var(--text-secondary); 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: var(--bg-color); border: 1px solid var(--border-color); border-radius: 12px; 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;">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.className = 'btn btn-primary';
|
|
} else {
|
|
title.innerText = 'Withdraw Funds';
|
|
submitBtn.innerText = 'Confirm Withdrawal';
|
|
submitBtn.className = 'btn btn-secondary';
|
|
}
|
|
|
|
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});
|
|
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 {
|
|
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);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
window.onclick = function(event) {
|
|
const modal = document.getElementById('wallet-modal');
|
|
if (event.target == modal) {
|
|
closeWalletModal();
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|