i want to change the classes names to different names… · The Chat Archive
Explore / Programming i want to change the classes names to different names (<?php // public/dashboard.php //… Save Share Download ▾ Reporti want to change the classes names to different names (<?php
// public/dashboard.php
// Now include the header
require_once '../includes/header.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
// Assuming header.php contains necessary meta tags and opening tag
// For this standalone example, we'll omit it
// require_once '../includes/header.php';
/**
// Total Orders
t o t a l O r d e r s S q l = " S E L E C T C O U N T ( ∗ ) A S t o t a l F R O M o r d e r s " ; totalOrdersSql = "SELECT COUNT(*) AS total FROM orders";
t o t a l O r d er s S totalOrdersResult = totalOrdersSql);
totalOrdersResult && totalOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
Assistant2024-11-12 08:59 UTC Copy response
Copy first prompt
Details
Provider OpenAI
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language en
Conversation date Nov 12, 2024
Added to archive Nov 16, 2026
ID 01m7h427xw35mp5xxa20zkxpvaSource & license Imported from WildChat-4.8M (AI2) (source ). Imported records earn no Research Points.
Upstream record: 4361b0b02b09ac44cca540ab7306c8e4
Zhao et al., WildChat: 1M ChatGPT Interaction Logs in the Wild (ICLR 2024). Contains information from WildChat-4.8M, made available under the ODC Attribution License.
License: ODC-BY-1.0
q
l
=
" S E L E C T C O U N T ( ∗ ) A S t o t a l F R O M or d er s " ;
c o n n − > q u e r y ( conn->query( co nn − > q u er y ( t o t a l O r d e r s = ( totalOrders = ( t o t a l O r d er s = ( // Pending Orders
p e n d i n g O r d e r s S q l = " S E L E C T C O U N T ( ∗ ) A S t o t a l F R O M o r d e r s W H E R E s t a t u s = ′ P e n d i n g ′ " ; pendingOrdersSql = "SELECT COUNT(*) AS total FROM orders WHERE status = 'Pending'";
p e n d in g O r d er s S q l = " S E L E C T C O U N T ( ∗ ) A S t o t a l F R O M or d er s W H E R E s t a t u s = ′ P e n d in g ′ " ; pendingOrdersResult = c o n n − > q u e r y ( conn->query( co nn − > q u er y ( pendingOrdersSql);
p e n d i n g O r d e r s = ( pendingOrders = ( p e n d in g O r d er s = ( pendingOrdersResult && r o w = row = r o w = pendingOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Completed Orders
c o m p l e t e d O r d e r s S q l = " S E L E C T C O U N T ( ∗ ) A S t o t a l F R O M o r d e r s W H E R E s t a t u s = ′ C o m p l e t e d ′ " ; completedOrdersSql = "SELECT COUNT(*) AS total FROM orders WHERE status = 'Completed'";
co m pl e t e d O r d er s S q l = " S E L E C T C O U N T ( ∗ ) A S t o t a l F R O M or d er s W H E R E s t a t u s = ′ C o m pl e t e d ′ " ; completedOrdersResult = c o n n − > q u e r y ( conn->query( co nn − > q u er y ( completedOrdersSql);
c o m p l e t e d O r d e r s = ( completedOrders = ( co m pl e t e d O r d er s = ( completedOrdersResult && r o w = row = r o w = completedOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Delivered Orders
d e l i v e r e d O r d e r s S q l = " S E L E C T C O U N T ( ∗ ) A S t o t a l F R O M o r d e r s W H E R E s t a t u s = ′ D e l i v e r e d ′ " ; deliveredOrdersSql = "SELECT COUNT(*) AS total FROM orders WHERE status = 'Delivered'";
d e l i v er e d O r d er s S q l = " S E L E C T C O U N T ( ∗ ) A S t o t a l F R O M or d er s W H E R E s t a t u s = ′ D e l i v er e d ′ " ; deliveredOrdersResult = c o n n − > q u e r y ( conn->query( co nn − > q u er y ( deliveredOrdersSql);
d e l i v e r e d O r d e r s = ( deliveredOrders = ( d e l i v er e d O r d er s = ( deliveredOrdersResult && r o w = row = r o w = deliveredOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Total Sales from Completed and Delivered Orders considering discounts
t o t a l S a l e s S q l = " S E L E C T S U M ( p . p r i c e ∗ o i . q u a n t i t y ∗ ( 1 − ( o i . d i s c o u n t p e r c e n t a g e / 100 ) ) ) A S t o t a l s a l e s F R O M o r d e r i t e m s o i J O I N p r o d u c t s p O N o i . p r o d u c t i d = p . i d J O I N o r d e r s o O N o i . o r d e r i d = o . i d W H E R E o . s t a t u s I N ( ′ C o m p l e t e d ′ , ′ D e l i v e r e d ′ ) " ; 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')
";
t o t a l S a l es S q l = " S E L E C T S U M ( p . p r i ce ∗ o i . q u an t i t y ∗ ( totalSalesResult = c o n n − > q u e r y ( conn->query( co nn − > q u er y ( totalSalesSql);
t o t a l S a l e s = ( totalSales = ( t o t a l S a l es = ( totalSalesResult && r o w = row = r o w = totalSalesResult->fetch_assoc()) ? (float)$row['total_sales'] : 0.00;
// Fetch the 5 most recent orders with associated products
$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,
p.name AS product_name
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
ORDER BY
o.order_date DESC
LIMIT 5
";
r e c e n t O r d e r s R e s u l t = recentOrdersResult = r ece n tO r d er s R es u l t = conn->query(r e c e n t O r d e r s S q l ) ; recentOrdersSql);
r ece n tO r d er s S q l ) ; recentOrders = [];
if (recentOrdersResult && recentOrdersResult->num_rows > 0) {
while(r o w = row = r o w = recentOrdersResult->fetch_assoc()) {
o r d e r i d = order_id = or d e r i d = row['order_id'];
if (!isset(r e c e n t O r d e r s [ recentOrders[ r ece n tO r d er s [ order_id])) {
r e c e n t O r d e r s [ recentOrders[ r ece n tO r d er s [ order_id] = [
'order_id' => r o w [ ′ o r d e r i d ′ ] , ′ c u s t o m e r n a m e ′ = > row['order_id'],
'customer_name' => r o w [ ′ or d e r i d row['customer_name'],
'contact' => r o w [ ′ c o n t a c t ′ ] , ′ d e l i v e r y a d d r e s s ′ = > row['contact'],
'delivery_address' => r o w [ ′ co n t a c t ′ ] , row['delivery_address'],
'status' => r o w [ ′ s t a t u s ′ ] , ′ o r d e r d a t e ′ = > row['status'],
'order_date' => r o w [ ′ s t a t u s ′ ] , row['order_date'],
'delivery_datetime' => row['delivery_datetime'],
'products' => []
];
}
recentOrders[o r d e r i d ] [ ′ p r o d u c t s ′ ] [ ] = order_id]['products'][] = or d e r i d ] [ ′ p r o d u c t s row['product_name'];
}
// Convert associative array to indexed array
r e c e n t O r d e r s = a r r a y v a l u e s ( recentOrders = array_values( r ece n tO r d er s = a r r a y v a l u es ( recentOrders);
} else {
$recentOrders = false;
}
<!-- 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 href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- 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 with New Prefix
---------------------------------------------------- */
:root {
/* Primary Colors */
--kaa-background: #F9FAFB; /* Light Neutral Background */
--kaa-white: #FFFFFF; /* Crisp White */
--kaa-light-grey: #E5E7EB; /* Light Grey */
--kaa-medium-grey: #D1D5DB; /* Medium Grey */
--kaa-dark-grey: #374151; /* Dark Grey */
--kaa-charcoal: #1F2937; /* Charcoal */
/* Accent Colors */
--kaa-accent-color: #D1C287; /* Accent Line Color */
--kaa-accent-blue: #4A90E2;
--kaa-accent-green: #50C878;
--kaa-accent-red: #FF6B6B;
--kaa-accent-teal: #20B2AA;
--kaa-accent-soft-blue: #A3D2CA;
--kaa-accent-purple: #8A65FF;
--kaa-accent-orange: #FFA500;
/* Text Colors */
--kaa-primary-text: var(--kaa-charcoal);
--kaa-secondary-text: #6B7280;
/* UI Elements */
--kaa-box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
--kaa-border-radius: 12px;
/* Button Colors */
--kaa-button-add-order: #6C63FF;
--kaa-button-view-orders: #FFA500;
--kaa-button-manage-products: #20B2AA;
--kaa-button-manage-users: #4B0082;
--kaa-button-generate-reports: #FF6B6B;
--kaa-button-workspace-team: #4F46E5; /* Indigo */
/* Status Badge Colors */
--kaa-badge-pending: #FFD166;
--kaa-badge-in-progress: #6A4C93;
--kaa-badge-completed: #4CAF50;
--kaa-badge-delivered: #20B2AA;
/* Line Color Between Products */
--kaa-product-line-color: #E5E7EB;
}
/* ---------------------------------------------------
2. Global Styles
---------------------------------------------------- */
body {
font-family: 'Roboto', sans-serif;
background-color: var(--kaa-background);
margin: 0;
padding: 0;
color: var(--kaa-primary-text);
}
.kaa-container-body {
max-width: 1200px;
margin: 40px auto;
padding: 40px 20px;
box-sizing: border-box;
background-color: var(--kaa-white);
box-shadow: var(--kaa-box-shadow);
border-radius: var(--kaa-border-radius);
transition: all 0.3s ease;
}
/* ---------------------------------------------------
3. Header Styles
---------------------------------------------------- */
.kaa-header {
padding: 20px 30px;
background-color: var(--kaa-white);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 30px;
border-bottom: 1px solid var(--kaa-light-grey);
}
.kaa-header h1 {
color: var(--kaa-charcoal);
font-size: 36px;
font-weight: 700;
font-family: 'Inter', sans-serif;
position: relative;
}
/* Decorative Line Under Header */
.kaa-header h1::after {
content: "";
display: block;
width: 120px;
height: 4px;
background: var(--kaa-accent-color);
margin: 12px auto 0;
border-radius: 2px;
}
/* ---------------------------------------------------
4. Welcome Section
---------------------------------------------------- */
.kaa-welcome-section {
background-color: var(--kaa-white);
box-shadow: var(--kaa-box-shadow);
border-radius: var(--kaa-border-radius);
padding: 30px;
text-align: center;
margin-bottom: 30px;
font-family: 'Inter', sans-serif;
}
.kaa-welcome-section h3 {
font-size: 24px;
color: var(--kaa-primary-text);
margin-bottom: 10px;
font-weight: 600;
}
.kaa-welcome-section p {
font-size: 16px;
color: var(--kaa-secondary-text);
margin: 0;
}
/* ---------------------------------------------------
5. Statistics Section
---------------------------------------------------- */
.kaa-stats-section {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 25px;
margin-bottom: 30px;
}
.kaa-stat-card {
background-color: var(--kaa-white);
box-shadow: var(--kaa-box-shadow);
border-radius: var(--kaa-border-radius);
padding: 20px;
display: flex;
align-items: center;
transition: transform 0.3s, box-shadow 0.3s;
cursor: default;
position: relative;
}
.kaa-stat-card:hover {
transform: translateY(-5px);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
.kaa-stat-icon {
width: 60px;
height: 60px;
background-color: var(--kaa-accent-soft-blue);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
/* Different colors for each stat icon */
.kaa-stat-icon.orders { background-color: var(--kaa-accent-blue); } /* Blue */
.kaa-stat-icon.pending { background-color: var(--kaa-badge-pending); } /* Yellow */
.kaa-stat-icon.completed { background-color: var(--kaa-badge-completed); } /* Green */
.kaa-stat-icon.delivered { background-color: var(--kaa-badge-delivered); } /* Teal */
.kaa-stat-icon.sales { background-color: var(--kaa-accent-red); } /* Red */
.kaa-stat-icon i {
color: #FFFFFF;
font-size: 24px;
}
.kaa-stat-info h5 {
font-size: 18px;
color: var(--kaa-primary-text);
margin-bottom: 5px;
font-family: 'Inter', sans-serif;
font-weight: 600;
}
.kaa-stat-info p {
font-size: 28px;
font-weight: 700;
color: var(--kaa-charcoal);
margin: 0;
}
/* ---------------------------------------------------
6. Main Buttons Section
---------------------------------------------------- */
.kaa-buttons-section {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-bottom: 30px;
}
.kaa-action-button {
display: flex;
align-items: center;
justify-content: center;
flex: 1 1 220px;
height: 60px;
font-size: 16px;
font-weight: 600;
color: #FFFFFF;
border: none;
border-radius: 15px;
padding: 0 20px;
cursor: pointer;
transition: background-color 0.3s, box-shadow 0.3s, transform 0.2s;
text-decoration: none;
text-align: center;
font-family: 'Inter', sans-serif;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
position: relative;
overflow: hidden;
}
.kaa-action-button::before {
content: "";
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(45deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
transition: left 0.3s;
}
.kaa-action-button:hover::before {
left: 100%;
}
/* Button Specific Styles */
.kaa-action-button.add-order {
background-color: var(--kaa-button-add-order);
}
.kaa-action-button.view-orders {
background-color: var(--kaa-button-view-orders);
}
.kaa-action-button.manage-products {
background-color: var(--kaa-button-manage-products);
}
.kaa-action-button.manage-users {
background-color: var(--kaa-button-manage-users);
}
.kaa-action-button.generate-reports {
background-color: var(--kaa-button-generate-reports);
}
.kaa-action-button.workspace-team {
background-color: var(--kaa-button-workspace-team);
}
.kaa-action-button:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
transform: scale(1.02);
}
.kaa-action-button i {
margin-right: 10px;
font-size: 20px;
color: #FFFFFF;
}
/* ---------------------------------------------------
7. Recent Orders Section
---------------------------------------------------- */
.kaa-recent-orders-section {
background-color: var(--kaa-white);
border-radius: var(--kaa-border-radius);
padding: 30px;
box-shadow: var(--kaa-box-shadow);
}
.kaa-recent-orders-section h4 {
font-size: 24px;
font-weight: 700;
color: var(--kaa-charcoal);
margin-bottom: 20px;
font-family: 'Inter', sans-serif;
}
/* Make table responsive */
.kaa-table-responsive {
overflow-x: auto;
}
.kaa-recent-orders-section table {
width: 100%;
border-collapse: collapse;
font-family: 'Roboto', sans-serif;
border: 1px solid var(--kaa-medium-grey);
}
.kaa-recent-orders-section th,
.kaa-recent-orders-section td {
padding: 16px 20px;
text-align: left;
font-size: 14px;
vertical-align: top;
}
.kaa-recent-orders-section th {
background-color: var(--kaa-light-grey);
color: var(--kaa-charcoal);
font-weight: 700;
border-bottom: 2px solid var(--kaa-medium-grey);
font-family: 'Inter', sans-serif;
position: relative;
}
/* Underline for headers */
.kaa-recent-orders-section th::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background-color: var(--kaa-medium-grey);
}
/* Alternating row colors */
.kaa-recent-orders-section tr:nth-child(even) {
background-color: #FAFAFA;
}
.kaa-recent-orders-section tr:hover {
background-color: #F1F1F1;
}
.kaa-recent-orders-section td {
color: var(--kaa-secondary-text);
border-bottom: 1px solid var(--kaa-light-grey);
}
/* Call to Action Text */
.kaa-call-to-action {
font-size: 18px;
font-weight: 600;
color: var(--kaa-primary-text);
text-align: center;
margin-bottom: 20px;
font-family: 'Inter', sans-serif;
}
.kaa-recent-orders-section .kaa-view-all {
display: block;
text-align: right;
margin-top: 15px;
font-size: 16px;
color: var(--kaa-accent-teal);
font-weight: 600;
text-decoration: none;
font-family: 'Inter', sans-serif;
transition: color 0.3s;
}
.kaa-recent-orders-section .kaa-view-all:hover {
color: var(--kaa-accent-soft-blue);
}
/* Badge Styles */
.kaa-badge-status-pending {
background-color: var(--kaa-badge-pending);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.kaa-badge-status-in-progress {
background-color: var(--kaa-badge-in-progress);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.kaa-badge-status-completed {
background-color: var(--kaa-badge-completed);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.kaa-badge-status-delivered {
background-color: var(--kaa-badge-delivered);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
/* Line Between Products */
.kaa-product-line {
border: none;
border-top: 1px solid var(--kaa-product-line-color);
margin: 8px 0;
}
/* ---------------------------------------------------
8. Footer Styles
---------------------------------------------------- */
.kaa-footer {
background-color: var(--kaa-white);
color: var(--kaa-secondary-text);
padding: 20px;
text-align: center;
border-radius: var(--kaa-border-radius);
font-size: 14px;
line-height: 22px;
margin-top: 40px;
font-family: 'Roboto', sans-serif;
box-shadow: var(--kaa-box-shadow);
}
/* ---------------------------------------------------
9. Responsive Design Enhancements
---------------------------------------------------- */
@media (max-width: 992px) {
.kaa-stat-card {
flex-direction: column;
align-items: flex-start;
}
.kaa-stat-icon {
margin-bottom: 10px;
}
}
@media (max-width: 768px) {
.kaa-header h1 {
font-size: 28px;
}
.kaa-welcome-section h3 {
font-size: 20px;
}
.kaa-stats-section {
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 20px;
}
.kaa-stat-info p {
font-size: 24px;
}
.kaa-action-button {
flex: 1 1 100%;
height: 50px;
font-size: 14px;
}
.kaa-recent-orders-section h4 {
font-size: 20px;
}
.kaa-recent-orders-section th,
.kaa-recent-orders-section td {
padding: 12px 16px;
font-size: 12px;
}
.kaa-call-to-action {
font-size: 16px;
}
}
@media (max-width: 576px) {
.kaa-container-body {
padding: 20px 10px;
}
.kaa-header h1 {
font-size: 24px;
}
.kaa-welcome-section h3 {
font-size: 18px;
}
.kaa-stat-info p {
font-size: 20px;
}
.kaa-action-button {
height: 45px;
font-size: 13px;
}
.kaa-recent-orders-section h4 {
font-size: 18px;
}
.kaa-recent-orders-section th,
.kaa-recent-orders-section td {
padding: 10px 12px;
font-size: 11px;
}
.kaa-call-to-action {
font-size: 14px;
}
}
</style>
<!-- Welcome Section -->
<div class="kaa-welcome-section">
<h3>Welcome to the Kaak Alia Dashboard! Streamline your bakery’s operations with ease.</h3>
</div>
<!-- Call to Action -->
<div class="kaa-call-to-action">
Manage orders, products, and more with just a click.
</div>
<!-- Statistics Section -->
<div class="kaa-stats-section">
<!-- Total Orders -->
<div class="kaa-stat-card">
<div class="kaa-stat-icon orders">
<i class="bi bi-cart-fill"></i>
</div>
<div class="kaa-stat-info">
<h5>Total Orders</h5>
<p><?= number_format($totalOrders) ?></p>
</div>
</div>
<!-- Pending Orders -->
<div class="kaa-stat-card">
<div class="kaa-stat-icon pending">
<i class="bi bi-hourglass-split"></i>
</div>
<div class="kaa-stat-info">
<h5>Pending Orders</h5>
<p><?= number_format($pendingOrders) ?></p>
</div>
</div>
<!-- Completed Orders -->
<div class="kaa-stat-card">
<div class="kaa-stat-icon completed">
<i class="bi bi-check-circle-fill"></i>
</div>
<div class="kaa-stat-info">
<h5>Completed Orders</h5>
<p><?= number_format($completedOrders) ?></p>
</div>
</div>
<!-- Delivered Orders -->
<div class="kaa-stat-card">
<div class="kaa-stat-icon delivered">
<i class="bi bi-truck"></i>
</div>
<div class="kaa-stat-info">
<h5>Delivered Orders</h5>
<p><?= number_format($deliveredOrders) ?></p>
</div>
</div>
<!-- Total Sales -->
<div class="kaa-stat-card">
<div class="kaa-stat-icon sales">
<i class="bi bi-cash-stack"></i>
</div>
<div class="kaa-stat-info">
<h5>Total Sales (KD)</h5>
<p><?= number_format($totalSales, 2) ?></p>
</div>
</div>
</div>
<!-- Main Buttons Section -->
<div class="kaa-buttons-section">
<a href="orders/add_order.php" class="kaa-action-button add-order">
<i class="bi bi-plus-circle-fill"></i>
Add New Order
</a>
<a href="orders/view_orders.php" class="kaa-action-button view-orders">
<i class="bi bi-eye-fill"></i>
View Orders
</a>
<a href="products/manage_products.php" class="kaa-action-button manage-products">
<i class="bi bi-box-seam-fill"></i>
Manage Products
</a>
<a href="users/manage_users.php" class="kaa-action-button manage-users">
<i class="bi bi-people-fill"></i>
Manage Users
</a>
<a href="reports/generate_reports.php" class="kaa-action-button generate-reports">
<i class="bi bi-bar-chart-fill"></i>
Generate Reports
</a>
<a href="/workspace" class="kaa-action-button workspace-team">
<i class="bi bi-people-fill"></i>
Workspace Team
</a>
</div>
<!-- Recent Orders Section -->
<div class="kaa-recent-orders-section">
<h4>Recent Orders</h4>
<div class="kaa-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 && count($recentOrders) > 0): ?>
<?php foreach($recentOrders as $order): ?>
<tr>
<td><?= htmlspecialchars($order['order_id'] ?? '', ENT_QUOTES, 'UTF-8') ?></td>
<td><?= htmlspecialchars($order['customer_name'] ?? '', ENT_QUOTES, 'UTF-8') ?></td>
<td><?= htmlspecialchars($order['contact'] ?? '', ENT_QUOTES, 'UTF-8') ?></td>
<td><?= nl2br(htmlspecialchars($order['delivery_address'] ?? '', ENT_QUOTES, 'UTF-8')) ?></td>
<td>
<?php
if (!empty($order['products'])) {
// Display product names with lines if two or more
foreach ($order['products'] as $index => $productName) {
echo '<div>' . htmlspecialchars($productName, ENT_QUOTES, 'UTF-8') . '</div>';
if ($index < count($order['products']) - 1) {
echo '<hr class="kaa-product-line">';
}
}
} else {
echo 'No products.';
}
?>
</td>
<td>
<?php
switch ($order['status']) {
case 'Pending':
echo '<span class="kaa-badge-status-pending">Pending</span>';
break;
case 'In Progress':
echo '<span class="kaa-badge-status-in-progress">In Progress</span>';
break;
case 'Completed':
echo '<span class="kaa-badge-status-completed">Completed</span>';
break;
case 'Delivered':
echo '<span class="kaa-badge-status-delivered">Delivered</span>';
break;
default:
echo '<span class="badge bg-light text-dark">Unknown</span>';
}
?>
</td>
<td><?= $order['order_date'] ? htmlspecialchars(date("d M Y, h:i A", strtotime($order['order_date'])), ENT_QUOTES, 'UTF-8') : 'N/A' ?></td>
<td><?= $order['delivery_datetime'] ? htmlspecialchars(date("d M Y, h:i A", strtotime($order['delivery_datetime'])), ENT_QUOTES, 'UTF-8') : 'N/A' ?></td>
</tr>
<?php endforeach; ?>
<?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="kaa-view-all">View All Orders</a>
</div>
<!-- Footer -->
<div class="kaa-footer">
© 2024 Kaak Alia Bakery. All rights reserved.
</div>
// Enable error reporting for debugging (Remove or comment out in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Include authentication and database connection
require_once DIR . '/auth.php';
require_once DIR . '/db_connect.php';
// Ensure the user is authenticated
if (!isset($_SESSION['user_id'])) {
header("Location: /public/login.php");
exit();
}
u s e r i d = user_id = u se r i d = _SESSION['user_id'];
$last_order_id = 0;
// Fetch the last pending order ID to initialize polling
i n i t i a l p e n d i n g s q l = " S E L E C T o . i d F R O M o r d e r s o W H E R E o . s t a t u s = ′ P e n d i n g ′ O R D E R B Y o . i d D E S C L I M I T 1 " ; initial_pending_sql = "
SELECT o.id
FROM orders o
WHERE o.status = 'Pending'
ORDER BY o.id DESC
LIMIT 1
";
ini t ia l p e n d in g s q l = " S E L E C T o . i d F R O M or d er so W H E R E o . s t a t u s = ′ P e n d in g ′ O R D E R B Y o . i d D E S C L I M I T 1" ; initial_result = c o n n − > q u e r y ( conn->query( co nn − > q u er y ( initial_pending_sql);
if (initial_result && initial_result->num_rows > 0) {
r o w = row = r o w = initial_result->fetch_assoc();
l a s t o r d e r i d = i n t v a l ( last_order_id = intval( l a s t o r d e r i d = in t v a l ( row['id']);
}
// Fetch the logged-in user's profile information
u s e r n a m e = ′ U s e r ′ ; / / D e f a u l t u s e r n a m e username = 'User'; // Default username
u ser nam e = ′ U se r ′ ; // D e f a u l t u ser nam e profile_image = '/assets/images/user-placeholder.png'; // Default profile image
s t m t = stmt = s t m t = conn->prepare("SELECT username, profile_image FROM users WHERE id = ?");
if (stmt) {
stmt->bind_param("i", u s e r i d ) ; user_id);
u se r i d ) ; stmt->execute();
r e s u l t u s e r = result_user = r es u l t u ser = stmt->get_result();
if (result_user && result_user->num_rows === 1) {
u s e r = user = u ser = result_user->fetch_assoc();
u s e r n a m e = h t m l s p e c i a l c h a r s ( username = htmlspecialchars( u ser nam e = h t m l s p ec ia l c ha r s ( user['username'], ENT_QUOTES, 'UTF-8');
if (!empty(user['profile_image']) && file_exists(__DIR__ . '/../' . user['profile_image'])) {
// Append file modification time to prevent caching
mod_time = filemtime(__DIR__ . '/../' . user['profile_image']);
p r o f i l e i m a g e = ′ / ′ . h t m l s p e c i a l c h a r s ( profile_image = '/' . htmlspecialchars( p r o f i l e i ma g e = ′ user['profile_image'], ENT_QUOTES, 'UTF-8') . '?v=' . mod_time;
}
}
stmt->close();
} else {
// Log error or handle accordingly
error_log("Failed to prepare statement for fetching user data.");
}
?>
<!-- Tailwind CSS -->
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<!-- Bootstrap JS Bundle with Popper (Loaded Defer for Performance) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" defer></script>
<!-- Alpine.js for Interactivity -->
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3.10.3/dist/cdn.min.js" defer></script>
<!-- Custom Styles for Notification Links -->
<style>
.notification-link {
display: block;
color: inherit;
text-decoration: none;
}
.notification-link:hover {
background-color: #4a5568; /* Tailwind's gray-700 */
}
.notification-badge {
position: absolute;
top: 0;
right: 0;
width: 0.75rem;
height: 0.75rem;
background-color: #f56565; /* Tailwind's red-500 */
border-radius: 9999px;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { transform: scale(0.75); opacity: 1; }
50% { transform: scale(1.25); opacity: 0.5; }
}
</style>
<!-- Audio Element for New Order Alert -->
<audio id="newOrderAudio" src="/assets/audio/you_have_a_new_order.mp3" preload="auto"></audio>
<!-- Header -->
<header class="bg-gray-800 text-white py-4 border-b-4 border-yellow-400 shadow-lg top-0 left-0 right-0 z-50">
<div class="container mx-auto px-4 flex justify-between items-center">
<!-- Logo -->
<div class="flex items-center">
<a href="/public/dashboard.php" class="flex items-center">
<img src="/assets/img/logo.png" alt="Kaak Alia Logo" class="h-12 w-auto mr-2">
<span class="text-xl font-bold">Admin Panel</span>
</a>
</div>
<!-- Navigation Links (Desktop) -->
<nav class="hidden md:flex space-x-4">
<a href="/public/orders/add_order.php" class="flex items-center bg-yellow-400 text-gray-800 px-4 py-2 rounded-lg hover:bg-yellow-300 shadow transition-all duration-300">
<i class="bi bi-plus-circle-fill mr-2"></i> Add Order
</a>
<a href="/public/orders/view_orders.php" class="flex items-center bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-400 shadow transition-all duration-300">
<i class="bi bi-eye-fill mr-2"></i> View Orders
</a>
<a href="/public/products/manage_products.php" class="flex items-center bg-green-400 text-white px-4 py-2 rounded-lg hover:bg-green-300 shadow transition-all duration-300">
<i class="bi bi-box-seam-fill mr-2"></i> Manage Products
</a>
<a href="/public/users/manage_users.php" class="flex items-center bg-orange-500 text-white px-4 py-2 rounded-lg hover:bg-orange-400 shadow transition-all duration-300">
<i class="bi bi-people-fill mr-2"></i> Manage Users
</a>
<a href="/public/reports/generate_reports.php" class="flex items-center bg-pink-500 text-white px-4 py-2 rounded-lg hover:bg-pink-400 shadow transition-all duration-300">
<i class="bi bi-bar-chart-fill mr-2"></i> Reports
</a>
</nav>
<!-- Right Side Icons -->
<div class="flex items-center space-x-4">
<!-- Notifications Dropdown -->
<div class="relative" x-data="{ open: false }">
<button @click="open = !open" class="relative text-white hover:text-yellow-400 focus:outline-none" aria-haspopup="true" aria-expanded="false" aria-controls="notification-menu" aria-label="Notifications">
<i class="bi bi-bell-fill text-2xl"></i>
<?php if ($last_order_id > 0): ?>
<!-- Notification Badge -->
<span class="absolute top-0 right-0 inline-block w-3 h-3 bg-red-500 rounded-full"></span>
<?php endif; ?>
</button>
<!-- Dropdown Menu -->
<div x-show="open" @click.away="open = false" id="notification-menu" class="absolute right-0 mt-2 w-80 bg-gray-800 text-white rounded-lg shadow-lg z-50">
<div class="py-2 px-4 border-b border-yellow-400">
<h3 class="text-lg font-semibold">Notifications</h3>
</div>
<ul class="max-h-64 overflow-y-auto" id="notificationsList">
<?php
// Fetch the latest 5 pending orders with their items
$notifications_sql = "
SELECT DISTINCT o.id, o.order_date, c.name AS customer_name
FROM orders o
JOIN customers c ON o.customer_id = c.id
JOIN order_items oi ON oi.order_id = o.id
WHERE o.status = 'Pending'
ORDER BY o.id DESC
LIMIT 5
";
$notifications_result = $conn->query($notifications_sql);
if ($notifications_result && $notifications_result->num_rows > 0):
while($notification = $notifications_result->fetch_assoc()):
?>
<li class="px-4 py-2 hover:bg-gray-700 cursor-pointer">
<a href="/public/orders/view_order_customer.php?order_id=<?= htmlspecialchars($notification['id'], ENT_QUOTES, 'UTF-8') ?>" class="notification-link flex items-center">
<span class="inline-block w-2 h-2 bg-red-500 rounded-full mr-2"></span>
New Order: <?= htmlspecialchars($notification['customer_name'], ENT_QUOTES, 'UTF-8'); ?> placed on <?= date("d M Y, h:i A", strtotime($notification['order_date'])) ?>
</a>
</li>
<?php
endwhile;
else:
?>
<li class="px-4 py-2 text-gray-400">No new notifications</li>
<?php endif; ?>
</ul>
<div class="py-2 px-4 border-t border-yellow-400 text-center">
<a href="/public/notifications.php" class="text-yellow-400 hover:underline">View All</a>
</div>
</div>
</div>
<!-- User Profile Dropdown -->
<div class="relative" x-data="{ open: false }">
<button @click="open = !open" class="flex items-center focus:outline-none" aria-haspopup="true" aria-expanded="false" aria-controls="profile-menu">
<img src="<?= $profile_image ?>" alt="User Avatar" class="h-10 w-10 rounded-full border-2 border-white hover:border-yellow-400 transition-colors duration-300">
<span class="ml-2 hidden lg:inline-block">
<?= $username ?>
</span>
<i class="bi bi-caret-down-fill ml-1 hidden lg:inline-block"></i>
</button>
<!-- Dropdown Menu -->
<div x-show="open" @click.away="open = false" id="profile-menu" class="absolute right-0 mt-2 w-48 bg-gray-800 text-white rounded-lg shadow-lg z-50">
<a href="/public/workspace/index.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
<i class="bi bi-laptop mr-2"></i> WorkSpace
</a>
<a href="/public/drivers/drivers_list.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
<i class="bi bi-car-front mr-2"></i> Drivers
</a>
<a href="/includes/user_settings.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
<i class="bi bi-gear-fill mr-2"></i> Settings
</a>
<a href="/public/about_kaakalia/index_en.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
<i class="bi bi-info-circle mr-2"></i> About Kaak Alia
</a>
<a href="/public/logout.php" class="block px-4 py-2 hover:bg-yellow-400 hover:text-gray-800 flex items-center">
<i class="bi bi-box-arrow-right mr-2"></i> Logout
</a>
</div>
</div>
<!-- Mobile Menu Button -->
<div class="md:hidden">
<button id="mobile-menu-button" class="text-white focus:outline-none" aria-label="Toggle Mobile Menu">
<i class="bi bi-list text-2xl"></i>
</button>
</div>
</div>
</div>
<!-- Mobile Navigation Menu -->
<nav id="mobile-menu" class="hidden md:hidden mt-4">
<ul class="flex flex-col space-y-2">
<li>
<a href="/public/orders/add_order.php" class="flex items-center bg-yellow-400 text-gray-800 px-4 py-2 rounded-lg hover:bg-yellow-300 transition-all duration-300">
<i class="bi bi-plus-circle-fill mr-2"></i> Add Order
</a>
</li>
<li>
<a href="/public/orders/view_orders.php" class="flex items-center bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-400 transition-all duration-300">
<i class="bi bi-eye-fill mr-2"></i> View Orders
</a>
</li>
<li>
<a href="/public/products/manage_products.php" class="flex items-center bg-green-400 text-white px-4 py-2 rounded-lg hover:bg-green-300 transition-all duration-300">
<i class="bi bi-box-seam-fill mr-2"></i> Manage Products
</a>
</li>
<li>
<a href="/public/users/manage_users.php" class="flex items-center bg-orange-500 text-white px-4 py-2 rounded-lg hover:bg-orange-400 transition-all duration-300">
<i class="bi bi-people-fill mr-2"></i> Manage Users
</a>
</li>
<li>
<a href="/public/reports/generate_reports.php" class="flex items-center bg-pink-500 text-white px-4 py-2 rounded-lg hover:bg-pink-400 transition-all duration-300">
<i class="bi bi-bar-chart-fill mr-2"></i> Reports
</a>
</li>
<!-- Additional Mobile Links -->
<li>
<a href="/public/notifications.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
<i class="bi bi-bell-fill mr-2"></i> Notifications
</a>
</li>
<li>
<a href="/includes/user_settings.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
<i class="bi bi-gear-fill mr-2"></i> Settings
</a>
</li>
<li>
<a href="/public/about_kaakalia/index.php" class="flex items-center bg-gray-700 text-white px-4 py-2 rounded-lg hover:bg-gray-600 transition-all duration-300">
<i class="bi bi-info-circle mr-2"></i> About Kaak Alia
</a>
</li>
</ul>
</nav>
</header>
<!-- JavaScript for Real-Time Notifications and Mobile Menu Toggle -->
<script>
document.addEventListener('DOMContentLoaded', function() {
const mobileMenuButton = document.getElementById('mobile-menu-button');
const mobileMenu = document.getElementById('mobile-menu');
// Toggle mobile menu on button click
mobileMenuButton.addEventListener('click', function() {
mobileMenu.classList.toggle('hidden');
});
let lastOrderId = <?= $last_order_id ?>;
const audio = document.getElementById('newOrderAudio');
// Function to fetch new orders
function fetchNewOrders() {
fetch(`/includes/get_new_orders.php?last_order_id=${lastOrderId}`)
.then(response => response.json())
.then(data => {
if (data.orders && data.orders.length > 0) {
data.orders.forEach(order => {
// Update lastOrderId if needed
if (order.id > lastOrderId) {
lastOrderId = order.id;
}
// Create a new notification item
const notificationsList = document.getElementById('notificationsList');
const li = document.createElement('li');
li.className = 'px-4 py-2 hover:bg-gray-700 cursor-pointer';
// Create a link to the order details page
const a = document.createElement('a');
a.href = `/public/orders/view_order_customer.php?order_id=${encodeURIComponent(order.id)}`;
a.className = 'notification-link flex items-center';
a.innerHTML = `
<span class="inline-block w-2 h-2 bg-red-500 rounded-full mr-2"></span>
New Order: ${sanitizeHTML(order.customer_name)} placed on ${sanitizeHTML(order.order_date)}
`;
li.appendChild(a);
// Insert the new notification at the top
notificationsList.insertBefore(li, notificationsList.firstChild);
// Play the audio alert
if (audio) {
audio.play().catch(function(error) {
console.log('Audio playback failed:', error);
});
}
// Optionally, update the notification badge
const bellIcon = document.querySelector('header .bi-bell-fill');
const existingBadge = bellIcon.parentNode.querySelector('.notification-badge');
if (!existingBadge) {
const badge = document.createElement('span');
badge.className = 'notification-badge';
bellIcon.parentNode.appendChild(badge);
}
});
}
})
.catch(error => {
console.error('Error fetching new orders:', error);
});
}
// Function to sanitize HTML to prevent XSS
function sanitizeHTML(str) {
var temp = document.createElement('div');
temp.textContent = str;
return temp.innerHTML;
}
// Poll every 10 seconds for new orders
setInterval(fetchNewOrders, 10000); // 10000 ms = 10 seconds
// Fetch immediately on page load
fetchNewOrders();
});
</script>
Certainly! Below is the fully updated dashboard.php file with all class names and CSS variables changed to use the db- prefix instead of kaa-. This ensures that the dashboard's styles are distinct from those in the header.php and avoids any potential naming conflicts.
Updated dashboard.php
<?php
// public/dashboard.php
// Now include the header
require_once '../includes/header.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';
/**
* 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 with associated products
$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,
p.name AS product_name
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
ORDER BY
o.order_date DESC
LIMIT 5
";
$recentOrdersResult = $conn->query($recentOrdersSql);
$recentOrders = [];
if ($recentOrdersResult && $recentOrdersResult->num_rows > 0) {
while($row = $recentOrdersResult->fetch_assoc()) {
$order_id = $row['order_id'];
if (!isset($recentOrders[$order_id])) {
$recentOrders[$order_id] = [
'order_id' => $row['order_id'],
'customer_name' => $row['customer_name'],
'contact' => $row['contact'],
'delivery_address' => $row['delivery_address'],
'status' => $row['status'],
'order_date' => $row['order_date'],
'delivery_datetime' => $row['delivery_datetime'],
'products' => []
];
}
$recentOrders[$order_id]['products'][] = $row['product_name'];
}
// Convert associative array to indexed array
$recentOrders = array_values($recentOrders);
} else {
$recentOrders = 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 href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- 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 with New Prefix
---------------------------------------------------- */
:root {
/* Primary Colors */
--db-background: #F9FAFB; /* Light Neutral Background */
--db-white: #FFFFFF; /* Crisp White */
--db-light-grey: #E5E7EB; /* Light Grey */
--db-medium-grey: #D1D5DB; /* Medium Grey */
--db-dark-grey: #374151; /* Dark Grey */
--db-charcoal: #1F2937; /* Charcoal */
/* Accent Colors */
--db-accent-color: #D1C287; /* Accent Line Color */
--db-accent-blue: #4A90E2;
--db-accent-green: #50C878;
--db-accent-red: #FF6B6B;
--db-accent-teal: #20B2AA;
--db-accent-soft-blue: #A3D2CA;
--db-accent-purple: #8A65FF;
--db-accent-orange: #FFA500;
/* Text Colors */
--db-primary-text: var(--db-charcoal);
--db-secondary-text: #6B7280;
/* UI Elements */
--db-box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
--db-border-radius: 12px;
/* Button Colors */
--db-button-add-order: #6C63FF;
--db-button-view-orders: #FFA500;
--db-button-manage-products: #20B2AA;
--db-button-manage-users: #4B0082;
--db-button-generate-reports: #FF6B6B;
--db-button-workspace-team: #4F46E5; /* Indigo */
/* Status Badge Colors */
--db-badge-pending: #FFD166;
--db-badge-in-progress: #6A4C93;
--db-badge-completed: #4CAF50;
--db-badge-delivered: #20B2AA;
/* Line Color Between Products */
--db-product-line-color: #E5E7EB;
}
/* ---------------------------------------------------
2. Global Styles
---------------------------------------------------- */
body {
font-family: 'Roboto', sans-serif;
background-color: var(--db-background);
margin: 0;
padding: 0;
color: var(--db-primary-text);
}
.db-container-body {
max-width: 1200px;
margin: 40px auto;
padding: 40px 20px;
box-sizing: border-box;
background-color: var(--db-white);
box-shadow: var(--db-box-shadow);
border-radius: var(--db-border-radius);
transition: all 0.3s ease;
}
/* ---------------------------------------------------
3. Header Styles
---------------------------------------------------- */
.db-header {
padding: 20px 30px;
background-color: var(--db-white);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 30px;
border-bottom: 1px solid var(--db-light-grey);
}
.db-header h1 {
color: var(--db-charcoal);
font-size: 36px;
font-weight: 700;
font-family: 'Inter', sans-serif;
position: relative;
}
/* Decorative Line Under Header */
.db-header h1::after {
content: "";
display: block;
width: 120px;
height: 4px;
background: var(--db-accent-color);
margin: 12px auto 0;
border-radius: 2px;
}
/* ---------------------------------------------------
4. Welcome Section
---------------------------------------------------- */
.db-welcome-section {
background-color: var(--db-white);
box-shadow: var(--db-box-shadow);
border-radius: var(--db-border-radius);
padding: 30px;
text-align: center;
margin-bottom: 30px;
font-family: 'Inter', sans-serif;
}
.db-welcome-section h3 {
font-size: 24px;
color: var(--db-primary-text);
margin-bottom: 10px;
font-weight: 600;
}
.db-welcome-section p {
font-size: 16px;
color: var(--db-secondary-text);
margin: 0;
}
/* ---------------------------------------------------
5. Statistics Section
---------------------------------------------------- */
.db-stats-section {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 25px;
margin-bottom: 30px;
}
.db-stat-card {
background-color: var(--db-white);
box-shadow: var(--db-box-shadow);
border-radius: var(--db-border-radius);
padding: 20px;
display: flex;
align-items: center;
transition: transform 0.3s, box-shadow 0.3s;
cursor: default;
position: relative;
}
.db-stat-card:hover {
transform: translateY(-5px);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
.db-stat-icon {
width: 60px;
height: 60px;
background-color: var(--db-accent-soft-blue);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
/* Different colors for each stat icon */
.db-stat-icon.orders { background-color: var(--db-accent-blue); } /* Blue */
.db-stat-icon.pending { background-color: var(--db-badge-pending); } /* Yellow */
.db-stat-icon.completed { background-color: var(--db-badge-completed); } /* Green */
.db-stat-icon.delivered { background-color: var(--db-badge-delivered); } /* Teal */
.db-stat-icon.sales { background-color: var(--db-accent-red); } /* Red */
.db-stat-icon i {
color: #FFFFFF;
font-size: 24px;
}
.db-stat-info h5 {
font-size: 18px;
color: var(--db-primary-text);
margin-bottom: 5px;
font-family: 'Inter', sans-serif;
font-weight: 600;
}
.db-stat-info p {
font-size: 28px;
font-weight: 700;
color: var(--db-charcoal);
margin: 0;
}
/* ---------------------------------------------------
6. Main Buttons Section
---------------------------------------------------- */
.db-buttons-section {
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-bottom: 30px;
}
.db-action-button {
display: flex;
align-items: center;
justify-content: center;
flex: 1 1 220px;
height: 60px;
font-size: 16px;
font-weight: 600;
color: #FFFFFF;
border: none;
border-radius: 15px;
padding: 0 20px;
cursor: pointer;
transition: background-color 0.3s, box-shadow 0.3s, transform 0.2s;
text-decoration: none;
text-align: center;
font-family: 'Inter', sans-serif;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
position: relative;
overflow: hidden;
}
.db-action-button::before {
content: "";
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(45deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
transition: left 0.3s;
}
.db-action-button:hover::before {
left: 100%;
}
/* Button Specific Styles */
.db-action-button.add-order {
background-color: var(--db-button-add-order);
}
.db-action-button.view-orders {
background-color: var(--db-button-view-orders);
}
.db-action-button.manage-products {
background-color: var(--db-button-manage-products);
}
.db-action-button.manage-users {
background-color: var(--db-button-manage-users);
}
.db-action-button.generate-reports {
background-color: var(--db-button-generate-reports);
}
.db-action-button.workspace-team {
background-color: var(--db-button-workspace-team);
}
.db-action-button:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
transform: scale(1.02);
}
.db-action-button i {
margin-right: 10px;
font-size: 20px;
color: #FFFFFF;
}
/* ---------------------------------------------------
7. Recent Orders Section
---------------------------------------------------- */
.db-recent-orders-section {
background-color: var(--db-white);
border-radius: var(--db-border-radius);
padding: 30px;
box-shadow: var(--db-box-shadow);
}
.db-recent-orders-section h4 {
font-size: 24px;
font-weight: 700;
color: var(--db-charcoal);
margin-bottom: 20px;
font-family: 'Inter', sans-serif;
}
/* Make table responsive */
.db-table-responsive {
overflow-x: auto;
}
.db-recent-orders-section table {
width: 100%;
border-collapse: collapse;
font-family: 'Roboto', sans-serif;
border: 1px solid var(--db-medium-grey);
}
.db-recent-orders-section th,
.db-recent-orders-section td {
padding: 16px 20px;
text-align: left;
font-size: 14px;
vertical-align: top;
}
.db-recent-orders-section th {
background-color: var(--db-light-grey);
color: var(--db-charcoal);
font-weight: 700;
border-bottom: 2px solid var(--db-medium-grey);
font-family: 'Inter', sans-serif;
position: relative;
}
/* Underline for headers */
.db-recent-orders-section th::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background-color: var(--db-medium-grey);
}
/* Alternating row colors */
.db-recent-orders-section tr:nth-child(even) {
background-color: #FAFAFA;
}
.db-recent-orders-section tr:hover {
background-color: #F1F1F1;
}
.db-recent-orders-section td {
color: var(--db-secondary-text);
border-bottom: 1px solid var(--db-light-grey);
}
/* Call to Action Text */
.db-call-to-action {
font-size: 18px;
font-weight: 600;
color: var(--db-primary-text);
text-align: center;
margin-bottom: 20px;
font-family: 'Inter', sans-serif;
}
.db-recent-orders-section .db-view-all {
display: block;
text-align: right;
margin-top: 15px;
font-size: 16px;
color: var(--db-accent-teal);
font-weight: 600;
text-decoration: none;
font-family: 'Inter', sans-serif;
transition: color 0.3s;
}
.db-recent-orders-section .db-view-all:hover {
color: var(--db-accent-soft-blue);
}
/* Badge Styles */
.db-badge-status-pending {
background-color: var(--db-badge-pending);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.db-badge-status-in-progress {
background-color: var(--db-badge-in-progress);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.db-badge-status-completed {
background-color: var(--db-badge-completed);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.db-badge-status-delivered {
background-color: var(--db-badge-delivered);
color: #FFFFFF;
padding: 6px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: 600;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
/* Line Between Products */
.db-product-line {
border: none;
border-top: 1px solid var(--db-product-line-color);
margin: 8px 0;
}
/* ---------------------------------------------------
8. Footer Styles
---------------------------------------------------- */
.db-footer {
background-color: var(--db-white);
color: var(--db-secondary-text);
padding: 20px;
text-align: center;
border-radius: var(--db-border-radius);
font-size: 14px;
line-height: 22px;
margin-top: 40px;
font-family: 'Roboto', sans-serif;
box-shadow: var(--db-box-shadow);
}
/* ---------------------------------------------------
9. Responsive Design Enhancements
---------------------------------------------------- */
@media (max-width: 992px) {
.db-stat-card {
flex-direction: column;
align-items: flex-start;
}
.db-stat-icon {
margin-bottom: 10px;
}
}
@media (max-width: 768px) {
.db-header h1 {
font-size: 28px;
}
.db-welcome-section h3 {
font-size: 20px;
}
.db-stats-section {
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 20px;
}
.db-stat-info p {
font-size: 24px;
}
.db-action-button {
flex: 1 1 100%;
height: 50px;
font-size: 14px;
}
.db-recent-orders-section h4 {
font-size: 20px;
}
.db-recent-orders-section th,
.db-recent-orders-section td {
padding: 12px 16px;
font-size: 12px;
}
.db-call-to-action {
font-size: 16px;
}
}
@media (max-width: 576px) {
.db-container-body {
padding: 20px 10px;
}
.db-header h1 {
font-size: 24px;
}
.db-welcome-section h3 {
font-size: 18px;
}
.db-stat-info p {
font-size: 20px;
}
.db-action-button {
height: 45px;
font-size: 13px;
}
.db-recent-orders-section h4 {
font-size: 18px;
}
.db-recent-orders-section th,
.db-recent-orders-section td {
padding: 10px 12px;
font-size: 11px;
}
.db-call-to-action {
font-size: 14px;
}
}
</style>
</head>
<body>
<main class='db-container-body'>
<!-- Header -->
<div class="db-header">
<h1>Kaak Alia Dashboard</h1>
</div>
<!-- Welcome Section -->
<div class="db-welcome-section">
<h3>Welcome to the Kaak Alia Dashboard! Streamline your bakery’s operations with ease.</h3>
</div>
<!-- Call to Action -->
<div class="db-call-to-action">
Manage orders, products, and more with just a click.
</div>
<!-- Statistics Section -->
<div class="db-stats-section">
<!-- Total Orders -->
<div class="db-stat-card">
<div class="db-stat-icon orders">
<i class="bi bi-cart-fill"></i>
</div>
<div class="db-stat-info">
<h5>Total Orders</h5>
<p><?= number_format($totalOrders) ?></p>
</div>
</div>
<!-- Pending Orders -->
<div class="db-stat-card">
<div class="db-stat-icon pending">
<i class="bi bi-hourglass-split"></i>
</div>
<div class="db-stat-info">
<h5>Pending Orders</h5>
<p><?= number_format($pendingOrders) ?></p>
</div>
</div>
<!-- Completed Orders -->
<div class="db-stat-card">
<div class="db-stat-icon completed">
<i class="bi bi-check-circle-fill"></i>
</div>
<div class="db-stat-info">
<h5>Completed Orders</h5>
<p><?= number_format($completedOrders) ?></p>
</div>
</div>
<!-- Delivered Orders -->
<div class="db-stat-card">
<div class="db-stat-icon delivered">
<i class="bi bi-truck"></i>
</div>
<div class="db-stat-info">
<h5>Delivered Orders</h5>
<p><?= number_format($deliveredOrders) ?></p>
</div>
</div>
<!-- Total Sales -->
<div class="db-stat-card">
<div class="db-stat-icon sales">
<i class="bi bi-cash-stack"></i>
</div>
<div class="db-stat-info">
<h5>Total Sales (KD)</h5>
<p><?= number_format($totalSales, 2) ?></p>
</div>
</div>
</div>
<!-- Main Buttons Section -->
<div class="db-buttons-section">
<a href="orders/add_order.php" class="db-action-button add-order">
<i class="bi bi-plus-circle-fill"></i>
Add New Order
</a>
<a href="orders/view_orders.php" class="db-action-button view-orders">
<i class="bi bi-eye-fill"></i>
View Orders
</a>
<a href="products/manage_products.php" class="db-action-button manage-products">
<i class="bi bi-box-seam-fill"></i>
Manage Products
</a>
<a href="users/manage_users.php" class="db-action-button manage-users">
<i class="bi bi-people-fill"></i>
Manage Users
</a>
<a href="reports/generate_reports.php" class="db-action-button generate-reports">
<i class="bi bi-bar-chart-fill"></i>
Generate Reports
</a>
<a href="/workspace" class="db-action-button workspace-team">
<i class="bi bi-people-fill"></i>
Workspace Team
</a>
</div>
<!-- Recent Orders Section -->
<div class="db-recent-orders-section">
<h4>Recent Orders</h4>
<div class="db-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 && count($recentOrders) > 0): ?>
<?php foreach($recentOrders as $order): ?>
<tr>
<td><?= htmlspecialchars($order['order_id'] ?? '', ENT_QUOTES, 'UTF-8') ?></td>
<td><?= htmlspecialchars($order['customer_name'] ?? '', ENT_QUOTES, 'UTF-8') ?></td>
<td><?= htmlspecialchars($order['contact'] ?? '', ENT_QUOTES, 'UTF-8') ?></td>
<td><?= nl2br(htmlspecialchars($order['delivery_address'] ?? '', ENT_QUOTES, 'UTF-8')) ?></td>
<td>
<?php
if (!empty($order['products'])) {
// Display product names with lines if two or more
foreach ($order['products'] as $index => $productName) {
echo '<div>' . htmlspecialchars($productName, ENT_QUOTES, 'UTF-8') . '</div>';
if ($index < count($order['products']) - 1) {
echo '<hr class="db-product-line">';
}
}
} else {
echo 'No products.';
}
?>
</td>
<td>
<?php
switch ($order['status']) {
case 'Pending':
echo '<span class="db-badge-status-pending">Pending</span>';
break;
case 'In Progress':
echo '<span class="db-badge-status-in-progress">In Progress</span>';
break;
case 'Completed':
echo '<span class="db-badge-status-completed">Completed</span>';
break;
case 'Delivered':
echo '<span class="db-badge-status-delivered">Delivered</span>';
break;
default:
echo '<span class="badge bg-light text-dark">Unknown</span>';
}
?>
</td>
<td><?= $order['order_date'] ? htmlspecialchars(date("d M Y, h:i A", strtotime($order['order_date'])), ENT_QUOTES, 'UTF-8') : 'N/A' ?></td>
<td><?= $order['delivery_datetime'] ? htmlspecialchars(date("d M Y, h:i A", strtotime($order['delivery_datetime'])), ENT_QUOTES, 'UTF-8') : 'N/A' ?></td>
</tr>
<?php endforeach; ?>
<?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="db-view-all">View All Orders</a>
</div>
<!-- Footer -->
<div class="db-footer">
© 2024 Kaak Alia Bakery. All rights reserved.
</div>
</main>
<!-- Bootstrap JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Optional JavaScript for additional interactivity can be added here
</script>
</body>
</html>
<?php
// Flush the output buffer
ob_end_flush();
// No closing PHP tag to prevent unwanted output
?>
Summary of Changes:
CSS Variables:
All CSS variables prefixed with --kaa- have been changed to --db-. For example:
--kaa-background → --db-background
--kaa-white → --db-white
...and so on for all variables.
Class Names:
All CSS classes and HTML class attributes prefixed with kaa- have been changed to db-. For example:
.kaa-container-body → .db-container-body
.kaa-header → .db-header
.kaa-welcome-section → .db-welcome-section
...and so on for all classes.
CSS Selectors and Properties:
Updated all occurrences in the <style> tag to reflect the new db- prefix.
HTML Structure:
Updated all HTML elements' class attributes from kaa- to db-. This includes:
<main class='kaa-container-body'> → <main class='db-container-body'>
<div class="kaa-header"> → <div class="db-header">
...and so on for all relevant elements.
CSS Styling:
Changed all styling references to use the new db- prefixed variables and classes to maintain consistency.
Important Notes:
Header File (header.php): As per your request, the header.php file remains unchanged. Ensure that it does not contain any class names or CSS variables that start with db- to avoid conflicts.
Unique Class Names: By changing the prefix from kaa- to db-, the dashboard's styles are now distinct and will not interfere with the styles defined in the header.php or any other included files.
Consistency: Make sure that any JavaScript or additional PHP code that references these class names is also updated accordingly. In the provided dashboard.php, class names are used consistently with the new db- prefix.
Testing: After making these changes, thoroughly test the dashboard to ensure that all styles are applied correctly and that there are no broken elements due to the class name changes.
If you have any further customization needs or encounter issues after implementing these changes, feel free to ask for assistance!
Copy first response
Not yet included in a published release.
1
−
( o i . d i sco u n t p er ce n t a g e /100 ))) A S t o t a l s a l es F R O M or d e r i t e m so i J O I N p r o d u c t s pO N o i . p r o d u c t i d =
p . i dJ O I N or d er so O N o i . or d e r i d =
o . i d W H E R E o . s t a t u s I N ( ′ C o m pl e t e d ′ , ′ D e l i v er e d ′ ) " ;
′
]
, ′
c
u
s
t
o
m
e
r n
am
e ′
=>
′
d
e
l
i
v
er
y a
dd
r
es
s ′
=>
′
or
d
e
r d
a
t
e ′
=>
′
]
[
]
=
/ ′
.
h
t
m
l
s
p
ec
ia
l
c
ha
r
s
(