diff --git a/api/wallet_transaction.php b/api/wallet_transaction.php new file mode 100644 index 0000000..d5fa388 --- /dev/null +++ b/api/wallet_transaction.php @@ -0,0 +1,63 @@ + false, 'error' => 'Unauthorized']); + exit; +} + +$user_id = $_SESSION['user_id']; +$action = $_POST['action'] ?? ''; +$amount = (float)($_POST['amount'] ?? 0); + +if ($amount <= 0) { + header('Content-Type: application/json'); + echo json_encode(['success' => false, 'error' => 'Invalid amount']); + exit; +} + +try { + db()->beginTransaction(); + + // Fetch current balance + $stmt = db()->prepare("SELECT balance FROM users WHERE id = ? FOR UPDATE"); + $stmt->execute([$user_id]); + $user = $stmt->fetch(); + + if (!$user) { + throw new Exception("User not found"); + } + + $current_balance = (float)$user['balance']; + + if ($action === 'add') { + $new_balance = $current_balance + $amount; + $stmt = db()->prepare("UPDATE users SET balance = ? WHERE id = ?"); + $stmt->execute([$new_balance, $user_id]); + + // Log transaction (optional but good practice, maybe later) + + db()->commit(); + echo json_encode(['success' => true, 'new_balance' => $new_balance]); + } elseif ($action === 'withdraw') { + if ($current_balance < $amount) { + throw new Exception("Insufficient funds"); + } + + $new_balance = $current_balance - $amount; + $stmt = db()->prepare("UPDATE users SET balance = ? WHERE id = ?"); + $stmt->execute([$new_balance, $user_id]); + + db()->commit(); + echo json_encode(['success' => true, 'new_balance' => $new_balance]); + } else { + throw new Exception("Invalid action"); + } + +} catch (Exception $e) { + db()->rollBack(); + header('Content-Type: application/json'); + echo json_encode(['success' => false, 'error' => $e->getMessage()]); +} diff --git a/dashboard.php b/dashboard.php index 30e21df..debbacc 100644 --- a/dashboard.php +++ b/dashboard.php @@ -65,10 +65,10 @@ $myInvestments = []; if ($user['role'] === 'founder') { $stmt = db()->prepare(" - SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status + SELECT s.*, fr.funding_goal as active_goal, fr.funding_raised as active_raised, fr.status as round_status, fr.id as round_id FROM startups s LEFT JOIN funding_rounds fr ON s.id = fr.startup_id AND fr.status = 'Active' - WHERE s.founder_id = ? + WHERE s.user_id = ? ORDER BY s.created_at DESC "); $stmt->execute([$_SESSION['user_id']]); @@ -118,6 +118,28 @@ function number_get_formatted($num) { .profile-link-card:hover { transform: translateY(-2px); } + + /* Modal Styles */ + .modal { + display: none; + position: fixed; + z-index: 1000; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: rgba(0,0,0,0.8); + backdrop-filter: blur(5px); + } + .modal-content { + background-color: #1a1a24; + margin: 10% auto; + padding: 40px; + border: 1px solid var(--border-color); + width: 400px; + border-radius: 32px; + box-shadow: 0 25px 50px rgba(0,0,0,0.5); + }
@@ -172,7 +194,9 @@ function number_get_formatted($num) {+ + Manage your startup capital and dividend funds. + + Manage your investment capital and earnings. + +
+Unlock direct access to institutional investors and exclusive demo days.
- -