<?php

namespace Modules\Reports\Controllers;

use App\Controllers\BaseController;

class ReportsController extends BaseController
{
    public function index()
    {
        return view('Modules\Reports\Views\index', array_merge($this->baseViewData(), [
            'title'    => 'Reports',
            'sections' => $this->reportSections(),
        ]));
    }

    /**
     * @return list<array{label: string, icon: string, items: list<array{title: string, desc: string, path: string, icon: string}>}>
     */
    private function reportSections(): array
    {
        return [
            [
                'label' => 'HRM — Attendance',
                'icon'  => 'fa-fingerprint',
                'items' => [
                    [
                        'title' => 'Monthly Report',
                        'desc'  => 'Month grid of attendance by employee.',
                        'path'  => 'attendance/monthly',
                        'icon'  => 'fa-calendar-check',
                    ],
                    [
                        'title' => 'Late Arrivals',
                        'desc'  => 'Employees who checked in after shift start.',
                        'path'  => 'attendance/late',
                        'icon'  => 'fa-clock',
                    ],
                    [
                        'title' => 'Early Exits',
                        'desc'  => 'Employees who left before shift end.',
                        'path'  => 'attendance/early-exit',
                        'icon'  => 'fa-person-walking-arrow-right',
                    ],
                    [
                        'title' => 'Overtime',
                        'desc'  => 'Overtime hours recorded for the period.',
                        'path'  => 'attendance/overtime',
                        'icon'  => 'fa-business-time',
                    ],
                ],
            ],
            [
                'label' => 'HRM — Payroll',
                'icon'  => 'fa-money-check-dollar',
                'items' => [
                    [
                        'title' => 'Payroll Summary',
                        'desc'  => 'Run totals and employee lines for a pay period.',
                        'path'  => 'payroll/reports/summary',
                        'icon'  => 'fa-chart-pie',
                    ],
                    [
                        'title' => 'SIO Report',
                        'desc'  => 'Social Insurance Organisation contributions.',
                        'path'  => 'payroll/reports/sio',
                        'icon'  => 'fa-shield-halved',
                    ],
                    [
                        'title' => 'EOSB Report',
                        'desc'  => 'End-of-service benefit accruals.',
                        'path'  => 'payroll/reports/eosb',
                        'icon'  => 'fa-piggy-bank',
                    ],
                ],
            ],
            [
                'label' => 'Sales & CRM',
                'icon'  => 'fa-chart-line',
                'items' => [
                    [
                        'title' => 'Sales Performance',
                        'desc'  => 'Revenue and activity by rep and period.',
                        'path'  => 'sale/reports/sales-performance',
                        'icon'  => 'fa-chart-line',
                    ],
                    [
                        'title' => 'Lead Conversion',
                        'desc'  => 'Lead funnel and conversion rates.',
                        'path'  => 'sale/reports/lead-conversion',
                        'icon'  => 'fa-filter',
                    ],
                    [
                        'title' => 'Revenue Forecast',
                        'desc'  => 'Pipeline-weighted expected revenue.',
                        'path'  => 'sale/reports/revenue-forecast',
                        'icon'  => 'fa-chart-area',
                    ],
                    [
                        'title' => 'Customer Analysis',
                        'desc'  => 'Customer segments and purchase patterns.',
                        'path'  => 'sale/reports/customer-analysis',
                        'icon'  => 'fa-users',
                    ],
                    [
                        'title' => 'Sales Reports',
                        'desc'  => 'Consolidated sales rollup.',
                        'path'  => 'sale/reports/sales-reports',
                        'icon'  => 'fa-file-invoice',
                    ],
                ],
            ],
            [
                'label' => 'Inventory',
                'icon'  => 'fa-boxes-stacked',
                'items' => [
                    [
                        'title' => 'Inventory Reports',
                        'desc'  => 'KPIs, low stock, and recent adjustments.',
                        'path'  => 'inventory/reports',
                        'icon'  => 'fa-chart-line',
                    ],
                ],
            ],
            [
                'label' => 'Procurement',
                'icon'  => 'fa-cart-shopping',
                'items' => [
                    [
                        'title' => 'Procurement Reports',
                        'desc'  => 'Purchasing and supplier rollups.',
                        'path'  => 'procurement/reports',
                        'icon'  => 'fa-chart-line',
                    ],
                ],
            ],
            [
                'label' => 'Accounting',
                'icon'  => 'fa-calculator',
                'items' => [
                    [
                        'title' => 'Financial Reports',
                        'desc'  => 'Hub for trial balance, ledger, and statements.',
                        'path'  => 'accounting/reports',
                        'icon'  => 'fa-chart-line',
                    ],
                    [
                        'title' => 'Trial Balance',
                        'desc'  => 'Net debit and credit balances by account.',
                        'path'  => 'accounting/reports/trial-balance',
                        'icon'  => 'fa-table',
                    ],
                    [
                        'title' => 'General Ledger',
                        'desc'  => 'Posted movements with running balances.',
                        'path'  => 'accounting/reports/general-ledger',
                        'icon'  => 'fa-book-open',
                    ],
                    [
                        'title' => 'Profit & Loss',
                        'desc'  => 'Revenue and expenses for the period.',
                        'path'  => 'accounting/reports/profit-and-loss',
                        'icon'  => 'fa-chart-area',
                    ],
                    [
                        'title' => 'Balance Sheet',
                        'desc'  => 'Assets, liabilities, and equity.',
                        'path'  => 'accounting/reports/balance-sheet',
                        'icon'  => 'fa-file-invoice-dollar',
                    ],
                    [
                        'title' => 'Cash Flow',
                        'desc'  => 'Operating, investing, and financing cash.',
                        'path'  => 'accounting/reports/cash-flow',
                        'icon'  => 'fa-water',
                    ],
                    [
                        'title' => 'Tax Reports',
                        'desc'  => 'VAT and tax period summaries.',
                        'path'  => 'accounting/tax-reports',
                        'icon'  => 'fa-percent',
                    ],
                    [
                        'title' => 'Receivables Aging',
                        'desc'  => 'Outstanding customer invoices by age.',
                        'path'  => 'accounting/receivables-aging',
                        'icon'  => 'fa-clock',
                    ],
                    [
                        'title' => 'Payables Aging',
                        'desc'  => 'Outstanding supplier bills by age.',
                        'path'  => 'accounting/payables-aging',
                        'icon'  => 'fa-clock',
                    ],
                ],
            ],
            [
                'label' => 'Operations',
                'icon'  => 'fa-clipboard-list',
                'items' => [
                    [
                        'title' => 'Completion Reports',
                        'desc'  => 'Completed work orders for the selected period.',
                        'path'  => 'operations/work-orders/completion-reports',
                        'icon'  => 'fa-file-circle-check',
                    ],
                ],
            ],
        ];
    }
}
