Appearance
Admin Dashboard Charts
Flow ID: SY-21 | Module(s): application (core) | Complexity: Medium Last Updated: 2026-04-04
Business Context
The admin dashboard provides real-time and period-based business intelligence charts for store administrators. When an admin logs in, the dashboard home page loads a set of AJAX-powered charts showing key performance metrics: daily turnover, order counts, payment method distribution, popular products, vendor performance, category performance, and live operational stats.
All chart data endpoints are AJAX-only (checking is_ajax_request()) and return JSON for rendering by the frontend JavaScript charting library. The dashboard supports date range filtering to analyze specific periods.
API Reference
REST Endpoints
No REST API. Dashboard charts are served via legacy AJAX endpoints.
Legacy Admin Routes
| Route | Controller | Method | HTTP | Description |
|---|---|---|---|---|
adminrun/eshopAdminCharts | Adminrun | eshopAdminCharts | POST (AJAX) | Main charts: turnover, orders, payment methods, popular products |
adminrun/dashboardLive | Adminrun | dashboardLive | POST (AJAX) | Live dashboard stats (today's orders, revenue, customers) |
adminrun/vendorschart | Adminrun | vendorschart | POST (AJAX) | Vendor sales comparison (current vs. previous year) |
adminrun/productschart | Adminrun | productschart | POST (AJAX) | Product-level sales breakdown |
adminrun/vendorproductschart | Adminrun | vendorproductschart | POST (AJAX) | Products within a specific vendor |
adminrun/categorieschart | Adminrun | categorieschart | POST (AJAX) | Category-level sales breakdown |
adminrun/categoriesproductschart | Adminrun | categoriesproductschart | POST (AJAX) | Products within a specific category |
All endpoints accept POST parameters: date_start, date_end. If not provided, default to current month (from 1st of month to today).
Code Flow
Main Charts (eshopAdminCharts)
- Dashboard page loads and fires an AJAX POST to
adminrun/eshopAdminCharts. eshopAdminCharts()validates the request is AJAX.- Merges results from four sub-methods:
turnoversWithVatChart(): Groups orders by day, sumstotal_vatper day. Returns{ labels: ["2026-04-01",...], total: [1234.56,...] }.turnovers(): Aggregates period totals:turnover(net) andturnoverVat(with VAT).ordersChart(): Groups orders by day, counts orders per day. Returns{ labels: [...], total: [...] }.payWayPie(): Groups orders bypayway, counts per payment method. Returns{ payway: { count, label, color } }where color is auto-generated from the payway string.popularProducts(): Joinsshop_order_basketwithproduct_codesandshop_product_mui, groups by product, orders by sell count DESC. Returns top 100 products with{ name, count }.
- All queries exclude orders with status
CANCELED,PENDING, orRETURN. - Returns combined JSON with
JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODEflags.
Live Dashboard (dashboardLive)
- AJAX POST to
adminrun/dashboardLive. - Merges three sub-methods:
dashboardLiveDaysData(): Detailed breakdown of today's orders -- total with VAT, guest vs. signed-up revenue, last-hour orders, unique customers, phone orders, orders to send, orders to send to stores, etc.dashboardLiveMonthData(): Current month aggregates.dashboardLiveExtraData(): Additional live metrics.
- All queries run against
shop_orderjoined withshop_customerfor customer type classification.
Vendor Charts (vendorschart)
- AJAX POST with
date_start,date_end. - Loads
reporting_modelandvendors_model. - Fetches current period and previous year same period vendor sales via
reporting_model::getVendorsSalesForPeriod(). - For each vendor: calculates
qty,subtotal,subtotal_percent,old_subtotal,old_percent(year-over-year comparison). - Returns top 15 vendors as bar chart data + "Others" aggregate, plus full vendor table data.
Product Charts (productschart)
- AJAX POST with date filters.
- Uses
order_basket_model::getReportingData()to fetch per-product sales. - Aggregates by product ID, calculates
qty,subtotal,qty_percent,subtotal_percent. - Sorts by subtotal descending. Returns top 15 for bar chart + full table.
Category Charts (categorieschart, categoriesproductschart)
- Similar pattern to product charts but joins category data.
categorieschart: Aggregates sales by product category.categoriesproductschart: Drills into a specific category (passed ascat_idPOST param) to show per-product breakdown within that category.
Domain Layer
No modern domain layer. Dashboard charts are a pure legacy application controller feature.
Architecture
| Component | Path | Purpose |
|---|---|---|
Adminrun | application/controllers/Adminrun.php | Main dashboard controller (~1,376 lines) |
order_basket_model | ecommercen/eshop/models/ | Order basket reporting queries |
reporting_model | ecommercen/eshop/models/ | Vendor/period sales aggregation |
vendors_model | ecommercen/eshop/models/ | Vendor list for chart labels |
| Frontend JS | public/ui/admin/js/dashboard.js | Chart rendering (Chart.js or similar) |
| Routes | application/config/routes.php:545-546 | adminrun/(.+) -> adminrun/$1 |
Data Model
This flow reads from (does not own):
| Table | Purpose |
|---|---|
shop_order | Order data: entry_datetime, total, total_vat, status, payway, customer_id, store_id, sent_date_time |
shop_order_basket | Order line items: product_code_id, price, qty |
product_codes | Product code to product mapping |
shop_product / shop_product_mui | Product names and prices |
shop_vendor / shop_vendor_mui | Vendor names |
shop_product_category_lp / shop_product_category_mui | Category mappings and names |
shop_customer | Customer guest/registered status |
Configuration
No registry keys or config files specific to dashboard charts. Chart behavior is controlled entirely by the date range parameters.
Status exclusions: All chart queries exclude orders with status CANCELED, PENDING, or RETURN (hardcoded).
Client Extension Points
- Override controller: Extend
Adminruninapplication/controllers/to add custom chart endpoints or modify existing ones. - Custom chart data: Override individual methods like
turnoversWithVatChart(),vendorschart(), etc. - Additional charts: Add new AJAX endpoints to
Adminrunand corresponding frontend components.
Business Rules
- AJAX-only: All chart endpoints check
is_ajax_request()and return empty data for non-AJAX requests. - Default date range: If no dates provided, defaults to current month (1st to today).
- Status exclusion: Orders with status
CANCELED,PENDING, orRETURNare excluded from all metrics. - Year-over-year: Vendor charts compare the selected period to the same period one year prior.
- Top N + Others: Vendor and product charts show top 15 items in bar charts, with remaining items aggregated as "Others" (labeled "Ypollipoi" in Greek).
- Color generation: Payment method pie chart colors are auto-generated from the payway string using
genColorCodeFromString(). - Live stats:
dashboardLiveprovides real-time metrics for the current day including last-hour order counts.
Related Flows
- AD-03 Order Management Admin -- Order data that feeds the charts
- AD-10 Reporting -- Detailed reporting module with export capabilities
- AD-19 Vendor Management -- Vendor data referenced in vendor charts