<?php

namespace Modules\Delegation;

use Modules\Delegation\Controller\PermanentDelegationController;
use Skeleton\Router;
use Skeleton\Module;
use Psr\Container\ContainerInterface;
use Skeleton\Renderer\RendererInterface;
use Helpers\Parametres\Parametres;
use Modules\Delegation\Controller\AbsenceDelegationController;

class DelegationModule extends Module
{

    const DEFINITIONS = __DIR__ . '/config.php';

    public function __construct(ContainerInterface $container)
    {
        $container->get(RendererInterface::class)->addPath('Delegation', __DIR__ . '/views');

        $router = $container->get(Router::class);

        $parametres = new Parametres();
        $deleg = $parametres->expression_global;
        $debut = $parametres->expression_decimal;
        $societe = $parametres->expression_global;
        $baseUrl = $container->get('baseUrl') . $container->get('Delegation.prefix');


        $router->get(
            $baseUrl . '/absence/index',
            AbsenceDelegationController::class,
            'Delegation.AbsenceDelegation.index'
        );
        $router->get(
            $baseUrl . '/permanent/index',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.index'
        );
        $router->get(
            $baseUrl . '/permanent/ajaxDetail/{index:' . $deleg . '+}/{deleg:' . $deleg . '+}[/{societe:' . $societe . '+}]',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.ajaxDetail'
        );
        $router->get(
            $baseUrl . '/absence/edit/{deleg:' . $deleg . '+}/{debut:' . $debut . '+}',
            AbsenceDelegationController::class,
            'Delegation.AbsenceDelegation.edit'
        );
        $router->get(
            $baseUrl . '/permanent/edit/{deleg:' . $deleg . '+}[/{societe:' . $societe . '+}]',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.edit'
        );
        $router->get(
            $baseUrl . '/absence/create',
            AbsenceDelegationController::class,
            'Delegation.AbsenceDelegation.create'
        );
        $router->get(
            $baseUrl . '/permanent/create',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.create'
        );
        $router->get(
            $baseUrl . '/permanent/ajaxAddTrigger',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.ajaxAddTrigger'
        );
        $router->get(
            $baseUrl . '/permanent/ajaxUpdateTriggerList[/{societe:' . $societe . '+}]',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.ajaxUpdateTriggerList'
        );
        $router->get(
            $baseUrl . '/permanent/ajaxGetTriggerZoom',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.ajaxGetTriggerZoom'
        );
        $router->get(
            $baseUrl . '/absence/delete/{deleg:' . $deleg . '+}/{debut:' . $debut . '+}',
            AbsenceDelegationController::class,
            'Delegation.AbsenceDelegation.delete'
        );
        $router->get(
            $baseUrl . '/permanent/delete/{deleg:' . $deleg . '+}[/{societe:' . $societe . '+}]',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.delete'
        );
        $router->get(
            $baseUrl . '/absence/validate[/{deleg:' . $deleg . '+}/{debut:' . $debut . '+}]',
            AbsenceDelegationController::class,
            'Delegation.AbsenceDelegation.validate'
        );
        $router->get(
            $baseUrl . '/permanent/validate[/{deleg:' . $deleg . '+}[/{societe:' . $societe . '+}]]',
            PermanentDelegationController::class,
            'Delegation.PermanentDelegation.validate'
        );
    }
}
