140 lines
6.6 KiB
PHP
140 lines
6.6 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>UBPay Dashboard</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="index.php">
|
|
<i class="bi bi-wallet2"></i> UBPay
|
|
</a>
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#">
|
|
<i class="bi bi-person-circle"></i> Profile
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
|
|
<main class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h1 class="h3 mb-4">Welcome, User!</h1>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<!-- Wallet Balance -->
|
|
<div class="col-md-6 col-lg-4 mb-4">
|
|
<div class="card text-white" style="background: linear-gradient(135deg, #00A859 0%, #007B5F 100%);">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Wallet Balance</h5>
|
|
<p class="display-4 fw-bold">R1,250.75</p>
|
|
<p class="card-text text-white-50">Available Funds</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quick Actions -->
|
|
<div class="col-md-6 col-lg-8 mb-4">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title mb-3">Quick Actions</h5>
|
|
<div class="d-grid gap-2 d-sm-flex">
|
|
<button class="btn btn-primary flex-fill"><i class="bi bi-send"></i> Send Money</button>
|
|
<button class="btn btn-secondary flex-fill"><i class="bi bi-shop"></i> Pay Merchant</button>
|
|
<button class="btn btn-info flex-fill"><i class="bi bi-phone"></i> Buy Airtime</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Recent Transactions -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Recent Transactions</h5>
|
|
<?php
|
|
require_once 'db/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
|
|
// Create transactions table if it doesn't exist
|
|
$pdo->exec("CREATE TABLE IF NOT EXISTS transactions (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
description VARCHAR(255) NOT NULL,
|
|
amount DECIMAL(10, 2) NOT NULL,
|
|
type VARCHAR(50) NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
)");
|
|
|
|
// Clear existing transactions and insert sample data for demonstration
|
|
$pdo->exec("TRUNCATE TABLE transactions");
|
|
$transactions = [
|
|
['Payment to Shoprite', -120.50, 'Merchant Payment'],
|
|
['Received from J. Doe', 250.00, 'P2P Transfer'],
|
|
['Airtime Purchase (MTN)', -50.00, 'Bill Payment'],
|
|
['Payment to Pick n Pay', -340.75, 'Merchant Payment'],
|
|
['Received from A. Smith', 500.00, 'P2P Transfer'],
|
|
];
|
|
$stmt = $pdo->prepare("INSERT INTO transactions (description, amount, type) VALUES (?, ?, ?)");
|
|
foreach ($transactions as $tx) {
|
|
$stmt->execute($tx);
|
|
}
|
|
|
|
|
|
// Fetch transactions
|
|
$stmt = $pdo->query("SELECT description, amount, type, created_at FROM transactions ORDER BY created_at DESC");
|
|
$transactions = $stmt->fetchAll();
|
|
|
|
if (count($transactions) > 0) {
|
|
echo '<ul class="list-group list-group-flush">';
|
|
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 '<li class="list-group-item d-flex justify-content-between align-items-center">';
|
|
echo '<div>';
|
|
echo '<i class="bi ' . $icon . ' ' . $amount_class . '"></i>';
|
|
echo '<strong class="ms-2">' . htmlspecialchars($tx['description']) . '</strong>';
|
|
echo '<small class="d-block text-muted">' . htmlspecialchars($tx['type']) . '</small>';
|
|
echo '</div>';
|
|
echo '<span class="' . $amount_class . ' fw-bold">' . $amount_prefix . ' ' . $formatted_amount . '</span>';
|
|
echo '</li>';
|
|
}
|
|
echo '</ul>';
|
|
} else {
|
|
echo '<p class="text-muted">No recent transactions.</p>';
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo '<p class="text-danger">Database error: ' . htmlspecialchars($e->getMessage()) . '</p>';
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<footer class="text-center text-muted py-4">
|
|
© 2025 UBPay. All Rights Reserved.
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|