<?php
namespace Modules\Parametrage;

use Modules\Parametrage\Consultation\Controller\ParametrageConsultationController;
use Skeleton\Router;
use Skeleton\Module;
use Psr\Container\ContainerInterface;
use Skeleton\Renderer\RendererInterface;
use Helpers\Parametres\Parametres;

use Modules\Parametrage\API\Controller\ParametrageAPIController;
use Modules\Parametrage\API\Controller\ParametrageApiCsdController;
use Modules\Parametrage\API\Controller\ParametrageApiExtController;
use Modules\Parametrage\OxaMobilite\Controller\ParametrageMobiliteController;
use Modules\Parametrage\Oxalink\Controller\ParametrageOxalinkController;
use Modules\Parametrage\Oxalink\Controller\ParametragePageOxalinkController;
use Modules\Parametrage\Oxalink\Controller\ParametrageFrsOxalinkController;
use Modules\Parametrage\Oxalink\Controller\ParametrageAccesOxalinkController;
use Modules\Parametrage\Facture\Controller\ParametrageAjaxController;
use Modules\Parametrage\Facture\Controller\ParametrageFlexiController;
use Modules\Parametrage\Fournisseur\Controller\ParametrageFournisseurController;
use Modules\Parametrage\Controller\ParametrageIndexController;
use Modules\Parametrage\Facture\Controller\ParametrageLADController;
use Modules\Parametrage\Facture\Controller\ParametrageLADFournImportController;
use Modules\Parametrage\Oxaproc\Controller\ParametrageOxaprocController;
use Modules\Parametrage\Facture\Controller\ParametrageFactureController;
use Modules\Parametrage\Evaluation\Controller\ParametrageEvaluationController;
use Modules\Parametrage\Facture\Controller\ParametrageAgenaBranchController;
use Modules\Parametrage\Facture\Controller\ParametrageFactureDematPartnController;
use Modules\Parametrage\Incident\Controller\ParametrageIncidentController;

class ParametrageModule extends Module
{

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

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

        $container->get(RendererInterface::class)->addPath('ParamAPI', __DIR__ . '/API/views');
        $container->get(RendererInterface::class)->addPath('ParamEval', __DIR__ . '/Evaluation/views');
        $container->get(RendererInterface::class)->addPath('ParamFac', __DIR__ . '/Facture/views');
        $container->get(RendererInterface::class)->addPath('ParamFou', __DIR__ . '/Fournisseur/views');
        $container->get(RendererInterface::class)->addPath('ParamOxalink', __DIR__ . '/Oxalink/views');
        $container->get(RendererInterface::class)->addPath('ParamOxaMobi', __DIR__ . '/OxaMobilite/views');
        $container->get(RendererInterface::class)->addPath('ParamOxaproc', __DIR__ . '/Oxaproc/views');
        $container->get(RendererInterface::class)->addPath('ParamConsultation', __DIR__ . '/Consultation/views');
        $container->get(RendererInterface::class)->addPath('ParamIncident', __DIR__ . '/Incident/views');
        
        $router = $container->get(Router::class);
        
        $parametres = new Parametres();
        $pageOxalink = $global = $parametres->expression_global;
        $langue     = $parametres->codeLangue;
        $bool = '[0-1]';

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

        /** Parametrage **/
        
        $router->get($base_url.'', ParametrageIndexController::class, 'Parametrage.Parametrage.index');
        
        $router->get($base_url.'/oxaLink', ParametrageOxalinkController::class, 'Parametrage.ParametrageOxalink.index');
        $router->get($base_url.'/oxaLink/paramMail', ParametrageOxalinkController::class, 'Parametrage.ParametrageOxalink.paramMail');

        $router->get($base_url.'/oxaLink/demandeReferencement', ParametrageFrsOxalinkController::class, 'Parametrage.ParametrageOxalink.fournisseur');
        $router->get($base_url.'/oxaLink/rules', ParametrageFrsOxalinkController::class, 'Parametrage.ParametrageOxalink.rules');


