<?php

declare(strict_types=1);

namespace App\Controllers;

use App\Core\Controller;
use App\Core\Config;
use App\Services\DashboardService;

final class DashboardController extends Controller
{
    public function index(): void
    {
        $this->view('dashboard/index', (new DashboardService())->general() + [
            'title' => 'Tableau de bord général',
            'appName' => Config::get('APP_NAME', 'Darlink ERP'),
        ]);
    }

    public function commercial(): void
    {
        $this->view('dashboard/commercial', (new DashboardService())->commercialDashboard() + [
            'title' => 'Tableau de bord commercial',
            'appName' => Config::get('APP_NAME', 'Darlink ERP'),
        ]);
    }

    public function devisAnalysis(): void
    {
        $this->view('dashboard/devis_analysis', (new DashboardService())->devisAnalysis($_GET) + [
            'title' => 'Analyse devis / transformation commerciale',
            'appName' => Config::get('APP_NAME', 'Darlink ERP'),
        ]);
    }

    public function facturesClients(): void
    {
        $this->view('dashboard/factures_clients', (new DashboardService())->facturesClients($_GET) + [
            'title' => 'Suivi factures clients / encaissements',
            'appName' => Config::get('APP_NAME', 'Darlink ERP'),
        ]);
    }

    public function articlesSalesAnalysis(): void
    {
        $this->view('dashboard/articles_sales_analysis', (new DashboardService())->articlesSalesAnalysis($_GET) + [
            'title' => 'Analyse articles vendus / performance commerciale',
            'appName' => Config::get('APP_NAME', 'Darlink ERP'),
        ]);
    }

    public function clientsAnalysis(): void
    {
        $this->view('dashboard/clients_analysis', (new DashboardService())->clientsAnalysis($_GET) + [
            'title' => 'Analyse clients / performance commerciale',
            'appName' => Config::get('APP_NAME', 'Darlink ERP'),
        ]);
    }

    public function commercialActions(): void
    {
        $this->view('dashboard/commercial_actions', (new DashboardService())->commercialActions($_GET) + [
            'title' => 'Actions commerciales / relances clients',
            'appName' => Config::get('APP_NAME', 'Darlink ERP'),
        ]);
    }

}

