<?php

namespace Modules\Transport\Controllers;

use App\Controllers\BaseController;
use Modules\Transport\Services\TransportReportService;

class TransportReportController extends BaseController
{
    protected TransportReportService $reports;

    public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
    {
        parent::initController($request, $response, $logger);
        $this->reports = new TransportReportService();
    }

    public function index()
    {
        $filters = $this->reports->resolveFilters($this->request->getGet());
        $report  = $this->reports->summary($filters);

        return view('Modules\Transport\Views\reports\index', array_merge($this->baseViewData(), [
            'title'   => 'Transport Reports',
            'filters' => $filters,
            'report'  => $report,
            'loadCharts' => true,
        ]));
    }
}