        $router->get($base_url.'/oxaLink/page', ParametragePageOxalinkController::class, 'Parametrage.ParametrageOxalink.page');
        $router->get($base_url.'/oxaLink/page/detail/{page:'.$pageOxalink.'+}', ParametragePageOxalinkController::class, 'Parametrage.ParametrageOxalink.ajaxDetailPage');
        $router->get($base_url.'/oxaLink/page/nouveau[/{page:'.$pageOxalink.'+}/{codeLng:'.$langue.'+}]', ParametragePageOxalinkController::class, 'Parametrage.ParametrageOxalink.ajouterPage');
        $router->get($base_url.'/oxaLink/page/modification/{page:'.$pageOxalink.'+}[/{codeLng:'.$langue.'+}]', ParametragePageOxalinkController::class, 'Parametrage.ParametrageOxalink.modificationPage');
        $router->get($base_url.'/oxaLink/page/suppresion/{page:'.$pageOxalink.'+}[/{codeLng:'.$langue.'+}]', ParametragePageOxalinkController::class, 'Parametrage.ParametrageOxalink.suppresionPage');
    
        $router->get($base_url.'/oxaLink/cgu/modification[/{codeLng:'.$langue.'+}]', ParametragePageOxalinkController::class, 'Parametrage.ParametrageOxalink.modificationCGU');
        $router->get($base_url.'/oxaLink/cgu/download[/{codeLng:'.$langue.'+}]', ParametragePageOxalinkController::class, 'Parametrage.ParametrageOxalink.downloadCGU');
        $router->get($base_url.'/oxaLink/cgu/detail', ParametragePageOxalinkController::class, 'Parametrage.ParametrageOxalink.ajaxDetailCGU');
        
        $router->get($base_url.'/oxaLink/acces', ParametrageAccesOxalinkController::class, 'Parametrage.ParametrageAcces.acces');

        //parametrageMoblit
        $router->get($base_url.'/mobilite/QrCode', ParametrageMobiliteController::class, 'Parametrage.ParametrageMobilite.QrCode');
        $router->get($base_url.'/mobilite/ajax/SendMail', ParametrageMobiliteController::class, 'Parametrage.ParametrageMobilite.ajaxSendMail');
        // Parametrage LAD
        $router->get($base_url . '/parametrage/LAD', ParametrageLADController::class, 'Parametrage.ParametrageLAD.LAD');
        $router->get($base_url . '/parametrage/LAD/Fournisseur[/del/{delCodeFournisseur:'.$global.'+}]', ParametrageLADController::class, 'Parametrage.ParametrageLAD.fournisseur');
        $router->get($base_url . '/parametrage/LAD/creation/Fournisseur/{type:'.$global.'+}/[{codeFournisseur : '.$global.'+}/{codeSte : '.$global.'+}/{fromFicheFournisseur : '.$bool.'+}]', ParametrageLADController::class, 'Parametrage.ParametrageLAD.creationParamLADFournisseur');
        $router->get($base_url . '/parametrage/LAD/Fournisseur/export', ParametrageLADController::class, 'Parametrage.ParametrageLAD.exportFournisseurArticle');
        $router->get($base_url . '/parametrage/LAD/Fournisseur/createOrModifyRedirect/{codeFournisseur : '.$global.'+}/{codeSte : '.$global.'+}', ParametrageLADController::class, 'Parametrage.ParametrageLAD.createOrModifyRedirect');
        $router->get($base_url . '/parametrage/LAD/Fournisseur/deleteAllArticles/{codeFournisseur : '.$global.'+}', ParametrageLADController::class, 'Parametrage.ParametrageLAD.deleteAllArticles');
        
        // flexi signature
        $router->get($base_url . '/parametrage/FLEXI/signature', ParametrageFlexiController::class, 'Parametrage.ParametrageFlexi.signature');
        $router->get($base_url . '/parametrage/FLEXI/validateSignature', ParametrageFlexiController::class, 'Parametrage.ParametrageFlexi.validateSignature');
        // Paramétrage LAD - IMPORT FOURNISSEUR ARTICLE
        $router->get($base_url . '/parametrage/LAD/import', ParametrageLADFournImportController::class, 'Parametrage.ParametrageLADFournImport.import');
        $router->get($base_url . '/parametrage/LAD/ajax/import', ParametrageLADFournImportController::class, 'Parametrage.ParametrageLADFournImport.ajaxImport');
        $router->get($base_url . '/parametrage/LAD/ajax/recapAnomalie', ParametrageLADFournImportController::class, 'Parametrage.ParametrageLADFournImport.recapAnomalie');

