📁 File Manager
Editing:
/home/wvl7mof7402e/public_html/chem/admin/dashboard.php
<?php /** * Pure Chemical - Admin Dashboard * File: /admin/dashboard.php * * Premium Modern Dashboard * * Database driven: * - Products * - Categories * - Industries * - Services * - Brands * - Pages * - Blog Posts * - Enquiries * - Media * - Testimonials * - FAQs * * No dummy website data is inserted. */ declare(strict_types=1); /* |-------------------------------------------------------------------------- | Session |-------------------------------------------------------------------------- */ if (session_status() !== PHP_SESSION_ACTIVE) { session_start(); } /* |-------------------------------------------------------------------------- | Database |-------------------------------------------------------------------------- */ $pdo = null; require_once __DIR__ . '/includes/db.php'; if (!$pdo instanceof PDO) { error_log('Dashboard error: Database connection is not available.'); } /* |-------------------------------------------------------------------------- | Authentication |-------------------------------------------------------------------------- */ if ( empty($_SESSION['admin_id']) || empty($_SESSION['admin_logged_in']) ) { header('Location: login.php'); exit; } /* |-------------------------------------------------------------------------- | Page Settings |-------------------------------------------------------------------------- */ $page_title = 'Dashboard'; $active_menu = 'dashboard'; /* |-------------------------------------------------------------------------- | Helper: Safe Count |-------------------------------------------------------------------------- | | If a table exists -> returns actual count. | If table doesn't exist -> returns 0. | */ function dashboard_count(?PDO $pdo, string $table): int { if (!$pdo instanceof PDO) { error_log('Dashboard count error: Database connection is not available for table ' . $table); return 0; } /* * Table names cannot be bound with PDO placeholders. * Only internal hardcoded table names are passed to this function. */ try { $allowed_tables = [ 'products', 'categories', 'industries', 'services', 'brands', 'pages', 'blog_posts', 'enquiries', 'media', 'testimonials', 'faqs', 'galleries', 'documents', 'menus', ]; if (!in_array($table, $allowed_tables, true)) { return 0; } $statement = $pdo->query( "SELECT COUNT(*) FROM `{$table}`" ); return (int) $statement->fetchColumn(); } catch (Throwable $e) { error_log( 'Dashboard count error: ' . $table . ' - ' . $e->getMessage() ); return 0; } } /* |-------------------------------------------------------------------------- | Helper: Status Count |-------------------------------------------------------------------------- */ function dashboard_status_count( ?PDO $pdo, string $table, string $status = '1' ): int { if (!$pdo instanceof PDO) { error_log('Dashboard status count error: Database connection is not available for table ' . $table); return 0; } try { $allowed_tables = [ 'products', 'categories', 'industries', 'services', 'brands', 'pages', 'blog_posts', 'enquiries', 'media', 'testimonials', 'faqs', 'galleries', 'documents', 'menus', ]; if (!in_array($table, $allowed_tables, true)) { return 0; } /* * Status columns are not guaranteed to be identical * across every existing table. * * This helper therefore checks whether a status * column exists before querying it. */ $columnCheck = $pdo->prepare( " SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = 'status' " ); $columnCheck->execute([$table]); if ((int) $columnCheck->fetchColumn() === 0) { return dashboard_count($pdo, $table); } $statement = $pdo->prepare( "SELECT COUNT(*) FROM `{$table}` WHERE `status` = ?" ); $statement->execute([$status]); return (int) $statement->fetchColumn(); } catch (Throwable $e) { error_log( 'Dashboard status count error: ' . $table . ' - ' . $e->getMessage() ); return 0; } } /* |-------------------------------------------------------------------------- | Dashboard Statistics |-------------------------------------------------------------------------- */ $stats = [ 'products' => dashboard_count( $pdo, 'products' ), 'categories' => dashboard_count( $pdo, 'categories' ), 'industries' => dashboard_count( $pdo, 'industries' ), 'services' => dashboard_count( $pdo, 'services' ), 'brands' => dashboard_count( $pdo, 'brands' ), 'pages' => dashboard_count( $pdo, 'pages' ), 'blog_posts' => dashboard_count( $pdo, 'blog_posts' ), 'enquiries' => dashboard_count( $pdo, 'enquiries' ), 'media' => dashboard_count( $pdo, 'media' ), 'testimonials' => dashboard_count( $pdo, 'testimonials' ), 'faqs' => dashboard_count( $pdo, 'faqs' ), 'galleries' => dashboard_count( $pdo, 'galleries' ), 'documents' => dashboard_count( $pdo, 'documents' ), 'menus' => dashboard_count( $pdo, 'menus' ), ]; /* |-------------------------------------------------------------------------- | Active Statistics |-------------------------------------------------------------------------- */ $active_products = dashboard_status_count( $pdo, 'products' ); $active_services = dashboard_status_count( $pdo, 'services' ); $active_industries = dashboard_status_count( $pdo, 'industries' ); $active_blog_posts = dashboard_status_count( $pdo, 'blog_posts' ); /* |-------------------------------------------------------------------------- | Recent Products |-------------------------------------------------------------------------- */ $recent_products = []; if ($pdo instanceof PDO) { try { $statement = $pdo->query( " SELECT id, name, slug, status, created_at FROM products ORDER BY id DESC LIMIT 6 " ); $recent_products = $statement instanceof PDOStatement ? $statement->fetchAll() : []; } catch (Throwable $e) { error_log( 'Dashboard recent products error: ' . $e->getMessage() ); } } else { error_log('Dashboard recent products error: Database connection is not available.'); } /* |-------------------------------------------------------------------------- | Recent Enquiries |-------------------------------------------------------------------------- */ $recent_enquiries = []; if ($pdo instanceof PDO) { try { /* * Fetch only columns that are expected to exist * in the existing enquiries table. * * If schema differs, dashboard safely falls back. */ $statement = $pdo->query( " SELECT * FROM enquiries ORDER BY id DESC LIMIT 5 " ); $recent_enquiries = $statement instanceof PDOStatement ? $statement->fetchAll() : []; } catch (Throwable $e) { error_log( 'Dashboard recent enquiries error: ' . $e->getMessage() ); } } else { error_log('Dashboard recent enquiries error: Database connection is not available.'); } /* |-------------------------------------------------------------------------- | Recent Blog Posts |-------------------------------------------------------------------------- */ $recent_blog_posts = []; if ($pdo instanceof PDO) { try { $statement = $pdo->query( " SELECT id, title, slug, status, created_at FROM blog_posts ORDER BY id DESC LIMIT 5 " ); $recent_blog_posts = $statement instanceof PDOStatement ? $statement->fetchAll() : []; } catch (Throwable $e) { error_log( 'Dashboard recent blog error: ' . $e->getMessage() ); } } else { error_log('Dashboard recent blog error: Database connection is not available.'); } /* |-------------------------------------------------------------------------- | Load Sidebar + Header |-------------------------------------------------------------------------- */ require_once __DIR__ . '/sidebar.php'; require_once __DIR__ . '/header.php'; ?> <style> /* ========================================================= DASHBOARD ========================================================= */ .dashboard-page { width: 100%; } /* ========================================================= WELCOME HEADER ========================================================= */ .dashboard-welcome { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 25px; padding: 27px 29px; margin-bottom: 22px; border-radius: 18px; background: radial-gradient( circle at 85% 10%, rgba(255,255,255,.17), transparent 25% ), linear-gradient( 110deg, #172554 0%, #1e40af 48%, #4338ca 100% ); color: #fff; box-shadow: 0 14px 35px rgba(30,64,175,.18); } .dashboard-welcome::after { content: ""; position: absolute; width: 210px; height: 210px; right: -70px; bottom: -120px; border-radius: 50%; border: 35px solid rgba(255,255,255,.06); } .dashboard-welcome-content { position: relative; z-index: 2; } .dashboard-welcome-label { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 8px; color: rgba(255,255,255,.62); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; } .dashboard-welcome-label span { width: 6px; height: 6px; border-radius: 50%; background: #60a5fa; box-shadow: 0 0 0 4px rgba(96,165,250,.12); } .dashboard-welcome-title { margin: 0; font-size: 25px; font-weight: 800; letter-spacing: -.7px; } .dashboard-welcome-text { margin-top: 5px; color: rgba(255,255,255,.65); font-size: 12px; } .dashboard-welcome-action { position: relative; z-index: 2; flex-shrink: 0; } .dashboard-site-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 15px; border: 1px solid rgba(255,255,255,.17); border-radius: 10px; background: rgba(255,255,255,.10); color: #fff; font-size: 11px; font-weight: 700; backdrop-filter: blur(10px); transition: all .2s ease; } .dashboard-site-btn:hover { background: rgba(255,255,255,.18); transform: translateY(-1px); } /* ========================================================= STAT GRID ========================================================= */ .dashboard-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; } .dashboard-stat-card { position: relative; overflow: hidden; padding: 19px; background: #fff; border: 1px solid #e5e7eb; border-radius: 15px; box-shadow: 0 7px 25px rgba(15,23,42,.045); transition: transform .2s ease, box-shadow .2s ease; } .dashboard-stat-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(15,23,42,.08); } .dashboard-stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; } .dashboard-stat-icon { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; border-radius: 11px; font-size: 14px; } .stat-blue .dashboard-stat-icon { color: #2563eb; background: #eff6ff; } .stat-purple .dashboard-stat-icon { color: #7c3aed; background: #f5f3ff; } .stat-green .dashboard-stat-icon { color: #16a34a; background: #f0fdf4; } .stat-orange .dashboard-stat-icon { color: #ea580c; background: #fff7ed; } .dashboard-stat-label { margin-top: 15px; color: #64748b; font-size: 11px; font-weight: 600; } .dashboard-stat-number { margin-top: 2px; color: #0f172a; font-size: 25px; line-height: 1.2; font-weight: 800; letter-spacing: -.7px; } .dashboard-stat-link { display: inline-flex; align-items: center; gap: 5px; margin-top: 11px; color: #64748b; font-size: 10px; font-weight: 700; } .dashboard-stat-link:hover { color: #2563eb; } .dashboard-stat-decoration { position: absolute; width: 95px; height: 95px; right: -42px; bottom: -45px; border-radius: 50%; border: 18px solid rgba(37,99,235,.035); } /* ========================================================= SECTION HEADER ========================================================= */ .dashboard-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin-bottom: 13px; } .dashboard-section-title { color: #0f172a; font-size: 14px; font-weight: 800; } .dashboard-section-description { margin-top: 2px; color: #94a3b8; font-size: 10px; } .dashboard-section-link { color: #2563eb; font-size: 10px; font-weight: 700; } /* ========================================================= QUICK ACTIONS ========================================================= */ .dashboard-quick-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 23px; } .dashboard-quick-card { display: flex; align-items: center; gap: 11px; min-height: 67px; padding: 12px 13px; border: 1px solid #e5e7eb; border-radius: 13px; background: #fff; box-shadow: 0 5px 20px rgba(15,23,42,.035); transition: all .2s ease; } .dashboard-quick-card:hover { border-color: #bfdbfe; transform: translateY(-2px); box-shadow: 0 10px 25px rgba(37,99,235,.08); } .dashboard-quick-icon { width: 38px; height: 38px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: #eff6ff; color: #2563eb; font-size: 12px; } .dashboard-quick-title { color: #172033; font-size: 11px; font-weight: 700; } .dashboard-quick-text { margin-top: 2px; color: #94a3b8; font-size: 9px; } /* ========================================================= TWO COLUMN ========================================================= */ .dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 17px; margin-bottom: 22px; } .dashboard-panel { overflow: hidden; background: #fff; border: 1px solid #e5e7eb; border-radius: 15px; box-shadow: 0 7px 25px rgba(15,23,42,.045); } .dashboard-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 16px 18px; border-bottom: 1px solid #eef2f7; } .dashboard-panel-heading { display: flex; align-items: center; gap: 10px; } .dashboard-panel-icon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 9px; background: #eff6ff; color: #2563eb; font-size: 11px; } .dashboard-panel-title { color: #172033; font-size: 12px; font-weight: 800; } .dashboard-panel-subtitle { margin-top: 1px; color: #94a3b8; font-size: 9px; } .dashboard-panel-link { color: #2563eb; font-size: 10px; font-weight: 700; } /* ========================================================= TABLE ========================================================= */ .dashboard-table-wrap { overflow-x: auto; } .dashboard-table { width: 100%; border-collapse: collapse; } .dashboard-table th { padding: 11px 17px; background: #f8fafc; color: #94a3b8; font-size: 9px; font-weight: 800; text-align: left; text-transform: uppercase; letter-spacing: .45px; white-space: nowrap; } .dashboard-table td { padding: 12px 17px; border-top: 1px solid #f1f5f9; color: #475569; font-size: 10px; white-space: nowrap; } .dashboard-product-name { display: block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; color: #172033; font-size: 11px; font-weight: 700; } .dashboard-product-slug { display: block; max-width: 230px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; color: #94a3b8; font-size: 9px; } /* ========================================================= STATUS ========================================================= */ .dashboard-status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 20px; font-size: 8px; font-weight: 800; } .dashboard-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; } .dashboard-status-active { color: #166534; background: #dcfce7; } .dashboard-status-active::before { background: #22c55e; } .dashboard-status-inactive { color: #991b1b; background: #fee2e2; } .dashboard-status-inactive::before { background: #ef4444; } /* ========================================================= EMPTY STATE ========================================================= */ .dashboard-empty { padding: 38px 20px; text-align: center; } .dashboard-empty-icon { width: 42px; height: 42px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #f8fafc; color: #94a3b8; font-size: 13px; } .dashboard-empty-title { color: #475569; font-size: 11px; font-weight: 700; } .dashboard-empty-text { margin-top: 3px; color: #94a3b8; font-size: 9px; } /* ========================================================= SYSTEM OVERVIEW ========================================================= */ .dashboard-overview-list { padding: 5px 18px 14px; } .dashboard-overview-item { padding: 12px 0; border-bottom: 1px solid #f1f5f9; } .dashboard-overview-item:last-child { border-bottom: 0; } .dashboard-overview-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; } .dashboard-overview-name { color: #475569; font-size: 10px; font-weight: 600; } .dashboard-overview-value { color: #172033; font-size: 11px; font-weight: 800; } .dashboard-progress { width: 100%; height: 5px; overflow: hidden; border-radius: 20px; background: #f1f5f9; } .dashboard-progress-bar { height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient( 90deg, #2563eb, #6366f1 ); transition: width .6s ease; } /* ========================================================= RESPONSIVE ========================================================= */ @media (max-width: 1200px) { .dashboard-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dashboard-quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dashboard-columns { grid-template-columns: 1fr; } } @media (max-width: 640px) { .dashboard-welcome { padding: 21px; align-items: flex-start; flex-direction: column; } .dashboard-welcome-title { font-size: 21px; } .dashboard-stat-grid { grid-template-columns: 1fr; } .dashboard-quick-grid { grid-template-columns: 1fr; } .dashboard-site-btn { width: 100%; justify-content: center; } .dashboard-table th, .dashboard-table td { padding: 10px 12px; } } </style> <div class="dashboard-page"> <!-- ===================================================== WELCOME ====================================================== --> <section class="dashboard-welcome"> <div class="dashboard-welcome-content"> <div class="dashboard-welcome-label"> <span></span> Admin Control Center </div> <h1 class="dashboard-welcome-title"> Welcome back, <?= htmlspecialchars( $_SESSION['admin_name'] ?? 'Administrator', ENT_QUOTES, 'UTF-8' ); ?> </h1> <p class="dashboard-welcome-text"> Manage your Pure Chemical website, content and business data from one place. </p> </div> <div class="dashboard-welcome-action"> <a href="../" target="_blank" rel="noopener noreferrer" class="dashboard-site-btn" > <i class="fa-solid fa-arrow-up-right-from-square"></i> View Website </a> </div> </section> <!-- ===================================================== MAIN STATISTICS ====================================================== --> <div class="dashboard-stat-grid"> <!-- Products --> <div class="dashboard-stat-card stat-blue"> <div class="dashboard-stat-top"> <div class="dashboard-stat-icon"> <i class="fa-solid fa-boxes-stacked"></i> </div> </div> <div class="dashboard-stat-label"> Total Products </div> <div class="dashboard-stat-number"> <?= number_format( $stats['products'] ); ?> </div> <a href="products/index.php" class="dashboard-stat-link" > Manage Products <i class="fa-solid fa-arrow-right"></i> </a> <div class="dashboard-stat-decoration"></div> </div> <!-- Industries --> <div class="dashboard-stat-card stat-purple"> <div class="dashboard-stat-top"> <div class="dashboard-stat-icon"> <i class="fa-solid fa-industry"></i> </div> </div> <div class="dashboard-stat-label"> Industries </div> <div class="dashboard-stat-number"> <?= number_format( $stats['industries'] ); ?> </div> <a href="industries/index.php" class="dashboard-stat-link" > Manage Industries <i class="fa-solid fa-arrow-right"></i> </a> <div class="dashboard-stat-decoration"></div> </div> <!-- Services --> <div class="dashboard-stat-card stat-green"> <div class="dashboard-stat-top"> <div class="dashboard-stat-icon"> <i class="fa-solid fa-handshake"></i> </div> </div> <div class="dashboard-stat-label"> Services </div> <div class="dashboard-stat-number"> <?= number_format( $stats['services'] ); ?> </div> <a href="services/index.php" class="dashboard-stat-link" > Manage Services <i class="fa-solid fa-arrow-right"></i> </a> <div class="dashboard-stat-decoration"></div> </div> <!-- Enquiries --> <div class="dashboard-stat-card stat-orange"> <div class="dashboard-stat-top"> <div class="dashboard-stat-icon"> <i class="fa-regular fa-envelope"></i> </div> </div> <div class="dashboard-stat-label"> Enquiries </div> <div class="dashboard-stat-number"> <?= number_format( $stats['enquiries'] ); ?> </div> <a href="enquiries/index.php" class="dashboard-stat-link" > View Enquiries <i class="fa-solid fa-arrow-right"></i> </a> <div class="dashboard-stat-decoration"></div> </div> </div> <!-- ===================================================== QUICK ACTIONS ====================================================== --> <div class="dashboard-section-heading"> <div> <div class="dashboard-section-title"> Quick Actions </div> <div class="dashboard-section-description"> Frequently used content management actions </div> </div> </div> <div class="dashboard-quick-grid"> <a href="products/add.php" class="dashboard-quick-card" > <div class="dashboard-quick-icon"> <i class="fa-solid fa-plus"></i> </div> <div> <div class="dashboard-quick-title"> Add Product </div> <div class="dashboard-quick-text"> Create a new product </div> </div> </a> <a href="industries/add.php" class="dashboard-quick-card" > <div class="dashboard-quick-icon"> <i class="fa-solid fa-industry"></i> </div> <div> <div class="dashboard-quick-title"> Add Industry </div> <div class="dashboard-quick-text"> Create industry content </div> </div> </a> <a href="pages/add.php" class="dashboard-quick-card" > <div class="dashboard-quick-icon"> <i class="fa-regular fa-file-lines"></i> </div> <div> <div class="dashboard-quick-title"> Add Page </div> <div class="dashboard-quick-text"> Create a website page </div> </div> </a> <a href="blog/add.php" class="dashboard-quick-card" > <div class="dashboard-quick-icon"> <i class="fa-regular fa-pen-to-square"></i> </div> <div> <div class="dashboard-quick-title"> New Blog Post </div> <div class="dashboard-quick-text"> Publish new content </div> </div> </a> </div> <!-- ===================================================== RECENT DATA + OVERVIEW ====================================================== --> <div class="dashboard-columns"> <!-- ================================================= RECENT PRODUCTS ================================================== --> <section class="dashboard-panel"> <div class="dashboard-panel-header"> <div class="dashboard-panel-heading"> <div class="dashboard-panel-icon"> <i class="fa-solid fa-box"></i> </div> <div> <div class="dashboard-panel-title"> Recent Products </div> <div class="dashboard-panel-subtitle"> Latest product records </div> </div> </div> <a href="products/index.php" class="dashboard-panel-link" > View All </a> </div> <?php if (!empty($recent_products)): ?> <div class="dashboard-table-wrap"> <table class="dashboard-table"> <thead> <tr> <th> Product </th> <th> Status </th> <th> Created </th> </tr> </thead> <tbody> <?php foreach ( $recent_products as $product ): ?> <tr> <td> <span class="dashboard-product-name" > <?= htmlspecialchars( (string) ( $product['name'] ?? 'Untitled Product' ), ENT_QUOTES, 'UTF-8' ); ?> </span> <?php if ( !empty( $product['slug'] ) ): ?> <span class="dashboard-product-slug" > /<?= htmlspecialchars( (string) $product['slug'], ENT_QUOTES, 'UTF-8' ); ?> </span> <?php endif; ?> </td> <td> <?php $product_status = (string) ( $product['status'] ?? '0' ); ?> <?php if ( $product_status === '1' ): ?> <span class="dashboard-status dashboard-status-active" > Active </span> <?php else: ?> <span class="dashboard-status dashboard-status-inactive" > Inactive </span> <?php endif; ?> </td> <td> <?= !empty( $product['created_at'] ) ? htmlspecialchars( date( 'd M Y', strtotime( (string) $product['created_at'] ) ), ENT_QUOTES, 'UTF-8' ) : '—'; ?> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php else: ?> <div class="dashboard-empty"> <div class="dashboard-empty-icon"> <i class="fa-solid fa-box-open"></i> </div> <div class="dashboard-empty-title"> No products yet </div> <div class="dashboard-empty-text"> Products added from the admin panel will appear here. </div> </div> <?php endif; ?> </section> <!-- ================================================= SYSTEM OVERVIEW ================================================== --> <section class="dashboard-panel"> <div class="dashboard-panel-header"> <div class="dashboard-panel-heading"> <div class="dashboard-panel-icon"> <i class="fa-solid fa-chart-simple"></i> </div> <div> <div class="dashboard-panel-title"> Content Overview </div> <div class="dashboard-panel-subtitle"> Current database records </div> </div> </div> </div> <div class="dashboard-overview-list"> <!-- Categories --> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Categories </span> <span class="dashboard-overview-value"> <?= number_format( $stats['categories'] ); ?> </span> </div> <div class="dashboard-progress"> <div class="dashboard-progress-bar" style="width: <?= min( 100, $stats['categories'] * 5 ); ?>%;" ></div> </div> </div> <!-- Brands --> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Brands </span> <span class="dashboard-overview-value"> <?= number_format( $stats['brands'] ); ?> </span> </div> <div class="dashboard-progress"> <div class="dashboard-progress-bar" style="width: <?= min( 100, $stats['brands'] * 8 ); ?>%;" ></div> </div> </div> <!-- Pages --> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Pages </span> <span class="dashboard-overview-value"> <?= number_format( $stats['pages'] ); ?> </span> </div> <div class="dashboard-progress"> <div class="dashboard-progress-bar" style="width: <?= min( 100, $stats['pages'] * 5 ); ?>%;" ></div> </div> </div> <!-- Blog --> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Blog Posts </span> <span class="dashboard-overview-value"> <?= number_format( $stats['blog_posts'] ); ?> </span> </div> <div class="dashboard-progress"> <div class="dashboard-progress-bar" style="width: <?= min( 100, $stats['blog_posts'] * 5 ); ?>%;" ></div> </div> </div> <!-- Media --> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Media Files </span> <span class="dashboard-overview-value"> <?= number_format( $stats['media'] ); ?> </span> </div> <div class="dashboard-progress"> <div class="dashboard-progress-bar" style="width: <?= min( 100, $stats['media'] / 2 ); ?>%;" ></div> </div> </div> </div> </section> </div> <!-- ===================================================== RECENT BLOG + DATABASE SUMMARY ====================================================== --> <div class="dashboard-columns"> <!-- ================================================= RECENT BLOG ================================================== --> <section class="dashboard-panel"> <div class="dashboard-panel-header"> <div class="dashboard-panel-heading"> <div class="dashboard-panel-icon"> <i class="fa-regular fa-newspaper"></i> </div> <div> <div class="dashboard-panel-title"> Recent Blog Posts </div> <div class="dashboard-panel-subtitle"> Latest published content </div> </div> </div> <a href="blog/index.php" class="dashboard-panel-link" > View All </a> </div> <?php if (!empty($recent_blog_posts)): ?> <div class="dashboard-table-wrap"> <table class="dashboard-table"> <thead> <tr> <th> Title </th> <th> Status </th> <th> Date </th> </tr> </thead> <tbody> <?php foreach ( $recent_blog_posts as $post ): ?> <tr> <td> <span class="dashboard-product-name" > <?= htmlspecialchars( (string) ( $post['title'] ?? 'Untitled Post' ), ENT_QUOTES, 'UTF-8' ); ?> </span> <?php if ( !empty( $post['slug'] ) ): ?> <span class="dashboard-product-slug" > /<?= htmlspecialchars( (string) $post['slug'], ENT_QUOTES, 'UTF-8' ); ?> </span> <?php endif; ?> </td> <td> <?php if ( (string) ( $post['status'] ?? '0' ) === '1' ): ?> <span class="dashboard-status dashboard-status-active" > Active </span> <?php else: ?> <span class="dashboard-status dashboard-status-inactive" > Inactive </span> <?php endif; ?> </td> <td> <?= !empty( $post['created_at'] ) ? htmlspecialchars( date( 'd M Y', strtotime( (string) $post['created_at'] ) ), ENT_QUOTES, 'UTF-8' ) : '—'; ?> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php else: ?> <div class="dashboard-empty"> <div class="dashboard-empty-icon"> <i class="fa-regular fa-newspaper"></i> </div> <div class="dashboard-empty-title"> No blog posts yet </div> <div class="dashboard-empty-text"> Blog content added from the admin panel will appear here. </div> </div> <?php endif; ?> </section> <!-- ================================================= DATABASE SUMMARY ================================================== --> <section class="dashboard-panel"> <div class="dashboard-panel-header"> <div class="dashboard-panel-heading"> <div class="dashboard-panel-icon"> <i class="fa-solid fa-database"></i> </div> <div> <div class="dashboard-panel-title"> Database Summary </div> <div class="dashboard-panel-subtitle"> Total managed entities </div> </div> </div> </div> <div class="dashboard-overview-list"> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Products </span> <span class="dashboard-overview-value"> <?= number_format( $stats['products'] ); ?> </span> </div> </div> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Services </span> <span class="dashboard-overview-value"> <?= number_format( $stats['services'] ); ?> </span> </div> </div> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Industries </span> <span class="dashboard-overview-value"> <?= number_format( $stats['industries'] ); ?> </span> </div> </div> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Pages </span> <span class="dashboard-overview-value"> <?= number_format( $stats['pages'] ); ?> </span> </div> </div> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Media </span> <span class="dashboard-overview-value"> <?= number_format( $stats['media'] ); ?> </span> </div> </div> <div class="dashboard-overview-item"> <div class="dashboard-overview-top"> <span class="dashboard-overview-name"> Enquiries </span> <span class="dashboard-overview-value"> <?= number_format( $stats['enquiries'] ); ?> </span> </div> </div> </div> </section> </div> </div> <?php /* |-------------------------------------------------------------------------- | Footer |-------------------------------------------------------------------------- */ require_once __DIR__ . '/footer.php'; ?>
Save
Cancel