<?php
namespace Modules\Catalogue;

use Helpers\Parametres\Parametres;
use Modules\Catalogue\Controller\AffectationTypeArticleController;
use Modules\Catalogue\Controller\ArticleEquivalentController;
use Modules\Catalogue\Controller\CatalogueExterneController;
use Modules\Catalogue\Controller\ChargementCatalogueController;
use Modules\Catalogue\Controller\ControleVersionController;
use Modules\Catalogue\Controller\FormatController;
use Modules\Catalogue\Controller\NomParametrageController;
use Modules\Catalogue\Controller\ParametrageFormatController;
use Modules\Catalogue\Controller\VersionCataExterneControlle;
use Skeleton\Router;
use Skeleton\Module;
use Skeleton\Renderer\RendererInterface;
use Psr\Container\ContainerInterface;

class CatalogueModule extends Module
{
    const DEFINITIONS = __DIR__ . '/config.php';

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

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

        $parametres     = new Parametres();
        $global         = '[A-Za-z0-9%._ @-]';

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

        //FORMAT
        $router->get($base_url. '/format', FormatController::class, 'Catalogue.Format.listeFormat');
        $router->get($base_url. '/format/delete/{IdFormat:'.$global.'+}', FormatController::class, 'Catalogue.Format.delete');
        $router->get($base_url. '/ajax/connecteur', FormatController::class, 'Catalogue.Format.ajaxConnecteur');
        $router->get($base_url. '/format/create', FormatController::class, 'Catalogue.Format.create');
        $router->get($base_url. '/format/validate', FormatController::class, 'Catalogue.Format.validate');

        $router->get($base_url. '/format/export/{IdFormat:'.$global.'+}', FormatController::class, 'Catalogue.Format.exportJson');
        $router->get($base_url. '/format/import', FormatController::class, 'Catalogue.Format.importJson');


        //liste nom parametrage format
        $router->get($base_url. '/format/nomParametrage', NomParametrageController::class, 'Catalogue.nomParametrage.liste');
        $router->get($base_url. '/format/nomParametrage/createEdit[/{idCle:'.$global.'+}/{nomParam:'.$global.'+}]', NomParametrageController::class, 'Catalogue.nomParametrage.createEdit');
        $router->get($base_url. '/format/nomParametrage/delete/{idCle:'.$global.'+}/{nomParam:'.$global.'+}', NomParametrageController::class, 'Catalogue.nomParametrage.delete');

        //FORMAT PARAMETRAGE
        $router->get($base_url. '/format/parametrage/updateValue/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.updateValue');
        //mappage
        $router->get($base_url. '/format/parametrage/Mappage/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.paramMappage');
        $router->get($base_url. '/format/parametrage/resetMapping/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.resetMapping');

        //_multiMappage
        $router->get($base_url. '/format/parametrage/popup/multiMapp/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.popupMultiMapp');
        $router->get($base_url. '/format/parametrage/ajax/ajoutLigne/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.ajaxAjoutLigne');
        $router->get($base_url. '/format/parametrage/validateMultiMapping/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.validateMultiMapping');
        $router->get($base_url. '/format/popupMapping/{typeFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.popupMapping');

        $router->get($base_url. '/format/parametrage/listeCatalogue/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.listeCatalogue');

        //controle
        $router->get($base_url. '/format/parametrage/Controle/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.paramControle');

        //transco
        $router->get($base_url. '/format/parametrage/Transcodification/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.paramTransco');
        $router->get($base_url. '/format/parametrage/gestionTransco/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.gestionTransco');
        $router->get($base_url. '/format/parametrage/gestionTransco/validateTransco/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.validateTransco');
        $router->get($base_url. '/format/parametrage/ajax/transco/ajoutLigne', ParametrageFormatController::class, 'Catalogue.parametrageFormat.ajaxAjoutLigneTransco');
        $router->get($base_url. '/format/parametrage/popup/importTransco', ParametrageFormatController::class, 'Catalogue.parametrageFormat.popupImportTransco');
        $router->get($base_url. '/format/parametrage/ajax/importTransco', ParametrageFormatController::class, 'Catalogue.parametrageFormat.ajaxImportTransco');
        