        // Parametrage Fournisseur
        $router->get($base_url . '/fournisseur/rules', ParametrageFournisseurController::class, 'Parametrage.ParametrageFournisseur.rules');
        $router->get($base_url . '/fournisseur/dashboard-rules', ParametrageFournisseurController::class, 'Parametrage.ParametrageFournisseur.dashboardRules');
   
        // Parametrage OXA.PROC
        $router->get($base_url . '/oxaproc/fonctionnel', ParametrageOxaprocController::class, 'Parametrage.ParametrageOxaproc.fonctionnel');
        $router->get($base_url . '/oxaproc/visual', ParametrageOxaprocController::class, 'Parametrage.ParametrageOxaproc.visual');
        $router->get($base_url . '/oxaproc/ajax/validator/File', ParametrageOxaprocController::class, 'Parametrage.ParametrageOxaproc.ajaxValidatorFile');
        
        // Parametrage facture
        $router->get($base_url . '/facture', ParametrageFactureController::class, 'Parametrage.ParametrageFacture.facture');
        $router->get($base_url . '/facture/ajax/update', ParametrageFactureController::class, 'Parametrage.ParametrageFacture.factureUpdate');
        
        // Parametrage Facture Demat
        $router->get($base_url . '/facture-demat', ParametrageFactureDematPartnController::class, 'Parametrage.FactureDematPartn.index');
        $router->get($base_url . '/facture-demat/form-create', ParametrageFactureDematPartnController::class, 'Parametrage.FactureDematPartn.formCreate');
        $router->get($base_url . '/facture-demat/create', ParametrageFactureDematPartnController::class, 'Parametrage.FactureDematPartn.create');
        $router->get($base_url . '/facture-demat/test', ParametrageFactureDematPartnController::class, 'Parametrage.FactureDematPartn.testConnection');
        $router->get($base_url . '/facture-demat/{id:[0-9]+}/form-update', ParametrageFactureDematPartnController::class, 'Parametrage.FactureDematPartn.formUpdate');
        $router->get($base_url . '/facture-demat/{id:[0-9]+}/update', ParametrageFactureDematPartnController::class, 'Parametrage.FactureDematPartn.update');
        $router->get($base_url . '/facture-demat/{id:[0-9]+}/disable', ParametrageFactureDematPartnController::class, 'Parametrage.FactureDematPartn.disable');
        $router->get($base_url . '/facture-demat/config/update', ParametrageFactureDematPartnController::class, 'Parametrage.FactureDematPartn.updateConfig');
        
        $router->get($base_url . '/facture-demat/zoom/field-ubl', ParametrageFactureDematPartnController::class, 'Facture.Zoom.zoomUblField');

        // Agena 3000 Branch
        $agenaId = '[a-z0-9-]+';
        $router->get($base_url . '/facture-demat/{pdp:[0-9]+}/branch', ParametrageAgenaBranchController::class, 'Parametrage.Agena.index');
        $router->get($base_url . '/facture-demat/{pdp:[0-9]+}/branch/form-create', ParametrageAgenaBranchController::class, 'Parametrage.Agena.formCreate');
        $router->get($base_url . '/facture-demat/{pdp:[0-9]+}/branch/create', ParametrageAgenaBranchController::class, 'Parametrage.Agena.create');
        //$router->get($base_url . '/facture-demat/{pdp:[0-9]+}/branch/{id:'.$agenaId.'}/form-update', ParametrageAgenaBranchController::class, 'Parametrage.Agena.formUpdate');
        //$router->get($base_url . '/facture-demat/{pdp:[0-9]+}/branch/{id:'.$agenaId.'}/update', ParametrageAgenaBranchController::class, 'Parametrage.Agena.update');
        $router->get($base_url . '/facture-demat/{pdp:[0-9]+}/branch/{id:'.$agenaId.'}/delete', ParametrageAgenaBranchController::class, 'Parametrage.Agena.delete');
        $router->get($base_url . '/facture-demat/{pdp:[0-9]+}/form-export-adrelec', ParametrageAgenaBranchController::class, 'Parametrage.Agena.formExportAdr');
        $router->get($base_url . '/facture-demat/{pdp:[0-9]+}/export-adrelec', ParametrageAgenaBranchController::class, 'Parametrage.Agena.exportAdr');

