Welcome, !
Wallet Balance
R
Available Funds
Quick Actions
Recent Transactions
exec("CREATE TABLE IF NOT EXISTS transactions ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, description VARCHAR(255) NOT NULL, amount DECIMAL(10, 2) NOT NULL, type VARCHAR(50) NOT NULL, notes TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) )"); // Fetch transactions for the logged-in user $stmt = $pdo->prepare("SELECT description, amount, type, notes, created_at FROM transactions WHERE user_id = :user_id ORDER BY created_at DESC LIMIT 10"); $stmt->execute(['user_id' => $user_id]); $transactions = $stmt->fetchAll(); if (count($transactions) > 0) { echo '- ';
foreach ($transactions as $tx) {
$amount_class = $tx['amount'] > 0 ? 'text-success' : 'text-danger';
$icon = $tx['amount'] > 0 ? 'bi-arrow-down-circle-fill' : 'bi-arrow-up-circle-fill';
$amount_prefix = $tx['amount'] > 0 ? '+' : '-';
$formatted_amount = 'R' . number_format(abs($tx['amount']), 2);
echo '
- ';
echo ''; echo ''; echo '' . htmlspecialchars($tx['description']) . ''; echo '' . htmlspecialchars($tx['type']) . ''; if (!empty($tx['notes'])) { echo '' . htmlspecialchars($tx['notes']) . ''; } echo ''; echo '' . $amount_prefix . ' ' . $formatted_amount . ''; echo ' ';
}
echo '
No recent transactions.
'; } } catch (PDOException $e) { echo 'Database error: Could not fetch transactions.
'; } ?>