        //Validation
        $router->get($base_url. '/format/parametrage/Validation/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.paramValidation');
        $router->get($base_url. '/format/parametrage/popup/validation/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.popupValidation');
        $router->get($base_url. '/format/parametrage/ajax/validation/ajoutLigne', ParametrageFormatController::class, 'Catalogue.parametrageFormat.ajaxAjoutLigneValidation');
        $router->get($base_url. '/format/parametrage/validateValidation/{IdFormat:'.$global.'+}/{IdLigne:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.validateValidation');
    
        //connecteur
        $router->get($base_url. '/format/parametrage/connecteur/edit/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.editConnecteur');
        $router->get($base_url. '/format/parametrage/connecteur/validate/{IdFormat:'.$global.'+}', ParametrageFormatController::class, 'Catalogue.parametrageFormat.validateConnecteur');
        //CATALOGUE EXTERNE
        $router->get($base_url. '/catalogueExterne', CatalogueExterneController::class, 'Catalogue.CatalogueExterne.listeCatalogue');
        $router->get($base_url. '/catalogueExterne/ajaxDetail/{idCatalogue:'.$global.'+}', CatalogueExterneController::class, 'Catalogue.CatalogueExterne.ajaxDetail');
        
        $router->get($base_url. '/catalogueExterne/creatEdit[/{idCatalogue:'.$global.'+}]', CatalogueExterneController::class, 'Catalogue.CatalogueExterne.creatEdit');
        $router->get($base_url. '/ajax/getTypeFormat', CatalogueExterneController::class, 'Catalogue.CatalogueExterne.ajaxGetTypeFormat');
        $router->get($base_url. '/catalogueExterne/validate[/{idCatalogue:'.$global.'+}]', CatalogueExterneController::class, 'Catalogue.catalogueExterne.validate');
    
