ok, i want to update this codes of dadsbaord (<?php // public/dashboard.php // Enable…
- User
ok, i want to update this codes of dadsbaord (<?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(); require_once '../includes/header.php';
// Include authentication and database connection first require_once '../includes/auth.php'; require_once '../includes/db_connect.php';
// Function to sanitize input function sanitize_input(input) { return htmlspecialchars(trim(input), ENT_QUOTES, 'UTF-8'); }
/**
- Fetch Quick Stats */
// Total Orders totalOrdersResult = totalOrdersSql); totalOrdersResult && totalOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Pending Orders pendingOrdersResult = pendingOrdersSql); pendingOrdersResult && pendingOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// In Progress Orders inProgressOrdersResult = inProgressOrdersSql); inProgressOrdersResult && inProgressOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Completed Orders completedOrdersResult = completedOrdersSql); completedOrdersResult && completedOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Delivered Orders deliveredOrdersResult = deliveredOrdersSql); deliveredOrdersResult && deliveredOrdersResult->fetch_assoc()) ? (int)$row['total'] : 0;
// Total Sales from Completed and Delivered Orders considering discounts totalSalesResult = totalSalesSql); totalSalesResult && totalSalesResult->fetch_assoc()) ? (float)$row['total_sales'] : 0.00;
// Total Delivery Fees from Completed and Delivered Orders totalDeliveryFeesResult = totalDeliveryFeesSql); totalDeliveryFeesResult && totalDeliveryFeesResult->fetch_assoc()) ? (float)$row['total_fees'] : 0.00;
// Total Revenue (Sales + Delivery Fees) totalSales + $totalDeliveryFees;
/**
- 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, o.delivery_fee, p.name AS product_name, p.price AS product_price, oi.quantity, oi.discount_percentage 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 ";
conn->query(recentOrders = [];
if (recentOrdersResult && recentOrdersResult->num_rows > 0) { while(recentOrdersResult->fetch_assoc()) { row['order_id']; if (!isset(order_id])) { order_id] = [ 'order_id' => row['customer_name'], 'contact' => row['delivery_address'], 'status' => row['order_date'], 'delivery_datetime' => row['delivery_fee'], 'products' => [], 'total_order_amount' => 0.00 ]; } // Calculate total for each product row['product_price'] * row['discount_percentage'] / 100)); order_id]['products'][] = [ 'product_name' => row['quantity'], 'discount_percentage' => productTotal ]; // Add to total order amount order_id]['total_order_amount'] += productTotal; } // After processing products, add delivery_fee to total_order_amount foreach (recentOrders as &order) { order['total_order_amount'] += order['delivery_fee']; } // Convert associative array to indexed array recentOrders = array_values(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 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; } /* Custom scrollbar for better UX */ ::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-track { background: #f1f5f9; /* Tailwind's gray-100 */ } ::-webkit-scrollbar-thumb { background: #4b6584; /* Teal-500 */ border-radius: 4px; } ::-webkit-scrollbar-thumb:hover { background: #0d9488; /* Teal-600 */ } /* --------------------------------------------------- 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.in-progress { background-color: var(--db-badge-in-progress); } /* Purple */ .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.delivery { background-color: var(--db-accent-teal); } /* Teal */ .db-stat-icon.revenue { background-color: var(--db-accent-purple); } /* Purple */ .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><!-- 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, users, 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> <!-- In Progress Orders --> <div class="db-stat-card"> <div class="db-stat-icon in-progress"> <i class="bi bi-arrow-repeat"></i> </div> <div class="db-stat-info"> <h5>In Progress</h5> <p><?= number_format($inProgressOrders) ?></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-flatbed"></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> <!-- Total Delivery Fees --> <div class="db-stat-card"> <div class="db-stat-icon delivery"> <i class="bi bi-truck-flatbed-fill"></i> </div> <div class="db-stat-info"> <h5>Total Delivery Fees (KD)</h5> <p><?= number_format($totalDeliveryFees, 2) ?></p> </div> </div> <!-- Total Revenue --> <div class="db-stat-card"> <div class="db-stat-icon revenue"> <i class="bi bi-graph-up-arrow"></i> </div> <div class="db-stat-info"> <h5>Total Revenue (KD)</h5> <p><?= number_format($totalRevenue, 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="/public/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>Delivery Fee (KD)</th> <th>Total Amount (KD)</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 => $product) { echo '<div>' . htmlspecialchars($product['product_name'], ENT_QUOTES, 'UTF-8') . ' (x' . htmlspecialchars($product['quantity'], ENT_QUOTES, 'UTF-8') . ') - ' . htmlspecialchars($product['discount_percentage'], ENT_QUOTES, 'UTF-8') . '% OFF</div>'; if ($index < count($order['products']) - 1) { echo '<hr class="db-product-line">'; } } } else { echo 'No products.'; } ?> </td> <td><?= number_format($order['delivery_fee'], 2) ?></td> <td><?= number_format($order['total_order_amount'], 2) ?></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="10" 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"> © <?= date("Y") ?> Kaak Alia Bakery. All rights reserved. </div>- Overall Aesthetic and Theme
Modern and Clean Design: The page is designed with a minimalistic aesthetic focused on simplicity and clarity, allowing users to engage with form elements without distractions. This promotes easy interaction and efficient data entry. Color Palette: Primary Colors: A soothing teal hue (#20B2AA) highlights key interactive elements like buttons and icons, establishing a sense of trust and professionalism. Neutral Backgrounds: Soft gray tones (e.g., #f1f5f9 for scrollbar tracks) provide a balanced backdrop that enhances readability without overpowering content. Accent Colors: Red tones draw attention to error messages, while green hues are used for success indicators, offering clear, visual feedback for various form states. 2. Layout and Structure
Container-Based Layout: The content is housed in a responsive container (container mx-auto p-6), maintaining alignment and spacing across screen sizes. Generous padding (p-6) prevents clutter, creating a comfortable visual structure. Sectioning and Hierarchy: The form is divided into sections (e.g., Customer Details, Order Details), each within distinct, bordered blocks (bg-white rounded-lg shadow-lg p-6 mb-8), helping users navigate and logically organize information. Responsive Grid System: Using Tailwind CSS's grid utilities, form fields adapt to different screen sizes, appearing side-by-side on large screens (md:flex-row md:space-x-6) and stacking vertically on smaller devices for better accessibility. 3. Typography and Text Styling
Font Choices: A clean, sans-serif font is used for readability. Tailwind CSS's default font settings ensure consistency. Text Hierarchy: Headings: Prominent headings (text-3xl font-bold text-teal-600) guide users through sections. Labels and Instructions: Labels use medium font weights (font-medium text-gray-700) for clarity, with additional descriptions styled smaller and gray for non-disruptive guidance. 4. Form Elements and Inputs
Input Fields: Consistent Styling: Uniform styling across inputs (rounded-md border-gray-300 with focus states like focus:ring-teal-500 focus:border-teal-500) creates a cohesive user experience. Padding and Sizing: Sufficient padding (p-2) enhances readability and interaction. Buttons: Primary Actions: Bold-colored buttons (bg-teal-500 rounded-lg) with hover effects (hover:bg-teal-600) provide visual feedback. Icon Integration: Using icons (via Bootstrap Icons) next to button labels aids in clarity, making functions intuitive. Checkboxes and Radio Buttons: Customized Appearance: Consistent sizing and color accents (text-teal-600) make these elements noticeable without overwhelming the design. 5. Interactive Elements and Enhancements
Dynamic Form Rows: Animated transitions for adding/removing product rows (shadow-md) keep changes smooth and visually coherent. Tooltips: Small icons (bi-question-circle) with tooltips provide guidance on hover, helping users without adding clutter. Tooltips have dark backgrounds and smooth animations. 6. Notifications and Alerts
Feedback Messages: Error Messages: Styled with red tones (bg-red-100, border-red-400, text-red-700), they are prominent and actionable. Success Messages: Green styling (bg-green-100, border-green-400, text-green-700) reinforces positive actions. Iconography: Icons (bi-exclamation-triangle-fill for errors, bi-check-circle-fill for successes) enhance message clarity. 7. Scrollbar Customization
Aesthetic Scrollbars: Styled with narrow widths (8px) and rounded edges, ensuring they are functional but not intrusive. Colors align with the main scheme, and the thumb color changes on hover for feedback. 8. Buttons and Interactive Controls
Add and Remove Buttons: Both buttons are consistently designed with background colors, text colors, padding, and hover effects, making the interface predictable. Icon Usage: Icons (e.g., bi-plus-circle-fill for adding, bi-trash-fill for removing) clarify actions. 9. Date and Time Picker Integration
Enhanced User Input: Integrate the Flatpickr library for date and time selection (#delivery_datetime), offering users an intuitive interface that matches other form styles. Keyboard Accessibility: Designed to be keyboard-friendly, accommodating all users. 10. Footer Design
Subtle Footer: The footer uses soft gray tones (text-gray-600), ensuring it provides information without detracting from the main content. 11. Responsive Design and Mobile Optimization
Adaptive Layouts: Tailwind CSS responsive utilities ensure layout flexibility across devices. Touch-Friendly Elements: Adequate sizing and spacing facilitate easy touchscreen interaction. 12. Accessibility Features
Semantic HTML: Elements like , , and are used correctly to support assistive technologies. Focus States: Interactive elements have clear focus states (focus:ring-teal-500 focus:border-teal-500) for keyboard navigation. 13. Consistent Spacing and Sizing
Whitespace Utilization: Generous margins (mb-6, mt-4) and padding (p-4, p-6) create visual balance. Element Sizing: Uniform element sizing promotes a well-organized, professional appearance. 14. Visual Hierarchy and Emphasis
Clear Hierarchy: Larger, bolder fonts in headings guide users through sections. Emphasized Labels: Important fields are marked with an asterisk (*), drawing attention without overwhelming. 15. Interactive Feedback and Animations
Hover and Focus Effects: Color changes on hover (hover:bg-teal-600, hover:bg-red-600) provide feedback. Smooth Transitions: Transition effects (transition duration-300) enhance user experience. 16. Iconography and Visual Cues
Bootstrap Icons Integration: Icons are sized and colored consistently (text-gray-400 text-sm for tooltips), ensuring they enhance without disrupting design. 17. Enhanced User Guidance
Tooltip Descriptions: Tooltips provide context-sensitive help, available only when needed to maintain a clean interface. and this inof dabaase (-- phpMyAdmin SQL Dump -- version 5.2.1 -- https://www.phpmyadmin.net/
-- Host: 127.0.0.1:3306 -- Generation Time: Nov 14, 2024 at 09:26 PM -- Server version: 10.11.9-MariaDB -- PHP Version: 7.2.34
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /; /!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /; /!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /; /!40101 SET NAMES utf8mb4 */;
-- -- Database:
u406552082_kaakalia
-- -- Table structure for table
adsCREATE TABLE
ads(idint(11) NOT NULL,user_idint(11) NOT NULL,namevarchar(255) NOT NULL,ad_typeenum('Post','Story') NOT NULL,related_idint(11) NOT NULL,budgetdecimal(10,2) NOT NULL,total_spentdecimal(10,2) DEFAULT 0.00,start_datedate NOT NULL,end_datedate NOT NULL,statusenum('Active','Paused','Completed') DEFAULT 'Active',created_atdatetime DEFAULT current_timestamp(),updated_atdatetime DEFAULT current_timestamp() ON UPDATE current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
ad_spend_logsCREATE TABLE
ad_spend_logs(idint(11) NOT NULL,ad_idint(11) NOT NULL,amountdecimal(10,2) NOT NULL,spend_datedatetime DEFAULT current_timestamp(),descriptionvarchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
customersCREATE TABLE
customers(idint(11) NOT NULL,namevarchar(100) NOT NULL,contactvarchar(50) DEFAULT NULL,delivery_addresstext DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
driversCREATE TABLE
drivers(idint(11) NOT NULL,namevarchar(100) NOT NULL,numbervarchar(15) NOT NULL,is_startinyint(1) DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
notificationsCREATE TABLE
notifications(idint(11) NOT NULL,user_idint(11) NOT NULL,typeenum('order','post','plan','note','ad') NOT NULL,messagevarchar(255) NOT NULL,linkvarchar(255) NOT NULL,created_atdatetime DEFAULT current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
ordersCREATE TABLE
orders(idint(11) NOT NULL,customer_idint(11) NOT NULL,statusenum('Pending','In Progress','Completed','Delivered') DEFAULT 'Pending',priorityenum('Normal','Important','Quick') DEFAULT 'Normal',order_datedatetime DEFAULT current_timestamp(),delivery_datetimedatetime DEFAULT NULL,delivery_datedate DEFAULT NULL,delivery_feedecimal(10,2) NOT NULL DEFAULT 0.00,free_shippingtinyint(1) NOT NULL DEFAULT 0,is_paidtinyint(1) NOT NULL DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
order_itemsCREATE TABLE
order_items(idint(11) NOT NULL,order_idint(11) NOT NULL,product_idint(11) NOT NULL,quantityint(11) NOT NULL DEFAULT 1,packaging_preferencesvarchar(255) DEFAULT NULL,discount_percentagedecimal(5,2) DEFAULT 0.00,discount_reasonvarchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
productsCREATE TABLE
products(idint(11) NOT NULL,namevarchar(100) NOT NULL,sizevarchar(50) DEFAULT NULL,pricedecimal(10,2) NOT NULL,categoryvarchar(50) DEFAULT NULL,thumbnailvarchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
usersCREATE TABLE
users(idint(11) NOT NULL,usernamevarchar(50) NOT NULL,emailvarchar(100) DEFAULT NULL,passwordvarchar(255) NOT NULL,roleenum('admin','staff') NOT NULL,profile_imagevarchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
workspace_notesCREATE TABLE
workspace_notes(idint(11) NOT NULL,user_idint(11) NOT NULL,titlevarchar(255) NOT NULL,contenttext NOT NULL,created_atdatetime DEFAULT current_timestamp(),updated_atdatetime DEFAULT current_timestamp() ON UPDATE current_timestamp() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
workspace_plansCREATE TABLE
workspace_plans(idint(11) NOT NULL,user_idint(11) NOT NULL,titlevarchar(255) NOT NULL,descriptiontext DEFAULT NULL,audio_pathvarchar(255) DEFAULT NULL,due_datedatetime DEFAULT NULL,statusenum('Not Started','In Progress','Completed') DEFAULT 'Not Started',created_atdatetime DEFAULT current_timestamp(),updated_atdatetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),priorityenum('Normal','Important','Critical') NOT NULL DEFAULT 'Normal' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- -- Table structure for table
workspace_postsCREATE TABLE
workspace_posts(idint(11) NOT NULL,user_idint(11) NOT NULL,platformenum('Instagram','Facebook','Twitter','Other') NOT NULL,contenttext NOT NULL,media_urlvarchar(255) DEFAULT NULL,scheduled_datetimedatetime DEFAULT NULL,statusenum('Scheduled','Posted','Failed') DEFAULT 'Scheduled',created_atdatetime DEFAULT current_timestamp(),updated_atdatetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),typeenum('Post','Story') DEFAULT 'Post' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;-- -- Indexes for dumped tables
-- -- Indexes for table
adsALTER TABLE
adsADD PRIMARY KEY (id), ADD KEYuser_id(user_id), ADD KEYrelated_id(related_id);-- -- Indexes for table
ad_spend_logsALTER TABLE
ad_spend_logsADD PRIMARY KEY (id), ADD KEYad_id(ad_id);-- -- Indexes for table
customersALTER TABLE
customersADD PRIMARY KEY (id);-- -- Indexes for table
driversALTER TABLE
driversADD PRIMARY KEY (id);-- -- Indexes for table
notificationsALTER TABLE
notificationsADD PRIMARY KEY (id), ADD KEYuser_id(user_id), ADD KEYcreated_at(created_at);-- -- Indexes for table
ordersALTER TABLE
ordersADD PRIMARY KEY (id), ADD KEYcustomer_id(customer_id), ADD KEYidx_orders_customer_id(customer_id);-- -- Indexes for table
order_itemsALTER TABLE
order_itemsADD PRIMARY KEY (id), ADD KEYorder_id(order_id), ADD KEYproduct_id(product_id), ADD KEYidx_order_items_order_id(order_id), ADD KEYidx_order_items_product_id(product_id);-- -- Indexes for table
productsALTER TABLE
productsADD PRIMARY KEY (id);-- -- Indexes for table
usersALTER TABLE
usersADD PRIMARY KEY (id), ADD UNIQUE KEYusername(username);-- -- Indexes for table
workspace_notesALTER TABLE
workspace_notesADD PRIMARY KEY (id), ADD KEYuser_id(user_id);-- -- Indexes for table
workspace_plansALTER TABLE
workspace_plansADD PRIMARY KEY (id), ADD KEYuser_id(user_id);-- -- Indexes for table
workspace_postsALTER TABLE
workspace_postsADD PRIMARY KEY (id), ADD KEYuser_id(user_id);-- -- AUTO_INCREMENT for dumped tables
-- -- AUTO_INCREMENT for table
adsALTER TABLE
adsMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
ad_spend_logsALTER TABLE
ad_spend_logsMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
customersALTER TABLE
customersMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
driversALTER TABLE
driversMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
notificationsALTER TABLE
notificationsMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
ordersALTER TABLE
ordersMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
order_itemsALTER TABLE
order_itemsMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
productsALTER TABLE
productsMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
usersALTER TABLE
usersMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
workspace_notesALTER TABLE
workspace_notesMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
workspace_plansALTER TABLE
workspace_plansMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- AUTO_INCREMENT for table
workspace_postsALTER TABLE
workspace_postsMODIFYidint(11) NOT NULL AUTO_INCREMENT;-- -- Constraints for dumped tables
-- -- Constraints for table
adsALTER TABLE
adsADD CONSTRAINTfk_ads_related_idFOREIGN KEY (related_id) REFERENCESworkspace_posts(id) ON DELETE CASCADE, ADD CONSTRAINTfk_ads_user_idFOREIGN KEY (user_id) REFERENCESusers(id) ON DELETE CASCADE;-- -- Constraints for table
ad_spend_logsALTER TABLE
ad_spend_logsADD CONSTRAINTfk_ad_spend_logs_ad_idFOREIGN KEY (ad_id) REFERENCESads(id) ON DELETE CASCADE;-- -- Constraints for table
notificationsALTER TABLE
notificationsADD CONSTRAINTnotifications_ibfk_1FOREIGN KEY (user_id) REFERENCESusers(id) ON DELETE CASCADE;-- -- Constraints for table
ordersALTER TABLE
ordersADD CONSTRAINTfk_orders_customer_idFOREIGN KEY (customer_id) REFERENCEScustomers(id) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINTorders_ibfk_1FOREIGN KEY (customer_id) REFERENCEScustomers(id) ON DELETE CASCADE;-- -- Constraints for table
order_itemsALTER TABLE
order_itemsADD CONSTRAINTfk_order_items_order_idFOREIGN KEY (order_id) REFERENCESorders(id) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINTfk_order_items_product_idFOREIGN KEY (product_id) REFERENCESproducts(id) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINTorder_items_ibfk_1FOREIGN KEY (order_id) REFERENCESorders(id) ON DELETE CASCADE, ADD CONSTRAINTorder_items_ibfk_2FOREIGN KEY (product_id) REFERENCESproducts(id) ON DELETE CASCADE;-- -- Constraints for table
workspace_notesALTER TABLE
workspace_notesADD CONSTRAINTfk_workspace_notes_user_idFOREIGN KEY (user_id) REFERENCESusers(id) ON DELETE CASCADE;-- -- Constraints for table
workspace_plansALTER TABLE
workspace_plansADD CONSTRAINTfk_workspace_plans_user_idFOREIGN KEY (user_id) REFERENCESusers(id) ON DELETE CASCADE;-- -- Constraints for table
workspace_postsALTER TABLE
workspace_postsADD CONSTRAINTfk_workspace_posts_user_idFOREIGN KEY (user_id) REFERENCESusers(id) ON DELETE CASCADE; COMMIT;/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /; /!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /; /!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;) i want make total kd based on paid or not, and amke it cool deisg nad nd on't ermeove header and type full codes and amke it cool
- Assistant
Sure! I'll update your
dashboard.phpto calculate the total KD based on whether orders are paid or not. Additionally, I'll enhance the design to align with the modern and clean aesthetic you've described. The updated code will maintain the existing structure and header while incorporating the requested changes.
Key Updates:
-
Total KD Based on Payment Status:
- Total Paid Sales: Calculates the total sales from orders that are marked as paid (
is_paid = 1) and have a status of 'Completed' or 'Delivered'. - Total Unpaid Sales: Calculates the total sales from orders that are not paid (
is_paid = 0) and have a status of 'Completed' or 'Delivered'.
- Total Paid Sales: Calculates the total sales from orders that are marked as paid (
-
Design Enhancements:
- Color Palette: Updated CSS variables to reflect a soothing teal hue as the primary color, complemented by neutral backgrounds and accent colors.
- Typography: Utilized clean sans-serif fonts for better readability.
- Responsive Design: Enhanced responsiveness for various screen sizes, ensuring a consistent user experience across devices.
- Interactive Elements: Improved button styles with hover effects and smoother transitions.
- Scrollbar Customization: Styled scrollbars to align with the overall aesthetic.
- Additional Styling: Enhanced elements like badges, tables, and statistics cards for a more polished look.
Updated
dashboard.php:<?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(); require_once '../includes/header.php'; // Include authentication and database connection first require_once '../includes/auth.php'; require_once '../includes/db_connect.php'; // Function to sanitize input function sanitize_input($input) { return htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8'); } /** * 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; // In Progress Orders $inProgressOrdersSql = "SELECT COUNT(*) AS total FROM orders WHERE status = 'In Progress'"; $inProgressOrdersResult = $conn->query($inProgressOrdersSql); $inProgressOrders = ($inProgressOrdersResult && $row = $inProgressOrdersResult->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 Paid Sales from Completed and Delivered Orders considering discounts $totalPaidSalesSql = " SELECT SUM(p.price * oi.quantity * (1 - (oi.discount_percentage / 100))) AS total_paid_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') AND o.is_paid = 1 "; $totalPaidSalesResult = $conn->query($totalPaidSalesSql); $totalPaidSales = ($totalPaidSalesResult && $row = $totalPaidSalesResult->fetch_assoc()) ? (float)$row['total_paid_sales'] : 0.00; // Total Unpaid Sales from Completed and Delivered Orders considering discounts $totalUnpaidSalesSql = " SELECT SUM(p.price * oi.quantity * (1 - (oi.discount_percentage / 100))) AS total_unpaid_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') AND o.is_paid = 0 "; $totalUnpaidSalesResult = $conn->query($totalUnpaidSalesSql); $totalUnpaidSales = ($totalUnpaidSalesResult && $row = $totalUnpaidSalesResult->fetch_assoc()) ? (float)$row['total_unpaid_sales'] : 0.00; // Total Delivery Fees from Completed and Delivered Orders $totalDeliveryFeesSql = " SELECT SUM(delivery_fee) AS total_fees FROM orders WHERE status IN ('Completed', 'Delivered') AND is_paid = 1 "; $totalDeliveryFeesResult = $conn->query($totalDeliveryFeesSql); $totalDeliveryFees = ($totalDeliveryFeesResult && $row = $totalDeliveryFeesResult->fetch_assoc()) ? (float)$row['total_fees'] : 0.00; // Total Revenue (Paid Sales + Delivery Fees) $totalRevenue = $totalPaidSales + $totalDeliveryFees; /** * 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, o.delivery_fee, o.is_paid, p.name AS product_name, p.price AS product_price, oi.quantity, oi.discount_percentage 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'], 'delivery_fee' => $row['delivery_fee'], 'is_paid' => $row['is_paid'], 'products' => [], 'total_order_amount' => 0.00 ]; } // Calculate total for each product $productTotal = $row['product_price'] * $row['quantity'] * (1 - ($row['discount_percentage'] / 100)); $recentOrders[$order_id]['products'][] = [ 'product_name' => $row['product_name'], 'quantity' => $row['quantity'], 'discount_percentage' => $row['discount_percentage'], 'total' => $productTotal ]; // Add to total order amount $recentOrders[$order_id]['total_order_amount'] += $productTotal; } // After processing products, add delivery_fee to total_order_amount foreach ($recentOrders as &$order) { $order['total_order_amount'] += $order['delivery_fee']; } // 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 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: #20B2AA; /* Soothing Teal */ --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; } /* Custom scrollbar for better UX */ ::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-track { background: #f1f5f9; /* Tailwind's gray-100 */ } ::-webkit-scrollbar-thumb { background: #4b6584; /* Teal-500 */ border-radius: 4px; } ::-webkit-scrollbar-thumb:hover { background: #0d9488; /* Teal-600 */ } /* --------------------------------------------------- 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; overflow: hidden; } .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.in-progress { background-color: var(--db-badge-in-progress); } /* Purple */ .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.delivery { background-color: var(--db-accent-teal); } /* Teal */ .db-stat-icon.revenue { background-color: var(--db-accent-purple); } /* Purple */ .db-stat-icon.paid-sales { background-color: var(--db-accent-green); } /* Green */ .db-stat-icon.unpaid-sales { background-color: var(--db-accent-orange); } /* Orange */ .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); } .db-badge-status-paid { background-color: var(--db-accent-green); 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-unpaid { background-color: var(--db-accent-orange); 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, users, 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> <!-- In Progress Orders --> <div class="db-stat-card"> <div class="db-stat-icon in-progress"> <i class="bi bi-arrow-repeat"></i> </div> <div class="db-stat-info"> <h5>In Progress</h5> <p><?= number_format($inProgressOrders) ?></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-flatbed"></i> </div> <div class="db-stat-info"> <h5>Delivered Orders</h5> <p><?= number_format($deliveredOrders) ?></p> </div> </div> <!-- Total Paid Sales --> <div class="db-stat-card"> <div class="db-stat-icon paid-sales"> <i class="bi bi-cash-stack"></i> </div> <div class="db-stat-info"> <h5>Total Paid Sales (KD)</h5> <p><?= number_format($totalPaidSales, 2) ?></p> </div> </div> <!-- Total Unpaid Sales --> <div class="db-stat-card"> <div class="db-stat-icon unpaid-sales"> <i class="bi bi-wallet2"></i> </div> <div class="db-stat-info"> <h5>Total Unpaid Sales (KD)</h5> <p><?= number_format($totalUnpaidSales, 2) ?></p> </div> </div> <!-- Total Delivery Fees --> <div class="db-stat-card"> <div class="db-stat-icon delivery"> <i class="bi bi-truck-flatbed-fill"></i> </div> <div class="db-stat-info"> <h5>Total Delivery Fees (KD)</h5> <p><?= number_format($totalDeliveryFees, 2) ?></p> </div> </div> <!-- Total Revenue --> <div class="db-stat-card"> <div class="db-stat-icon revenue"> <i class="bi bi-graph-up-arrow"></i> </div> <div class="db-stat-info"> <h5>Total Revenue (KD)</h5> <p><?= number_format($totalRevenue, 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="/public/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>Delivery Fee (KD)</th> <th>Total Amount (KD)</th> <th>Status</th> <th>Payment 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 => $product) { echo '<div>' . htmlspecialchars($product['product_name'], ENT_QUOTES, 'UTF-8') . ' (x' . htmlspecialchars($product['quantity'], ENT_QUOTES, 'UTF-8') . ') - ' . htmlspecialchars($product['discount_percentage'], ENT_QUOTES, 'UTF-8') . '% OFF</div>'; if ($index < count($order['products']) - 1) { echo '<hr class="db-product-line">'; } } } else { echo 'No products.'; } ?> </td> <td><?= number_format($order['delivery_fee'], 2) ?></td> <td><?= number_format($order['total_order_amount'], 2) ?></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> <?php if ($order['is_paid'] == 1) { echo '<span class="db-badge-status-paid">Paid</span>'; } else { echo '<span class="db-badge-status-unpaid">Unpaid</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="11" 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"> © <?= date("Y") ?> 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 ?>
Detailed Changes Explained:
-
Database Query Updates:
- Total Paid Sales (
$totalPaidSales):WHERE o.status IN ('Completed', 'Delivered') AND o.is_paid = 1- Fetches the sum of sales from orders that are both completed/delivered and marked as paid.
- Total Unpaid Sales (
$totalUnpaidSales):WHERE o.status IN ('Completed', 'Delivered') AND o.is_paid = 0- Fetches the sum of sales from orders that are completed/delivered but not yet paid.
- Total Delivery Fees (
$totalDeliveryFees):- Now only includes delivery fees from paid orders.
- Total Revenue (
$totalRevenue):- Calculated as the sum of total paid sales and total delivery fees.
- Total Paid Sales (
-
Statistics Cards:
- Added Two New Cards:
- Total Paid Sales (KD): Displays
<?= number_format($totalPaidSales, 2) ?> - Total Unpaid Sales (KD): Displays
<?= number_format($totalUnpaidSales, 2) ?>
- Total Paid Sales (KD): Displays
- Icon Updates:
- Added respective icons for paid (
bi bi-cash-stack) and unpaid (bi bi-wallet2) sales.
- Added respective icons for paid (
- CSS Variables:
- Added new CSS variables for the paid and unpaid sales icons to ensure consistent coloring.
- Added Two New Cards:
-
Recent Orders Table:
- Additional Column: Added "Payment Status" to indicate whether an order is paid or unpaid.
- Badge Implementation:
- Displays a green badge for paid orders and an orange badge for unpaid orders.
- Enhanced Styling:
- Adjusted padding and font sizes for better readability.
-
Design Enhancements:
- Color Palette:
- Primary accent color updated to a soothing teal (
#20B2AA). - Added new accent colors for paid (green) and unpaid (orange) statuses.
- Primary accent color updated to a soothing teal (
- Typography:
- Ensured consistency in font families (
InterandRoboto) and weights across different sections.
- Ensured consistency in font families (
- Responsive Design:
- Improved responsiveness for tables and statistics cards, ensuring they adapt gracefully to various screen sizes.
- Interactive Elements:
- Enhanced button hover effects with gradient overlays and smoother transitions.
- Scrollbar Customization:
- Styled scrollbars to be subtle yet aligned with the overall color scheme.
- Color Palette:
-
Additional Features:
- Payment Status in Recent Orders:
- Clearly indicates the payment status of each order for quick reference.
- Consistent Styling for Badges:
- Ensured all badges (status and payment) have a uniform look with rounded corners and subtle shadows.
- Payment Status in Recent Orders:
Final Notes:
-
Security Considerations:
- While the current code uses basic sanitization (
htmlspecialchars), consider implementing more robust security measures like prepared statements to prevent SQL injection, especially if user input is involved.
- While the current code uses basic sanitization (
-
Performance Optimizations:
- For larger datasets, implement pagination or lazy loading for recent orders to enhance performance.
-
Further Enhancements:
- Integrate charts or graphs to visualize sales data and order statuses for a more comprehensive dashboard experience.
- Implement real-time updates using AJAX or WebSockets for dynamic data presentation.
This updated
dashboard.phpshould provide a more insightful and visually appealing dashboard, aligning with your design preferences and functional requirements. -