����JFIF��`�`�����Viewing File: /home/u820193700/domains/throtllr.in/public_html/admin/index.php
<?php
require_once '../includes/db.php';
require_once '../includes/functions.php';
if(!is_logged_in()) { redirect("login.php"); }

$total_bikes = $pdo->query("SELECT COUNT(*) FROM bikes")->fetchColumn();
$available_bikes = $pdo->query("SELECT COUNT(*) FROM bikes WHERE status = 'available'")->fetchColumn();
$pending_inspections = $pdo->query("SELECT COUNT(*) FROM inspection_bookings WHERE status = 'pending'")->fetchColumn();
$new_sell_requests = $pdo->query("SELECT COUNT(*) FROM sell_requests WHERE status = 'pending'")->fetchColumn();

$recent_activity = [];
$stmt = $pdo->query("SELECT created_at, CONCAT('New Sell Request for ', model_name) as action, name as user, status FROM sell_requests ORDER BY created_at DESC LIMIT 3");
$recent_activity = array_merge($recent_activity, $stmt->fetchAll());
$stmt = $pdo->query("SELECT created_at, CONCAT('Inspection - ', preferred_date) as action, name as user, status FROM inspection_bookings ORDER BY created_at DESC LIMIT 3");
$recent_activity = array_merge($recent_activity, $stmt->fetchAll());

usort($recent_activity, function($a, $b) {
    return strtotime($b['created_at']) - strtotime($a['created_at']);
});
$recent_activity = array_slice($recent_activity, 0, 5);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ReOwn Admin Dashboard</title>
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="admin.css?v=<?php echo time(); ?>">
</head>
<body>

<?php include 'admin_sidebar.php'; ?>

<div id="main-content">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h2>Dashboard Overview</h2>
        <div>
            <span class="text-muted">Welcome, Admin</span>
        </div>
    </div>

    <div class="row g-4 mb-5">
        <div class="col-md-3">
            <div class="stat-card">
                <h3><?php echo htmlspecialchars($total_bikes); ?></h3>
                <p class="text-light mb-0">Total Bikes</p>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card">
                <h3><?php echo htmlspecialchars($available_bikes); ?></h3>
                <p class="text-light mb-0">Available Bikes</p>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card">
                <h3><?php echo htmlspecialchars($pending_inspections); ?></h3>
                <p class="text-light mb-0">Pending Inspections</p>
            </div>
        </div>
        <div class="col-md-3">
            <div class="stat-card">
                <h3><?php echo htmlspecialchars($new_sell_requests); ?></h3>
                <p class="text-light mb-0">New Sell Requests</p>
            </div>
        </div>
    </div>
    
    <div class="row">
        <div class="col-12">
            <h4 class="mb-3">Recent Activity</h4>
            <div class="table-responsive">
                <table class="table table-dark table-hover">
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Action</th>
                            <th>User</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if (count($recent_activity) > 0): ?>
                            <?php foreach($recent_activity as $act): ?>
                            <tr>
                                <td><?php echo date('Y-m-d', strtotime($act['created_at'])); ?></td>
                                <td><?php echo htmlspecialchars($act['action']); ?></td>
                                <td><?php echo htmlspecialchars($act['user']); ?></td>
                                <td>
                                    <?php 
                                    $statusClass = 'bg-secondary';
                                    if(in_array($act['status'], ['approved', 'completed'])) $statusClass = 'bg-success';
                                    if(in_array($act['status'], ['pending'])) $statusClass = 'bg-warning text-dark';
                                    if(in_array($act['status'], ['rejected', 'cancelled'])) $statusClass = 'bg-danger';
                                    ?>
                                    <span class="badge <?php echo $statusClass; ?>"><?php echo ucfirst($act['status']); ?></span>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                        <?php else: ?>
                            <tr><td colspan="4" class="text-center text-muted">No recent activity.</td></tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����