        // Parametrage incident
        $router->get($base_url . '/incident', ParametrageIncidentController::class, 'Parametrage.ParametrageIncident.incident');
        $router->get($base_url . '/incident/update/{code : '.$global.'+}', ParametrageIncidentController::class, 'Parametrage.ParametrageIncident.incidentUpdate');
        $router->get($base_url . '/incident/create', ParametrageIncidentController::class, 'Parametrage.ParametrageIncident.incidentCreate');
        $router->get($base_url . '/incident/validationUpdate/{code : '.$global.'+}', ParametrageIncidentController::class, 'Parametrage.ParametrageIncident.incidentValidationUpdate');
        $router->get($base_url . '/incident/validationCreate', ParametrageIncidentController::class, 'Parametrage.ParametrageIncident.incidentValidationCreate');

        // Parametrage evaluation
        $router->get($base_url . '/evaluation', ParametrageEvaluationController::class, 'Parametrage.ParametrageEvaluation.evaluation');
        $router->get($base_url . '/evaluation/ajax/update', ParametrageEvaluationController::class, 'Parametrage.ParametrageEvaluation.evaluationUpdate');

        // Parametrage API
        $router->get($base_url.'/api/settings/connect[/{reset:'.$global.'+}]', ParametrageAPIController::class, 'Parametrage.ParametrageAPI.index');

        // Parametrage Consultation
        $router->get($base_url.'/consultation/fonctionnel', ParametrageConsultationController::class, 'Parametrage.ParametrageConsultation.fonctionnel');
        $router->get($base_url.'/consultation/entete', ParametrageConsultationController::class, 'Parametrage.ParametrageConsultation.entete');
        $router->get($base_url.'/consultation/documentsreponse', ParametrageConsultationController::class, 'Parametrage.ParametrageConsultation.documentreponse');
        $router->get($base_url.'/consultation/pjclause', ParametrageConsultationController::class, 'Parametrage.ParametrageConsultation.pjclause');
        $router->get($base_url.'/ajax/consultation/deletelignedoc/{typeDoc:'.$global.'+}/{codLng:'.$global.'+}/{numOrdreInit:'.$global.'+}', ParametrageConsultationController::class, 'Parametrage.ParametrageConsultation.ajaxDeleteLigneDoc');
        $router->get($base_url.'/popup/consultation/ajoutdocumentconsult/{typeDoc:'.$global.'+}', ParametrageConsultationController::class, 'Parametrage.ParametrageConsultation.popupAjoutDocumentConsult');

        $router->get(
            $base_url.'/mail',
            ParametrageOxalinkController::class,
            'Parametrage.ParametrageOxalink.notifierDestinataire'
        );

        $router->get(
            $base_url.'/mail/ajaxDelete/{type:'.$global.'+}',
            ParametrageOxalinkController::class,
            'Parametrage.ParametrageOxalink.ajaxDeleteParamDestinataire'
        );

        // Parametrage API Consomer
        $router->get($base_url . '/api-ext', ParametrageApiExtController::class, 'Parametrage.ApiExt.index');
        $router->get($base_url . '/api-ext/form-mapping', ParametrageApiExtController::class, 'Parametrage.ApiExt.formMapping');
        $router->get($base_url . '/api-ext/update', ParametrageApiExtController::class, 'Parametrage.ApiExt.updateMapping');

        // Ajax
        $router->get($base_url . '/ajax-parametrage/{codeFournisseur:'.$global.'+}/{societe:'.$global.'+}/ligne-articles', ParametrageAjaxController::class, 'Parametrage.Ajax.ligneArticles');
        
        // API - CSD
        $router->get($base_url . '/csd', ParametrageApiCsdController::class, 'Parametrage.Csd.index');
        $router->get($base_url . '/csd/update', ParametrageApiCsdController::class, 'Parametrage.Csd.update');
    }
}