        //version
        $router->get($base_url. '/catalogueExterne/gestionVersion/{idCatalogue:'.$global.'+}', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.gestionVersion');
        $router->get($base_url. '/catalogueExterne/gestionVersion/ajax/detailVersion/{idVersion:'.$global.'+}[/{noOrdre:'.$global.'+}]', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.ajaxDetailVersion');
        $router->get($base_url. '/catalogueExterne/gestionVersion/ajax/updateChargementActif/{idVersion:'.$global.'+}/{noOrdre:'.$global.'+}', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.ajaxUpdateChargementActif');

        
        $router->get($base_url. '/catalogueExterne/createEdit/{idCatalogue:'.$global.'+}[/{idVersion:'.$global.'+}]', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.createEdit');
        $router->get($base_url. '/catalogueExterne/validateVersion/{idCatalogue:'.$global.'+}[/{idVersion:'.$global.'+}]', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.validateVersion');
        
        $router->get($base_url. '/catalogueExterne/gestionVersion/{idVersion:'.$global.'+}/delete', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.delete');
        $router->get($base_url. '/catalogueExterne/gestionVersion/{idVersion:'.$global.'+}/RAZ', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.RAZ');
        $router->get($base_url. '/catalogueExterne/gestionVersion/ajax/addParam/{idVersion:'.$global.'+}', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.ajaxAddParam');
        $router->get($base_url. '/catalogueExterne/gestionVersion/validationParamVersion/{idVersion:'.$global.'+}/{noOrdre:'.$global.'+}', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.validationParamVersion');
        $router->get($base_url. '/catalogueExterne/uploadFile/{idVersion:'.$global.'+}/{noOrdre:'.$global.'+}', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.uploadFile');
        $router->get($base_url. '/catalogueExterne/gestionVersion/chargementRemise/{idVersion:'.$global.'+}/{noOrdre:'.$global.'+}', VersionCataExterneControlle::class, 'Catalogue.VersionCataExterne.chargementRemise');
        
        
        $router->get($base_url. '/catalogueExterne/modeAssistant/popup/{idVersion:'.$global.'+}', ChargementCatalogueController::class, 'Catalogue.ChargementCatalogue.assistant');
        $router->get($base_url. '/catalogueExterne/modeAssistant/visualisation', ChargementCatalogueController::class, 'Catalogue.ChargementCatalogue.visualisationModeAssistant');
        $router->get($base_url. '/catalogueExterne/chargement/{idVersion:'.$global.'+}', ChargementCatalogueController::class, 'Catalogue.ChargementCatalogue.chargement');
        $router->get($base_url. '/catalogueExterne/gestionVersion/delete/{idVersion:'.$global.'+}/{noOrdre:'.$global.'+}', ChargementCatalogueController::class, 'Catalogue.ChargementCatalogue.delete');
    
        //controle
        $router->get($base_url. '/catalogueExterne/ControleVersion/listeArticles/{idVersion:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.listeArticles');
        
        $router->get($base_url. '/catalogueExterne/ControleVersion/ajoutArticle/{idVersion:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.ajoutArticle');
        $router->get($base_url. '/catalogueExterne/ControleVersion/ajax/ajaxArticles/{idLigne:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.ajaxArticles');
        $router->get($base_url. '/catalogueExterne/ControleVersion/updateValue[/{idLigne:'.$global.'+}]', ControleVersionController::class, 'Catalogue.ControleVersion.updateValue');
        $router->get($base_url. '/catalogueExterne/ControleVersion/deleteArticle/{idLigne:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.deleteArticle');

        $router->get($base_url. '/catalogueExterne/ControleVersion/ajaxchargeImage/{idLigne:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.ajaxChargeImage');
    
        $router->get($base_url. '/catalogueExterne/ControleVersion/listeUNSPSC', ControleVersionController::class, 'Catalogue.ControleVersion.listeUNSPSC');
        $router->get($base_url. '/catalogueExterne/ControleVersion/ajax/UNSPSC', ControleVersionController::class, 'Catalogue.ControleVersion.ajaxUNSPSC');

        $router->get($base_url. '/catalogueExterne/ControleVersion/popup/prixDegressif/{idLigne:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.popupPrixDegressif');
        $router->get($base_url. '/catalogueExterne/ControleVersion/ajax/prixDegressif', ControleVersionController::class, 'Catalogue.ControleVersion.ajaxPrixDegressif');
        $router->get($base_url. '/catalogueExterne/ControleVersion/validatePrixDegressif/{idLigne:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.validatePrixDegressif');

        $router->get($base_url. '/catalogueExterne/ControleVersion/listeCarac/{idLigne:'.$global.'+}/{typeCar:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.listeCarac');
        $router->get($base_url. '/catalogueExterne/ControleVersion/ajax/carac', ControleVersionController::class, 'Catalogue.ControleVersion.ajaxCarac');
        $router->get($base_url. '/catalogueExterne/ControleVersion/validateCarac/{idLigne:'.$global.'+}/{typeCar:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.validateCarac');
    
        $router->get($base_url. '/catalogueExterne/ControleVersion/articleAssocies/liste/{idLigne:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.listeArticleAssocies');
        $router->get($base_url. '/catalogueExterne/ControleVersion/articleAssocies/createEdit/{idLigne:'.$global.'+}/{idObjet:'.$global.'+}[/{typeObjetAss:'.$global.'+}/{idObjetAss:'.$global.'+}]', ControleVersionController::class, 'Catalogue.ControleVersion.createEditArticleAssocies');
        $router->get($base_url. '/catalogueExterne/ControleVersion/articleAssocies/validate/{idLigne:'.$global.'+}/{idObjet:'.$global.'+}[/{typeObjetAss:'.$global.'+}/{idObjetAss:'.$global.'+}]', ControleVersionController::class, 'Catalogue.ControleVersion.validateArticleAssocies');
        $router->get($base_url. '/catalogueExterne/ControleVersion/articleAssocies/delete/{idLigne:'.$global.'+}/{idObjet:'.$global.'+}/{typeObjetAss:'.$global.'+}/{idObjetAss:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.deleteArticleAssocies');


        $router->get($base_url. '/catalogueExterne/ControleVersion/associesA/liste/{idLigne:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.listeAssociesA');
        $router->get($base_url. '/catalogueExterne/ControleVersion/associesA/createEdit/{idLigne:'.$global.'+}/{idObjetAss:'.$global.'+}[/{typeAss:'.$global.'+}/{idObjet:'.$global.'+}]', ControleVersionController::class, 'Catalogue.ControleVersion.createEditlisteAssociesA');
        $router->get($base_url. '/catalogueExterne/ControleVersion/associesA/validate/{idLigne:'.$global.'+}/{idObjetAss:'.$global.'+}[/{typeAss:'.$global.'+}/{idObjet:'.$global.'+}]', ControleVersionController::class, 'Catalogue.ControleVersion.validateAssociesA');
        $router->get($base_url. '/catalogueExterne/ControleVersion/associesA/delete/{idLigne:'.$global.'+}/{idObjetAss:'.$global.'+}/{typeAss:'.$global.'+}/{idObjet:'.$global.'+}', ControleVersionController::class, 'Catalogue.ControleVersion.deleteAssociesA');
    
        // Equivalence
        $router->get($base_url. '/catalogueExterne/Equivalence/listeArticles/{idLigne:'.$global.'+}/{idClass:'.$global.'+}', ArticleEquivalentController::class, 'Catalogue.ArticleEquivalent.listeEquiArticle');
        $router->get($base_url. '/catalogueExterne/Equivalence/dissocier/{codeArt:'.$global.'+}/{codeFou:'.$global.'+}/{artFou:'.$global.'+}/{codeFab:'.$global.'+}/{artFab:'.$global.'+}/{idClass:'.$global.'+}', ArticleEquivalentController::class, 'Catalogue.ArticleEquivalent.dissocier');
        $router->get($base_url. '/catalogueExterne/Equivalence/referent/{codeArt:'.$global.'+}/{codeFou:'.$global.'+}/{artFou:'.$global.'+}/{codeFab:'.$global.'+}/{artFab:'.$global.'+}/{idClass:'.$global.'+}', ArticleEquivalentController::class, 'Catalogue.ArticleEquivalent.referent');
        $router->get($base_url. '/catalogueExterne/Equivalence/gestionPreference/{idClass:'.$global.'+}', ArticleEquivalentController::class, 'Catalogue.ArticleEquivalent.gestionPreference');
        $router->get($base_url. '/catalogueExterne/Equivalence/ajax/addArticle/{idClass:'.$global.'+}', ArticleEquivalentController::class, 'Catalogue.ArticleEquivalent.ajaxAddArticle');
        $router->get($base_url. '/catalogueExterne/Equivalence/createEquivalent/{idLigne:'.$global.'+}', ArticleEquivalentController::class, 'Catalogue.ArticleEquivalent.createEquivalent');
        $router->get($base_url. '/catalogueExterne/Equivalence/ajax/articleCompare', ArticleEquivalentController::class, 'Catalogue.ArticleEquivalent.ajaxArticleCompare');
        $router->get($base_url. '/catalogueExterne/Equivalence/validateEquiv/{idLigne:'.$global.'+}', ArticleEquivalentController::class, 'Catalogue.ArticleEquivalent.validateEquiv');
    
    
        //liste Catalogue
        $router->get($base_url. '/versionCatalogue[/{type:'.$global.'+}]', CatalogueExterneController::class, 'Catalogue.CatalogueExterne.listeVersionCatalogue');
        $router->get($base_url. '/affectation/typeArticle/article[/{idVersion:'.$global.'+}]', AffectationTypeArticleController::class, 'Catalogue.AffectationTypeArticle.parArticle');
        $router->get($base_url. '/affectation/typeArticle/ssFamille/Gamme[/{idVersion:'.$global.'+}]', AffectationTypeArticleController::class, 'Catalogue.AffectationTypeArticle.parSsfamilleGamme');
        $router->get($base_url. '/affectation/ajaxAppliquerChangement/typeArticle/ssFamille/Gamme[/{idVersion:'.$global.'+}]', AffectationTypeArticleController::class, 'Catalogue.AffectationTypeArticle.ajaxAppliquerChangement');
    }
}
