<?php
namespace Modules\Signature;

use Skeleton\Router;
use Skeleton\Module;
use Psr\Container\ContainerInterface;
use Skeleton\Renderer\RendererInterface;
use Helpers\Parametres\Parametres;
use Modules\Signature\Controller\DelegationSignatureController;
use Modules\Signature\Controller\SignatureBapController;
use Modules\Signature\Controller\SignatureCdeController;
use Modules\Signature\Controller\SignatureDaController;

class SignatureModule extends Module
{

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

    public function __construct(ContainerInterface $container)
    {
        $container->get(RendererInterface::class)->addPath('signature', __DIR__ . '/views');
        
        $router = $container->get(Router::class);
        
        $parametres = new Parametres();
        $global     = $parametres->expression_global;

        $base_url = $container->get('baseUrl') . $container->get('Signature.prefix');

        $router->get($base_url.'/{MODULE:'.$global.'+}/delegationSignature', DelegationSignatureController::class, 'Signature.DelegationSignature.delegation');

        $router->get($base_url.'/DA/listeDoc[/{signataire:'.$global.'+}]', SignatureDaController::class, 'Signature.SignatureDa.listeDoc');
        $router->get($base_url.'/CDE/listeDoc[/{signataire:'.$global.'+}]', SignatureCdeController::class, 'Signature.SignatureCde.listeDoc');
        $router->get($base_url.'/BAP/listeDoc[/{signataire:'.$global.'+}]', SignatureBapController::class, 'Signature.SignatureBap.listeDoc');

        $router->get($base_url.'/DA/asynchSignature/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureDaController::class, 'Signature.SignatureDa.asynchSignature');
        $router->get($base_url.'/CDE/asynchSignature/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureCdeController::class, 'Signature.SignatureCde.asynchSignature');
        $router->get($base_url.'/BAP/asynchSignature/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureBapController::class, 'Signature.SignatureBap.asynchSignature');

        $router->get($base_url. '/DA/popup-sign/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureDaController::class, 'Signature.SignatureDa.popupSignature');
        $router->get($base_url. '/CDE/popup-sign/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureCdeController::class, 'Signature.SignatureCde.popupSignature');
        $router->get($base_url. '/BAP/popup-sign/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureBapController::class, 'Signature.SignatureBap.popupSignature');
        $router->get($base_url. '/BAP/form-refus[/{signataire:'.$global.'+}]', SignatureBapController::class, 'Signature.SignatureBap.formRefusSignature');

        $router->get($base_url. '/DA/sign/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureDaController::class, 'Signature.SignatureDa.signer');
        $router->get($base_url. '/CDE/sign/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureCdeController::class, 'Signature.SignatureCde.signer');
        $router->get($base_url. '/BAP/sign/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureBapController::class, 'Signature.SignatureBap.signer');

        $router->get($base_url. '/DA/confirmationSignature/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureDaController::class, 'Signature.SignatureDa.confirmationSignature');
        $router->get($base_url. '/CDE/confirmationSignature/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureCdeController::class, 'Signature.SignatureCde.confirmationSignature');
        $router->get($base_url. '/BAP/confirmationSignature/{mode:[SR]}[/{signataire:'.$global.'+}]', SignatureBapController::class, 'Signature.SignatureBap.confirmationSignature');
        
        $router->get($base_url.'/DA/changementSignature/{idDoc:'.$global.'+}', SignatureDaController::class, 'Signature.SignatureDa.changementSignataire');
        $router->get($base_url.'/CDE/changementSignature/{idDoc:'.$global.'+}', SignatureCdeController::class, 'Signature.SignatureCde.changementSignataire');
        $router->get($base_url.'/BAP/changementSignature/{idDoc:'.$global.'+}', SignatureBapController::class, 'Signature.SignatureBap.changementSignataire');
    
        $router->get($base_url.'/DA/ajouterSignature/{idDoc:'.$global.'+}', SignatureDaController::class, 'Signature.SignatureDa.ajoutSignataire');
        $router->get($base_url.'/CDE/ajouterSignature/{idDoc:'.$global.'+}', SignatureCdeController::class, 'Signature.SignatureCde.ajoutSignataire');
        $router->get($base_url.'/BAP/ajouterSignature/{idDoc:'.$global.'+}', SignatureBapController::class, 'Signature.SignatureBap.ajoutSignataire');
        
        $router->get($base_url.'/DA/signatureAttendu/{idDoc:'.$global.'+}', SignatureDaController::class, 'Signature.SignatureDa.signatureAttendu');
        $router->get($base_url.'/CDE/signatureAttendu/{idDoc:'.$global.'+}', SignatureCdeController::class, 'Signature.SignatureCde.signatureAttendu');
        $router->get($base_url.'/BAP/signatureAttendu/{idDoc:'.$global.'+}', SignatureBapController::class, 'Signature.SignatureBap.signatureAttendu');

        $router->get($base_url.'/DA/editAndSign/{idDoc:'.$global.'+}[/{signataire:'.$global.'+}]', SignatureDaController::class, 'Signature.SignatureDa.editAndSign');
        $router->get($base_url.'/CDE/editAndSign/{idDoc:'.$global.'+}[/{signataire:'.$global.'+}]', SignatureCdeController::class, 'Signature.SignatureCde.editAndSign');

        $router->get($base_url.'/DA/validation/editAndSign/{idDoc:'.$global.'+}[/{signataire:'.$global.'+}]', SignatureDaController::class, 'Signature.SignatureDa.validation');
        $router->get($base_url.'/CDE/validation/editAndSign/{idDoc:'.$global.'+}[/{signataire:'.$global.'+}]', SignatureCdeController::class, 'Signature.SignatureCde.validation');
        
        $router->get($base_url.'/DA/confirmValidation/editAndSign/{idDoc:'.$global.'+}[/{signataire:'.$global.'+}]', SignatureDaController::class, 'Signature.SignatureDa.confirmValidation');
        $router->get($base_url.'/CDE/confirmValidation/editAndSign/{idDoc:'.$global.'+}[/{signataire:'.$global.'+}]', SignatureCdeController::class, 'Signature.SignatureCde.confirmValidation');
    }
}
