PNG IHDR x sBIT|d pHYs + tEXtSoftware www.inkscape.org< ,tEXtComment
<?php
// 🔴 DEBUG MODE ON
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
// 1. STRICT SECURITY PERIMETER
if (!isset($_SESSION['admin_id']) || !isset($_SESSION['is_admin']) || $_SESSION['is_admin'] !== true) {
session_destroy();
header("Location: admin-login.php");
exit();
}
$host = 'localhost';
$dbname = 'u264723324_NuDb';
$user = 'u264723324_NuUu';
$pass = '@WdsdsdAq1231';
try {
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $user, $pass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// =======================================================
// AJAX HANDLER: ISSUE OR REJECT CARDS
// =======================================================
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax_action'])) {
header('Content-Type: application/json');
if ($_POST['ajax_action'] === 'process_card') {
$cardId = filter_input(INPUT_POST, 'card_id', FILTER_VALIDATE_INT);
$action = filter_input(INPUT_POST, 'status', FILTER_SANITIZE_STRING); // 'active' or 'blocked'
if (!$cardId || !in_array($action, ['active', 'blocked'])) {
echo json_encode(['success' => false, 'message' => 'Invalid parameters.']);
exit;
}
try {
$stmt = $pdo->prepare("UPDATE cards SET status = ? WHERE id = ?");
$stmt->execute([$action, $cardId]);
$msg = ($action === 'active') ? 'Card successfully issued and activated.' : 'Card request rejected/blocked.';
echo json_encode(['success' => true, 'message' => $msg]);
} catch (Exception $e) {
echo json_encode(['success' => false, 'message' => 'Database error during update.']);
}
exit;
}
}
// =======================================================
// FETCH CARD QUEUE (Pending First, Then Active/Blocked)
// =======================================================
$query = "
SELECT c.*, u.first_name, u.last_name, u.email
FROM cards c
JOIN users u ON c.user_id = u.id
ORDER BY
CASE WHEN c.status = 'pending' THEN 1 ELSE 2 END,
c.created_at DESC
";
$stmtCards = $pdo->query($query);
$cardList = $stmtCards->fetchAll(PDO::FETCH_ASSOC);
// Count pending cards for the header badge
$stmtCount = $pdo->query("SELECT COUNT(*) FROM cards WHERE status = 'pending'");
$pendingCount = $stmtCount->fetchColumn();
} catch (PDOException $e) {
$cardList = [];
$pendingCount = 0;
$dbError = "Database connection unstable. " . $e->getMessage();
}
$adminName = htmlspecialchars($_SESSION['admin_username']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Card Manager - City Prime Admin</title>
<style>
:root {
--bg-deep: #050505; --surface-dark: #0f0f0f; --surface-light: #1a1a1a;
--border-red: #7f1d1d; --danger: #ef4444; --danger-glow: rgba(239, 68, 68, 0.15);
--text-main: #f8fafc; --text-muted: #64748b; --success: #22c55e; --warning: #facc15;
--card-gradient: linear-gradient(135deg, #0284c7, #0f172a);
}
* { margin: 0; padding: 0; box-sizing: border-box; font-family: "Courier New", Courier, monospace; }
body { background-color: var(--bg-deep); color: var(--text-main); display: flex; min-height: 100vh; overflow-x: hidden; }
.grid-bg { position: fixed; width: 100vw; height: 100vh; background-image: linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px); background-size: 30px 30px; z-index: 0; pointer-events: none;}
/* SIDEBAR */
.sidebar { width: 260px; background: var(--surface-dark); border-right: 1px solid var(--border-red); height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column; padding: 24px 0; z-index: 10;}
.brand { text-align: center; margin-bottom: 40px; padding: 0 24px;}
.brand h2 { color: var(--danger); letter-spacing: 2px; text-transform: uppercase; font-size: 1.4rem; text-shadow: 0 0 10px rgba(239,68,68,0.4);}
.brand p { color: var(--text-muted); font-size: 0.75rem; letter-spacing: 1px; margin-top: 4px; }
.nav-links { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; flex: 1;}
.nav-links a { text-decoration: none; color: var(--text-muted); padding: 14px 20px; border-radius: 8px; transition: 0.2s; display: flex; align-items: center; gap: 12px; font-weight: bold; letter-spacing: 1px;}
.nav-links a:hover, .nav-links a.active { background: var(--danger-glow); color: var(--danger); border: 1px solid rgba(239,68,68,0.3);}
.logout-box { padding: 0 16px; margin-top: auto;}
.logout-btn { display: block; text-align: center; background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 14px; border-radius: 8px; text-decoration: none; font-weight: bold; transition: 0.2s; letter-spacing: 1px;}
.logout-btn:hover { background: var(--danger); color: white; box-shadow: 0 0 15px rgba(239,68,68,0.4);}
/* MAIN CONTENT */
.main-content { flex: 1; padding: 32px 40px; position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; width: 100%;}
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 40px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 24px;}
.page-title h1 { font-size: 1.8rem; font-weight: normal; letter-spacing: 2px;}
.page-title p { color: var(--text-muted); font-size: 0.9rem; margin-top: 8px;}
.queue-badge { background: rgba(250, 204, 21, 0.1); border: 1px solid var(--warning); color: var(--warning); padding: 8px 16px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; letter-spacing: 1px;}
/* DATA TABLE */
.data-panel { background: var(--surface-dark); border: 1px solid rgba(255,255,255,0.05); border-radius: 16px; padding: 24px; overflow-x: auto; min-height: 500px;}
table { width: 100%; border-collapse: collapse; min-width: 900px;}
th { text-align: left; padding: 16px; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; border-bottom: 1px solid rgba(255,255,255,0.1); letter-spacing: 1px; font-weight: normal;}
td { padding: 16px; border-bottom: 1px solid rgba(255,255,255,0.02); font-size: 0.95rem; vertical-align: middle;}
tr:last-child td { border-bottom: none;}
tr:hover td { background: rgba(255,255,255,0.02);}
.td-name { font-weight: bold; margin-bottom: 4px; display: block; font-size: 1rem; color: var(--text-main);}
.td-sub { color: var(--text-muted); font-size: 0.8rem;}
.td-cardnum { font-family: monospace; font-size: 1.1rem; letter-spacing: 1px;}
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; display: inline-block;}
.badge.active { background: rgba(34, 197, 94, 0.1); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.3);}
.badge.pending { background: rgba(250, 204, 21, 0.1); color: var(--warning); border: 1px solid rgba(250, 204, 21, 0.3);}
.badge.blocked { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3);}
.action-btn { background: rgba(14, 165, 233, 0.1); border: 1px solid rgba(14, 165, 233, 0.3); color: var(--accent-blue); padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; transition: 0.2s; font-family: inherit; font-weight: bold;}
.action-btn:hover { background: var(--accent-blue); color: white; box-shadow: 0 0 10px rgba(14,165,233,0.4);}
.action-btn.disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; border-color: transparent; background: rgba(255,255,255,0.05); color: var(--text-muted);}
/* MODAL (REVIEW CARD) */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: 0.3s; z-index: 1000; }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-container { background: var(--surface-dark); width: 100%; max-width: 500px; border-radius: 16px; padding: 32px; border: 1px solid var(--accent-blue); box-shadow: 0 0 30px rgba(14,165,233,0.1); transform: translateY(20px); transition: 0.3s;}
.modal-overlay.active .modal-container { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 16px;}
.modal-header h3 { font-size: 1.4rem; color: var(--accent-blue); text-transform: uppercase; letter-spacing: 1px;}
.close-btn { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition: 0.2s;}
.close-btn:hover { color: var(--text-main);}
/* Simulated Credit Card inside Modal */
.visual-card { background: var(--card-gradient); border-radius: 16px; padding: 24px; margin-bottom: 24px; position: relative; overflow: hidden; border: 1px solid rgba(255,255,255,0.2); box-shadow: 0 10px 20px rgba(0,0,0,0.5);}
.visual-card::after { content: ''; position: absolute; top: -50px; right: -50px; width: 150px; height: 150px; background: rgba(255,255,255,0.05); border-radius: 50%; pointer-events: none;}
.vc-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; position: relative; z-index: 2;}
.vc-top h4 { font-size: 1.1rem; color: white;}
.vc-chip { width: 40px; height: 30px; background: linear-gradient(135deg, #eab308, #ca8a04); border-radius: 6px; }
.vc-number { font-size: 1.4rem; letter-spacing: 2px; margin-bottom: 24px; font-family: monospace; color: white; position: relative; z-index: 2; text-shadow: 0 2px 4px rgba(0,0,0,0.5);}
.vc-bottom { display: flex; justify-content: space-between; font-size: 0.75rem; color: rgba(255,255,255,0.8); position: relative; z-index: 2;}
.vc-bottom h5 { font-size: 0.9rem; color: white; margin-top: 4px; text-transform: uppercase; letter-spacing: 1px;}
.modal-actions { display: flex; gap: 16px;}
.btn-approve { flex: 1; background: rgba(34, 197, 94, 0.1); color: var(--success); border: 1px solid var(--success); padding: 16px; border-radius: 8px; font-size: 0.9rem; font-weight: bold; cursor: pointer; transition: 0.2s; text-transform: uppercase; letter-spacing: 1px;}
.btn-approve:hover { background: var(--success); color: white; box-shadow: 0 0 15px rgba(34,197,94,0.4);}
.btn-reject { flex: 1; background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid var(--danger); padding: 16px; border-radius: 8px; font-size: 0.9rem; font-weight: bold; cursor: pointer; transition: 0.2s; text-transform: uppercase; letter-spacing: 1px;}
.btn-reject:hover { background: var(--danger); color: white; box-shadow: 0 0 15px rgba(239,68,68,0.4);}
/* TOAST */
.toast { position: fixed; top: 20px; right: -300px; background: var(--success); color: white; padding: 16px 24px; border-radius: 8px; font-weight: bold; box-shadow: 0 4px 12px rgba(0,0,0,0.3); transition: 0.4s; z-index: 2000; font-family: monospace; letter-spacing: 1px;}
.toast.show { right: 20px; }
.toast.error { background: var(--danger); }
</style>
</head>
<body oncontextmenu="return false;">
<div class="grid-bg"></div>
<aside class="sidebar">
<div class="brand">
<h2>City Prime</h2>
<p>COMMAND CENTER</p>
</div>
<nav class="nav-links">
<a href="admin-dashboard.php"><span>[1]</span> Dashboard</a>
<a href="admin-users.php"><span>[2]</span> User Matrix</a>
<a href="admin-kyc.php"><span>[3]</span> KYC Approvals</a>
<a href="admin-cards.php" class="active"><span>[4]</span> Card Requests</a>
<a href="admin-transactions.php"><span>[5]</span> Ledgers</a>
<a href="admin-settings.php"><span>[6]</span> System Config</a>
</nav>
<div class="logout-box">
<a href="admin-logout.php" class="logout-btn">TERMINATE SESSION</a>
</div>
</aside>
<main class="main-content">
<div class="top-bar">
<div class="page-title">
<h1>Card Issuance Queue</h1>
<p>Review and provision virtual and physical cards.</p>
</div>
<div class="queue-badge" id="headerQueueCount" style="<?php echo ($pendingCount == 0) ? 'display:none;' : ''; ?>">
<?php echo $pendingCount; ?> PENDING
</div>
</div>
<div class="data-panel">
<?php if (isset($dbError)): ?>
<div style="color: var(--danger); margin-bottom: 16px;"><?php echo $dbError; ?></div>
<?php endif; ?>
<table id="cardsTable">
<thead>
<tr>
<th>Requester</th>
<th>Card Number</th>
<th>Card Type / Style</th>
<th>Date Requested</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php if (empty($cardList)): ?>
<tr><td colspan="6" style="text-align:center; padding:40px; color:var(--text-muted); font-style:italic;">No cards in the database.</td></tr>
<?php else: ?>
<?php foreach ($cardList as $c):
// Mask the card number for display
$maskedNumber = "**** **** **** " . substr($c['card_number'], -4);
// Determine if we should show the action button
$isPending = ($c['status'] === 'pending');
?>
<tr>
<td>
<span class="td-name"><?php echo htmlspecialchars($c['first_name'] . ' ' . $c['last_name']); ?></span>
<span class="td-sub"><?php echo htmlspecialchars($c['email']); ?></span>
</td>
<td class="td-cardnum"><?php echo $maskedNumber; ?></td>
<td>
<span style="display: block; font-weight: bold;"><?php echo htmlspecialchars($c['card_type']); ?></span>
<span class="td-sub">Style: <?php echo ucfirst(htmlspecialchars($c['card_style'])); ?></span>
</td>
<td style="color: var(--text-muted);">
<?php echo date('M d, Y - H:i', strtotime($c['created_at'])); ?>
</td>
<td>
<span class="badge <?php echo $c['status']; ?>" id="badge-<?php echo $c['id']; ?>">
<?php echo strtoupper($c['status']); ?>
</span>
</td>
<td>
<button class="action-btn <?php echo $isPending ? '' : 'disabled'; ?>" id="btn-<?php echo $c['id']; ?>" onclick="openCardModal(
<?php echo $c['id']; ?>,
'<?php echo addslashes($c['first_name'] . ' ' . $c['last_name']); ?>',
'<?php echo addslashes($c['card_type']); ?>',
'<?php echo $maskedNumber; ?>',
'<?php echo addslashes($c['expiry_date']); ?>',
'<?php echo addslashes($c['card_style']); ?>'
)">REVIEW</button>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</main>
<div class="modal-overlay" id="cardModal">
<div class="modal-container">
<div class="modal-header">
<h3>Provision Card</h3>
<button class="close-btn" onclick="closeModal()">×</button>
</div>
<div class="visual-card" id="visualCard">
<div class="vc-top">
<h4 id="modalCardType">Card Type</h4>
<div class="vc-chip"></div>
</div>
<div class="vc-number" id="modalCardNum">**** **** **** ****</div>
<div class="vc-bottom">
<div>
<p>Card Holder</p>
<h5 id="modalCardHolder">HOLDER NAME</h5>
</div>
<div>
<p>Valid Thru</p>
<h5 id="modalExpiry">--/--</h5>
</div>
</div>
</div>
<input type="hidden" id="modalCardId">
<div class="modal-actions">
<button class="btn-reject" onclick="processCard('blocked')">BLOCK / REJECT</button>
<button class="btn-approve" onclick="processCard('active')">ISSUE CARD</button>
</div>
</div>
</div>
<div id="toast" class="toast">Command Executed</div>
<script>
let pendingQueueCount = <?php echo $pendingCount; ?>;
// --- Toast Notification ---
function showToast(msg, isError = false) {
const toast = document.getElementById('toast');
toast.textContent = msg;
toast.className = 'toast show ' + (isError ? 'error' : '');
setTimeout(() => { toast.classList.remove('show'); }, 3000);
}
// --- Modal Controls ---
const modal = document.getElementById('cardModal');
const visualCard = document.getElementById('visualCard');
function openCardModal(id, holderName, cardType, cardNum, expiry, style) {
document.getElementById('modalCardId').value = id;
document.getElementById('modalCardHolder').innerText = holderName;
document.getElementById('modalCardType').innerText = cardType;
document.getElementById('modalCardNum').innerText = cardNum;
document.getElementById('modalExpiry').innerText = expiry;
// Dynamically apply the background style based on user's choice
let bgStyle = 'linear-gradient(135deg, #0284c7, #0f172a)'; // default ocean
if (style === 'onyx') bgStyle = 'linear-gradient(135deg, #3f3f46, #18181b)';
if (style === 'ruby') bgStyle = 'linear-gradient(135deg, #9f1239, #4c0519)';
if (style === 'emerald') bgStyle = 'linear-gradient(135deg, #047857, #064e3b)';
if (style === 'gold') bgStyle = 'linear-gradient(135deg, #ca8a04, #713f12)';
visualCard.style.background = bgStyle;
modal.classList.add('active');
}
function closeModal() {
modal.classList.remove('active');
}
// --- AJAX Processing ---
function processCard(statusAction) {
const cardId = document.getElementById('modalCardId').value;
if (statusAction === 'blocked') {
if (!confirm("Are you sure you want to REJECT this card request? The user will not receive this card.")) {
return;
}
}
const formData = new FormData();
formData.append('ajax_action', 'process_card');
formData.append('card_id', cardId);
formData.append('status', statusAction);
fetch('admin-cards.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if(data.success) {
showToast(data.message, statusAction === 'blocked');
// Instantly Update the Table Row UI
const badge = document.getElementById('badge-' + cardId);
const btn = document.getElementById('btn-' + cardId);
badge.innerText = statusAction.toUpperCase();
badge.className = 'badge ' + statusAction;
// Disable the review button
btn.classList.add('disabled');
btn.onclick = null;
// Update Queue Counter
pendingQueueCount--;
const headerCount = document.getElementById('headerQueueCount');
if (pendingQueueCount > 0) {
headerCount.innerText = pendingQueueCount + " PENDING";
} else {
headerCount.style.display = 'none';
}
closeModal();
} else {
showToast(data.message, true);
}
})
.catch(error => {
showToast('Protocol Error: Connection failed.', true);
});
}
</script>
</body>
</html>
b IDATxytVսϓ22 A@IR:hCiZ[v*E:WũZA ^dQeQ @ !jZ'>gsV仿$|?g)&x-E