180 lines
7.5 KiB
PHP
180 lines
7.5 KiB
PHP
|
<?php
|
||
|
session_start();
|
||
|
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true){
|
||
|
header("location: login.php");
|
||
|
exit;
|
||
|
}
|
||
|
require_once "config/database.php";
|
||
|
|
||
|
// Get counts for dashboard
|
||
|
$products_count = mysqli_fetch_array(mysqli_query($conn, "SELECT COUNT(*) FROM products"))[0];
|
||
|
$orders_count = mysqli_fetch_array(mysqli_query($conn, "SELECT COUNT(*) FROM orders"))[0];
|
||
|
$pending_orders = mysqli_fetch_array(mysqli_query($conn, "SELECT COUNT(*) FROM orders WHERE status='pending'"))[0];
|
||
|
?>
|
||
|
|
||
|
<!DOCTYPE html>
|
||
|
<html lang="ar" dir="rtl">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<title>لوحة التحكم - ShubraVeil</title>
|
||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
|
||
|
<link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;700&display=swap" rel="stylesheet">
|
||
|
<style>
|
||
|
body {
|
||
|
font-family: 'Tajawal', sans-serif;
|
||
|
background-color: #f8f9fa;
|
||
|
}
|
||
|
.sidebar {
|
||
|
min-height: 100vh;
|
||
|
background-color: #343a40;
|
||
|
padding-top: 20px;
|
||
|
}
|
||
|
.sidebar a {
|
||
|
color: #fff;
|
||
|
padding: 10px 15px;
|
||
|
display: block;
|
||
|
text-decoration: none;
|
||
|
}
|
||
|
.sidebar a:hover {
|
||
|
background-color: #495057;
|
||
|
}
|
||
|
.main-content {
|
||
|
padding: 20px;
|
||
|
}
|
||
|
.dashboard-card {
|
||
|
background: white;
|
||
|
border-radius: 10px;
|
||
|
padding: 20px;
|
||
|
margin-bottom: 20px;
|
||
|
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||
|
}
|
||
|
.card-icon {
|
||
|
font-size: 2.5rem;
|
||
|
margin-bottom: 15px;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="container-fluid">
|
||
|
<div class="row">
|
||
|
<!-- Sidebar -->
|
||
|
<nav class="col-md-2 d-none d-md-block sidebar">
|
||
|
<div class="text-center mb-4">
|
||
|
<img src="../images/logo.jpg" alt="Logo" style="max-width: 120px;">
|
||
|
</div>
|
||
|
<div class="sidebar-sticky">
|
||
|
<ul class="nav flex-column">
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link active" href="index.php">
|
||
|
<i class="fas fa-home ml-2"></i>
|
||
|
الرئيسية
|
||
|
</a>
|
||
|
</li>
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="products.php">
|
||
|
<i class="fas fa-box ml-2"></i>
|
||
|
المنتجات
|
||
|
</a>
|
||
|
</li>
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="orders.php">
|
||
|
<i class="fas fa-shopping-cart ml-2"></i>
|
||
|
الطلبات
|
||
|
</a>
|
||
|
</li>
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="settings.php">
|
||
|
<i class="fas fa-cog ml-2"></i>
|
||
|
الإعدادات
|
||
|
</a>
|
||
|
</li>
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="logout.php">
|
||
|
<i class="fas fa-sign-out-alt ml-2"></i>
|
||
|
تسجيل الخروج
|
||
|
</a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</nav>
|
||
|
|
||
|
<!-- Main content -->
|
||
|
<main role="main" class="col-md-10 mr-auto ml-auto col-lg-10 px-4 main-content">
|
||
|
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||
|
<h1 class="h2">لوحة التحكم</h1>
|
||
|
</div>
|
||
|
|
||
|
<div class="row">
|
||
|
<div class="col-md-4">
|
||
|
<div class="dashboard-card">
|
||
|
<div class="text-primary card-icon">
|
||
|
<i class="fas fa-box"></i>
|
||
|
</div>
|
||
|
<h3>المنتجات</h3>
|
||
|
<p class="h2"><?php echo $products_count; ?></p>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="col-md-4">
|
||
|
<div class="dashboard-card">
|
||
|
<div class="text-success card-icon">
|
||
|
<i class="fas fa-shopping-cart"></i>
|
||
|
</div>
|
||
|
<h3>إجمالي الطلبات</h3>
|
||
|
<p class="h2"><?php echo $orders_count; ?></p>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="col-md-4">
|
||
|
<div class="dashboard-card">
|
||
|
<div class="text-warning card-icon">
|
||
|
<i class="fas fa-clock"></i>
|
||
|
</div>
|
||
|
<h3>الطلبات المعلقة</h3>
|
||
|
<p class="h2"><?php echo $pending_orders; ?></p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<!-- Recent Orders -->
|
||
|
<div class="dashboard-card mt-4">
|
||
|
<h3>آخر الطلبات</h3>
|
||
|
<div class="table-responsive">
|
||
|
<table class="table table-striped">
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>#</th>
|
||
|
<th>اسم العميل</th>
|
||
|
<th>التاريخ</th>
|
||
|
<th>الحالة</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<?php
|
||
|
$sql = "SELECT * FROM orders ORDER BY created_at DESC LIMIT 5";
|
||
|
$result = mysqli_query($conn, $sql);
|
||
|
while($row = mysqli_fetch_assoc($result)) {
|
||
|
echo "<tr>";
|
||
|
echo "<td>" . $row['id'] . "</td>";
|
||
|
echo "<td>" . $row['customer_name'] . "</td>";
|
||
|
echo "<td>" . $row['created_at'] . "</td>";
|
||
|
echo "<td><span class='badge badge-" .
|
||
|
($row['status'] == 'completed' ? 'success' :
|
||
|
($row['status'] == 'pending' ? 'warning' : 'secondary')) .
|
||
|
"'>" . $row['status'] . "</span></td>";
|
||
|
echo "</tr>";
|
||
|
}
|
||
|
?>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
</div>
|
||
|
</div>
|
||
|
</main>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
||
|
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
|
||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||
|
</body>
|
||
|
</html>
|