| Server IP : 3.111.61.48 / Your IP : 216.73.216.67 Web Server : Apache System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.2.31 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/vhost/book.gyaniguru.org/admin/ |
Upload File : |
<?php
include 'includes/header.php';
// Fetch stats
$total_books = get_row("SELECT COUNT(*) as count FROM books")['count'];
$total_photos = get_row("SELECT COUNT(*) as count FROM photos")['count'];
$total_users = get_row("SELECT COUNT(*) as count FROM users")['count'];
$total_orders = get_row("SELECT COUNT(*) as count FROM orders")['count'];
$total_revenue = get_row("SELECT SUM(total_amount) as total FROM orders WHERE status != 'Cancelled'")['total'] ?? 0;
// Fetch chart data (Last 7 days revenue)
$chart_data = [];
$chart_labels = [];
for ($i = 6; $i >= 0; $i--) {
$date = date('Y-m-d', strtotime("-$i days"));
$display_date = date('d M', strtotime("-$i days"));
$revenue = get_row("SELECT SUM(total_amount) as total FROM orders WHERE DATE(order_date) = ? AND status != 'Cancelled'", [$date])['total'] ?? 0;
$chart_data[] = $revenue;
$chart_labels[] = $display_date;
}
// Recent orders
$recent_orders = get_all("SELECT o.*, u.name as user_name
FROM orders o
JOIN users u ON o.user_id = u.id
ORDER BY o.order_date DESC LIMIT 5");
?>
<div class="row g-4 mb-5">
<div class="col-md">
<div class="stat-card shadow-sm h-100">
<div class="stat-icon" style="background: var(--gradient-divine);"><i class="bi bi-journal-bookmark text-white"></i></div>
<div class="stat-info">
<h3><?php echo $total_books; ?></h3>
<p>Digital Library</p>
</div>
</div>
</div>
<div class="col-md">
<div class="stat-card shadow-sm h-100">
<div class="stat-icon" style="background: linear-gradient(135deg,#6366f1,#4338ca);"><i class="bi bi-camera-fill text-white"></i></div>
<div class="stat-info">
<h3><?php echo $total_photos; ?></h3>
<p>Guru Photos</p>
</div>
</div>
</div>
<div class="col-md">
<div class="stat-card shadow-sm h-100">
<div class="stat-icon" style="background: var(--gradient-saffron);"><i class="bi bi-people-fill text-white"></i></div>
<div class="stat-info">
<h3><?php echo $total_users; ?></h3>
<p>Divine Seekers</p>
</div>
</div>
</div>
<div class="col-md">
<div class="stat-card shadow-sm h-100">
<div class="stat-icon" style="background: #27ae60;"><i class="bi bi-cart-check-fill text-white"></i></div>
<div class="stat-info">
<h3><?php echo $total_orders; ?></h3>
<p>Sacred Orders</p>
</div>
</div>
</div>
<div class="col-md">
<div class="stat-card shadow-sm h-100">
<div class="stat-icon" style="background: var(--maroon);"><i class="bi bi-currency-rupee text-white"></i></div>
<div class="stat-info">
<h3>₹<?php echo number_format($total_revenue, 0); ?></h3>
<p>Total Blessings</p>
</div>
</div>
</div>
</div>
<div class="row g-4">
<div class="col-lg-8">
<!-- Sales Chart Card -->
<div class="admin-card mb-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h5 class="m-0">Revenue Analytics</h5>
<div class="badge bg-gold text-dark px-3 py-2">Last 7 Days</div>
</div>
<div style="height: 300px; position: relative;">
<canvas id="salesChart"></canvas>
</div>
</div>
<div class="admin-card">
<div class="d-flex justify-content-between align-items-center mb-4">
<h5 class="m-0">Recent Sacred Transactions</h5>
<a href="orders.php" class="btn btn-sm btn-outline-gold px-3">View All</a>
</div>
<div class="table-responsive">
<table class="table table-custom mb-0">
<thead>
<tr>
<th>Order ID</th>
<th>Seeker Name</th>
<th>Amount</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach($recent_orders as $order): ?>
<tr>
<td class="fw-bold" style="color: var(--maroon);">#ORD-<?php echo $order['id']; ?></td>
<td><?php echo $order['user_name']; ?></td>
<td class="fw-bold">₹<?php echo number_format($order['total_amount'], 0); ?></td>
<td>
<span class="status-badge status-<?php echo strtolower($order['status']); ?>">
<?php echo $order['status']; ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="admin-card h-100 shadow-sm">
<h5 class="mb-4">Sacred Controls</h5>
<div class="d-grid gap-3">
<a href="book-add.php" class="btn btn-saffron text-start py-3 px-4 shadow-sm">
<i class="bi bi-plus-circle-fill me-3"></i> Add New Book
</a>
<a href="photos.php" class="btn btn-outline-gold text-start py-3 px-4">
<i class="bi bi-camera-fill me-3"></i> Manage Guru Photos
</a>
<a href="categories.php" class="btn btn-outline-gold text-start py-3 px-4">
<i class="bi bi-grid-3x3-gap-fill me-3"></i> Manage Categories
</a>
<a href="users.php" class="btn btn-outline-gold text-start py-3 px-4">
<i class="bi bi-person-lines-fill me-3"></i> User Directory
</a>
<div class="mt-4 p-4 rounded-4" style="background: var(--warm-white); border: 2px dashed var(--cream-dark)">
<h6 class="font-cinzel text-maroon mb-3">System Vitals</h6>
<div class="d-flex justify-content-between mb-2 small">
<span class="text-muted">Database</span>
<span class="text-success fw-bold">Active <i class="bi bi-circle-fill ms-1" style="font-size: 0.5rem"></i></span>
</div>
<div class="d-flex justify-content-between mb-2 small">
<span class="text-muted">Storage</span>
<span class="text-dark">84% Used</span>
</div>
<div class="d-flex justify-content-between small">
<span class="text-muted">PHP Version</span>
<span class="text-dark">8.2.12</span>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
const ctx = document.getElementById('salesChart').getContext('2d');
// Create Gradient
const gradient = ctx.createLinearGradient(0, 0, 0, 400);
gradient.addColorStop(0, 'rgba(128, 0, 32, 0.2)');
gradient.addColorStop(1, 'rgba(128, 0, 32, 0)');
new Chart(ctx, {
type: 'line',
data: {
labels: <?php echo json_encode($chart_labels); ?>,
datasets: [{
label: 'Daily Revenue',
data: <?php echo json_encode($chart_data); ?>,
borderColor: '#800020', // Maroon
backgroundColor: gradient,
borderWidth: 3,
fill: true,
tension: 0.4,
pointBackgroundColor: '#D4AF37', // Gold
pointBorderColor: '#fff',
pointHoverRadius: 6
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false }
},
scales: {
y: {
beginAtZero: true,
grid: { color: 'rgba(0,0,0,0.05)' },
ticks: { color: '#666', font: { size: 10 } }
},
x: {
grid: { display: false },
ticks: { color: '#666', font: { size: 10 } }
}
}
}
});
</script>
<?php include 'includes/footer.php'; ?>