Certainly! Below is the fully refined PHP code for your Kaak Alia Management System Dashboard. The design has been transformed to embody a modern, clean, and professional aesthetic while retaining subtle hints of the bakery theme. Key enhancements include a crisp white background, minimalistic shadows, enhanced spacing, sleek buttons, updated typography, and refined status badges.
Key Changes Implemented:
-
Background and Layout:
- Crisp White Background: Ensures a clean and professional look.
- Minimal Shadows: Provides a sleek floating effect to cards and tables.
- Increased Padding and Spacing: Creates an airy and open layout.
-
Typography:
- Modern Sans-Serif Fonts: Utilized "Inter" for headings and "Roboto" for body text to maintain a clean and professional appearance.
- Hierarchy and Emphasis: Established clear font sizes and weights for better readability.
-
Color Palette:
- Primary Colors: Dominantly white and light grey for a modern feel.
- Accent Colors: Muted blues, greens, and soft reds for status indicators and subtle highlights.
-
Action Buttons:
- Sleek, Rounded Buttons: Enhanced with slight gradients and modern icons.
- Interactive Hover Effects: Subtle shadows and color shifts to indicate interactivity.
-
Tables and Badges:
- Refined Table Headers: Light grey background with bold sans-serif fonts and underlines.
- Alternating Row Colors: Improves readability with alternating white and light grey backgrounds.
- Modern Status Badges: Rounded edges with updated colors to reflect different statuses.
-
Interactive Elements and Transitions:
- Smooth Transitions: Enhanced hover and focus effects for a responsive user experience.
Complete Refined PHP Code:
<?php
// public/dashboard.php
// Enable error reporting for debugging (disable in production)
ini_set('display_errors', 0); // Set to 0 in production
ini_set('display_startup_errors', 0); // Set to 0 in production
error_reporting(E_ALL);
// Start output buffering to prevent "headers already sent" errors
ob_start();
// Include authentication and database connection first
require_once '../includes/auth.php';
require_once '../includes/db_connect.php';
// Now include the header
require_once '../includes/header.php';
/**
* Fetch Quick Stats
*/
// Total Orders
$totalOrdersSql = "SELECT COUNT(*) AS total FROM orders";
$totalOrdersResult = $conn->query($totalOrdersSql);
$totalOrders = ($totalOrdersResult && $row = $totalOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Pending Orders
$pendingOrdersSql = "SELECT COUNT(*) AS total FROM orders WHERE status = 'Pending'";
$pendingOrdersResult = $conn->query($pendingOrdersSql);
$pendingOrders = ($pendingOrdersResult && $row = $pendingOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Completed Orders
$completedOrdersSql = "SELECT COUNT(*) AS total FROM orders WHERE status = 'Completed'";
$completedOrdersResult = $conn->query($completedOrdersSql);
$completedOrders = ($completedOrdersResult && $row = $completedOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Delivered Orders
$deliveredOrdersSql = "SELECT COUNT(*) AS total FROM orders WHERE status = 'Delivered'";
$deliveredOrdersResult = $conn->query($deliveredOrdersSql);
$deliveredOrders = ($deliveredOrdersResult && $row = $deliveredOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Total Sales from Completed and Delivered Orders considering discounts
$totalSalesSql = "
SELECT
SUM(p.price * oi.quantity * (1 - (oi.discount_percentage / 100))) AS total_sales
FROM
order_items oi
JOIN
products p ON oi.product_id = p.id
JOIN
orders o ON oi.order_id = o.id
WHERE
o.status IN ('Completed', 'Delivered')
";
$totalSalesResult = $conn->query($totalSalesSql);
$totalSales = ($totalSalesResult && $row = $totalSalesResult->fetch_assoc()) ? (float)$row['total_sales'] : 0.00;
/**
* Fetch Recent Orders
*/
// Fetch the 5 most recent orders
$recentOrdersSql = "
SELECT
o.id AS order_id,
c.name AS customer_name,
c.contact,
c.delivery_address,
o.status,
o.order_date,
o.delivery_datetime,
GROUP_CONCAT(
CONCAT(
p.name, ' - ', p.size, ' (', FORMAT(p.price, 2), ' KD) <br>',
'Qty: ', oi.quantity, '<br>',
'Packaging: ', IFNULL(oi.packaging_preferences, 'None'), '<br>',
'Discount: ', oi.discount_percentage, '%<br>',
'Reason: ', IFNULL(oi.discount_reason, 'N/A')
) SEPARATOR '<hr>'
) AS products_details
FROM
orders o
JOIN
customers c ON o.customer_id = c.id
JOIN
order_items oi ON o.id = oi.order_id
JOIN
products p ON oi.product_id = p.id
GROUP BY
o.id
ORDER BY
o.order_date DESC
LIMIT 5
";
$recentOrdersResult = $conn->query($recentOrdersSql);
$recentOrders = ($recentOrdersResult && $recentOrdersResult->num_rows > 0) ? $recentOrdersResult : false;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashboard - Kaak Alia Management System</title>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
<!-- Custom Styles -->
<style>
/* ---------------------------------------------------
1. CSS Variables for Consistent Design
---------------------------------------------------- */
:root {
/* Primary Colors */
--background-color: #FFFFFF; /* Crisp White */
--light-grey: #F5F5F5;
--medium-grey: #CCCCCC;
--dark-grey: #333333;
--charcoal: #4A4A4A;
/* Accent Colors */
--accent-blue: #4A90E2;
--accent-green: #50C878;
--accent-red: #FF6B6B;
--accent-teal: #20B2AA;
--accent-soft-blue: #A3D2CA;
/* Text Colors */
--primary-text: var(--dark-grey);
--secondary-text: #666666;
/* UI Elements */
--input-border: var(--medium-grey);
--input-focus-border: var(--accent-blue);
--box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
--box-border-radius: 12px;
--hover-shadow: rgba(0, 0, 0, 0.1);
/* Button Colors */
--button-add-order: #6C63FF;
--button-view-orders: #FFA500;
--button-manage-products: #20B2AA;
--button-manage-users: #4B0082;
--button-generate-reports: #FF6B6B;
/* Status Badge Colors */
--badge-pending: #FFD166;
--badge-in-progress: #6A4C93;
--badge-completed: #4CAF50;
--badge-delivered: #20B2AA;
}
/* ---------------------------------------------------
2. Global Styles
---------------------------------------------------- */
body {
font-family: 'Roboto', sans-serif;
background-color: var(--light-grey);
margin: 0;
padding: 0;
color: var(--primary-text);
}
.container-body {
max-width: 1200px;
margin: 0 auto;
padding: 40px 20px;
box-sizing: border-box;
background-color: var(--background-color);
box-shadow: var(--box-shadow);
border-radius: var(--box-border-radius);
font-family: 'Roboto', sans-serif;
}
/* ---------------------------------------------------
3. Header Styles
---------------------------------------------------- */
.header {
padding: 20px 30px;
background-color: var(--background-color);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 30px;
}
.header h1 {
color: var(--charcoal);
font-size: 28px;
font-weight: 700;
font-family: 'Inter', sans-serif;
}
/* ---------------------------------------------------
4. Welcome Section
---------------------------------------------------- */
.welcome-section {
background-color: var(--background-color);
box-shadow: var(--box-shadow);
border-radius: var(--box-border-radius);
padding: 30px;
text-align: center;
margin-bottom: 30px;
font-family: 'Inter', sans-serif;
}
.welcome-section h3 {
font-size: 22px;
color: var(--primary-text);
margin-bottom: 10px;
font-weight: 600;
}
.welcome-section hr {
width: 60px;
height: 4px;
background: linear-gradient(90deg, var(--accent-teal), var(--accent-soft-blue));
border: none;
margin: 10px auto;
border-radius: 2px;
}
/* ---------------------------------------------------
5. Statistics Section
---------------------------------------------------- */
.stats-section {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 25px;
margin-bottom: 30px;
}
.stat-card {
background-color: var(--background-color);
box-shadow: var(--box-shadow);
border-radius: var(--box-border-radius);
padding: 20px;
display: flex;
align-items: center;
transition: transform 0.3s, box-shadow 0.3s;
cursor: default;
}
.stat-card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.stat-icon {
font-size: 36px;
margin-right: 20px;
color: var(--accent-blue);
}
.stat-info h5 {
font-size: 18px;
color: var(--primary-text);
margin-bottom: 8px;
font-family: 'Inter', sans-serif;
font-weight: 600;
}
.stat-info p {
font-size: 26px;
font-weight: 700;
color: var(--charcoal);
margin: 0;
}
/* ---------------------------------------------------
6. Main Buttons Section
---------------------------------------------------- */
.buttons-section {
display: flex;
flex-wrap: wrap;
gap: 25px;
margin-bottom: 30px;
}
.action-button {
display: flex;
align-items: center;
justify-content: center;
flex: 1 1 200px;
height: 60px;
font-size: 16px;
font-weight: 600;
color: #FFFFFF;
border: none;
border-radius: 30px;
padding: 0 20px;
cursor: pointer;
transition: background-color 0.3s, box-shadow 0.3s;
text-decoration: none;
text-align: center;
font-family: 'Inter', sans-serif;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.action-button.add-order {
background: linear-gradient(135deg, #6C63FF, #8A65FF);
}
.action-button.view-orders {
background: linear-gradient(135deg, #FFA500, #FFB733);
}
.action-button.manage-products {
background: linear-gradient(135deg, #20B2AA, #38C9B0);
}
.action-button.manage-users {
background: linear-gradient(135deg, #4B0082, #6A1B9A);
}
.action-button.generate-reports {
background: linear-gradient(135deg, #FF6B6B, #FF8787);
}
.action-button:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.action-button i {
margin-right: 10px;
font-size: 20px;
}
/* ---------------------------------------------------
7. Recent Orders Section
---------------------------------------------------- */
.recent-orders-section {
background-color: var(--background-color);
border-radius: var(--box-border-radius);
padding: 30px;
box-shadow: var(--box-shadow);
}
.recent-orders-section h4 {
font-size: 24px;
font-weight: 700;
color: var(--charcoal);
margin-bottom: 20px;
font-family: 'Inter', sans-serif;
}
/* Make table responsive */
.table-responsive {
overflow-x: auto;
}
.recent-orders-section table {
width: 100%;
border-collapse: collapse;
font-family: 'Roboto', sans-serif;
}
.recent-orders-section th,
.recent-orders-section td {
padding: 14px 16px;
text-align: left;
font-size: 14px;
vertical-align: top;
}
.recent-orders-section th {
background-color: var(--light-grey);
color: var(--charcoal);
font-weight: 700;
border-bottom: 2px solid var(--medium-grey);
font-family: 'Inter', sans-serif;
}
.recent-orders-section tr:nth-child(even) {
background-color: #FAFAFA;
}
.recent-orders-section tr:hover {
background-color: #F1F1F1;
}
.recent-orders-section td {
color: var(--secondary-text);
}
.recent-orders-section .view-all {
display: block;
text-align: right;
margin-top: 15px;
font-size: 16px;
color: var(--accent-blue);
font-weight: 600;
text-decoration: none;
font-family: 'Inter', sans-serif;
transition: color 0.3s;
}
.recent-orders-section .view-all:hover {
color: var(--accent-teal);
}
/* Badge Styles */
.badge-status-pending {
background-color: var(--badge-pending);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
}
.badge-status-in-progress {
background-color: var(--badge-in-progress);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
}
.badge-status-completed {
background-color: var(--badge-completed);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
}
.badge-status-delivered {
background-color: var(--badge-delivered);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
}
/* ---------------------------------------------------
8. Footer Styles
---------------------------------------------------- */
.footer {
background-color: var(--background-color);
color: var(--secondary-text);
padding: 20px;
text-align: center;
border-radius: var(--box-border-radius);
font-size: 14px;
line-height: 22px;
margin-top: 40px;
font-family: 'Roboto', sans-serif;
box-shadow: var(--box-shadow);
}
/* ---------------------------------------------------
9. Responsive Design Enhancements
---------------------------------------------------- */
@media (max-width: 768px) {
.header h1 {
font-size: 24px;
}
.welcome-section h3 {
font-size: 20px;
}
.stats-section {
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 20px;
}
.stat-icon {
font-size: 30px;
}
.stat-info p {
font-size: 22px;
}
.action-button {
flex: 1 1 100%;
height: 50px;
font-size: 14px;
}
.recent-orders-section h4 {
font-size: 20px;
}
.recent-orders-section th,
.recent-orders-section td {
padding: 10px 12px;
font-size: 12px;
}
}
@media (max-width: 480px) {
.container-body {
padding: 20px 10px;
}
.header h1 {
font-size: 20px;
}
.welcome-section h3 {
font-size: 18px;
}
.stat-info p {
font-size: 20px;
}
.action-button {
height: 45px;
font-size: 13px;
}
.recent-orders-section h4 {
font-size: 18px;
}
.recent-orders-section th,
.recent-orders-section td {
padding: 8px 10px;
font-size: 11px;
}
}
</style>
</head>
<body>
<main class='container-body'>
<!-- Header -->
<div class="header">
<h1>Kaak Alia Dashboard</h1>
</div>
<!-- Welcome Section -->
<div class="welcome-section">
<h3>Welcome to the Kaak Alia Management System!</h3>
<hr>
</div>
<!-- Statistics Section -->
<div class="stats-section">
<!-- Total Orders -->
<div class="stat-card">
<div class="stat-icon">
<i class="bi bi-cart-fill"></i>
</div>
<div class="stat-info">
<h5>Total Orders</h5>
<p><?= number_format($totalOrders) ?></p>
</div>
</div>
<!-- Pending Orders -->
<div class="stat-card">
<div class="stat-icon">
<i class="bi bi-hourglass-split"></i>
</div>
<div class="stat-info">
<h5>Pending Orders</h5>
<p><?= number_format($pendingOrders) ?></p>
</div>
</div>
<!-- Completed Orders -->
<div class="stat-card">
<div class="stat-icon">
<i class="bi bi-check-circle-fill"></i>
</div>
<div class="stat-info">
<h5>Completed Orders</h5>
<p><?= number_format($completedOrders) ?></p>
</div>
</div>
<!-- Delivered Orders -->
<div class="stat-card">
<div class="stat-icon">
<i class="bi bi-truck"></i>
</div>
<div class="stat-info">
<h5>Delivered Orders</h5>
<p><?= number_format($deliveredOrders) ?></p>
</div>
</div>
<!-- Total Sales -->
<div class="stat-card">
<div class="stat-icon">
<i class="bi bi-currency-dollar"></i>
</div>
<div class="stat-info">
<h5>Total Sales (KD)</h5>
<p><?= number_format($totalSales, 2) ?></p>
</div>
</div>
</div>
<!-- Main Buttons Section -->
<div class="buttons-section">
<a href="orders/add_order.php" class="action-button add-order">
<i class="bi bi-plus-circle-fill"></i>
Add New Order
</a>
<a href="orders/view_orders.php" class="action-button view-orders">
<i class="bi bi-eye-fill"></i>
View Orders
</a>
<a href="products/manage_products.php" class="action-button manage-products">
<i class="bi bi-box-seam-fill"></i>
Manage Products
</a>
<a href="users/manage_users.php" class="action-button manage-users">
<i class="bi bi-people-fill"></i>
Manage Users
</a>
<a href="reports/generate_reports.php" class="action-button generate-reports">
<i class="bi bi-bar-chart-fill"></i>
Generate Reports
</a>
</div>
<!-- Recent Orders Section -->
<div class="recent-orders-section">
<h4>Recent Orders</h4>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>#ID</th>
<th>Customer Name</th>
<th>Contact</th>
<th>Delivery Address</th>
<th>Products</th>
<th>Status</th>
<th>Order Date</th>
<th>Delivery DateTime</th>
</tr>
</thead>
<tbody>
<?php if ($recentOrders && $recentOrders->num_rows > 0): ?>
<?php while($order = $recentOrders->fetch_assoc()): ?>
<tr>
<td><?= htmlspecialchars($order['order_id']) ?></td>
<td><?= htmlspecialchars($order['customer_name']) ?></td>
<td><?= htmlspecialchars($order['contact']) ?></td>
<td><?= nl2br(htmlspecialchars($order['delivery_address'])) ?></td>
<td>
<?php
// Display all products associated with the order
echo $order['products_details'];
?>
</td>
<td>
<?php
switch ($order['status']) {
case 'Pending':
echo '<span class="badge-status-pending">Pending</span>';
break;
case 'In Progress':
echo '<span class="badge-status-in-progress">In Progress</span>';
break;
case 'Completed':
echo '<span class="badge-status-completed">Completed</span>';
break;
case 'Delivered':
echo '<span class="badge-status-delivered">Delivered</span>';
break;
default:
echo '<span class="badge bg-light text-dark">Unknown</span>';
}
?>
</td>
<td><?= htmlspecialchars(date("d M Y, h:i A", strtotime($order['order_date']))) ?></td>
<td><?= $order['delivery_datetime'] ? htmlspecialchars(date("d M Y, h:i A", strtotime($order['delivery_datetime']))) : 'N/A' ?></td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr>
<td colspan="8" class="text-center">No recent orders.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<a href="orders/view_orders.php" class="view-all">View All Orders</a>
</div>
<!-- Footer -->
<div class="footer">
© 2024 Kaak Alia Bakery. All rights reserved.
</div>
</main>
<!-- Embedded Bootstrap JS -->
<script src="bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php
// Flush the output buffer
ob_end_flush();
// No closing PHP tag to prevent unwanted output
?>
Detailed Enhancements Breakdown:
-
CSS Variables:
- Defined a comprehensive set of CSS variables for colors, ensuring consistency across the design.
- Chose modern and muted accent colors to maintain a professional tone while subtly hinting at the bakery theme.
-
Typography:
- Fonts: Integrated "Inter" for headings to establish a strong hierarchy and "Roboto" for body text to ensure readability.
- Font Weights and Sizes: Adjusted to create clear differentiation between various text elements.
-
Buttons:
- Design: Adopted rounded-pill shapes with linear gradients for a modern and sleek appearance.
- Icons: Incorporated Bootstrap Icons for visual clarity and enhanced user experience.
- Interactivity: Implemented hover effects with intensified shadows to signify interactivity.
-
Statistics Cards:
- Layout: Enhanced padding and spacing for an airy feel.
- Icons and Colors: Updated icon sizes and colors to align with the new color palette.
-
Recent Orders Table:
- Headers: Applied a light grey background with bold fonts and underlines for a minimalist and organized look.
- Rows: Implemented alternating row colors to improve readability.
- Badges: Redesigned status badges with rounded edges and updated colors to reflect different order statuses effectively.
-
Responsive Design:
- Ensured the dashboard is fully responsive across various devices, adjusting paddings, font sizes, and layouts to maintain aesthetics and functionality on smaller screens.
-
Overall Aesthetic:
- Minimalistic Shadows: Provided depth without overwhelming the design.
- Whitespace Utilization: Leveraged ample whitespace to reduce visual clutter and highlight key components.
- Color Harmony: Maintained a balanced color palette that is both modern and warm, suitable for an upscale bakery platform.
Additional Recommendations:
-
Consistency in Icons:
- Ensure all action buttons have corresponding intuitive icons for better user navigation.
-
Accessibility:
- Implement ARIA labels and ensure color contrast ratios meet accessibility standards for better usability.
-
Performance Optimization:
- Consider minifying CSS and JavaScript files for faster load times.
-
Scalability:
- For larger projects, segregate CSS into separate files and consider using CSS preprocessors like SASS for better manageability.
-
Interactive Elements:
- Enhance user experience by adding modal dialogs or notifications for actions like adding orders, completing tasks, etc.
By implementing the above refinements, your Kaak Alia Management System Dashboard will present an inviting, professional, and user-friendly interface that aligns perfectly with the modern aesthetic and upscale nature of your online bakery platform.