<?php

namespace Modules\Evaluation;

use Skeleton\Router;
use Skeleton\Module;
use Skeleton\Renderer\RendererInterface;
use Psr\Container\ContainerInterface;
use Modules\Evaluation\Controller\BilbliothequeDeQuestionsController;
use Helpers\Parametres\Parametres;
use Modules\Evaluation\Controller\AssociationController;
use Modules\Evaluation\Controller\CampaignController;
use Modules\Evaluation\Controller\CategoryController;
use Modules\Evaluation\Controller\EvaluationController;
use Modules\Evaluation\Controller\GroupOfRatersController;
use Modules\Evaluation\Controller\QuestionController;
use Modules\Evaluation\Controller\ImportBibliothequeController;
use Modules\Evaluation\Controller\ModelController;
use Modules\Evaluation\Controller\RaterController;
use Modules\Evaluation\Controller\RatersBySupplierController;

class EvaluationModule extends Module
{

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

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

        $parametres     = new Parametres();
        $id_campagne    = $parametres->expression_global_espace;
        $idCategorie    = $parametres->expression_global_espace;
        $modelId        = $parametres->expression_global_espace;
        $campaignId     = $parametres->expression_global_espace;
        $tab            = $parametres->expression_global_slash;
        $mode           = $parametres->expression_global_espace;
        $id             = $parametres->expression_global_espace;
        $type           = $parametres->expression_global_espace;
        $group          = $parametres->expression_global_espace_slash_accents_quotes;
        $supplier       = $parametres->id_fournisseur;
        $value          = $parametres->expression_global_espace;
        $company        = $parametres->expression_global_espace;
        $rater          = $parametres->expression_global_espace;
        $jwt            = $parametres->expression_point_tiret_underscore;
        $action         = $parametres->expression_global_espace;
        $user           = $parametres->expression_global_espace;

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

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

        // CONTROLLER Bibliotheque
        $router->get($base_url . '/bibliotheque/{mode:' . $id_campagne . '+}/{idCamp:' . $id_campagne . '+}', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.gestionBibliotheque');
        $router->get($base_url . '/bibliotheque/reset/{mode:' . $id_campagne . '+}/{id:' . $id_campagne . '+}', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.reset');
        $router->get($base_url . '/ajoutTheme/{mode:' . $id_campagne . '+}/{idCamp:' . $id_campagne . '+}[/{idPere:' . $id_campagne . '+}]', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.ajoutTheme');
        $router->get($base_url . '/modifierTheme/{mode:' . $id_campagne . '+}/{idCamp:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.modifierTheme');
        $router->get($base_url . '/supprimerTheme/{mode:' . $id_campagne . '+}/{idCamp:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.supprimerTheme');
        $router->get($base_url . '/detailQuestion/{mode:' . $id_campagne . '+}/{idCamp:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}/{idQuestion:' . $id_campagne . '+}', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.ajaxDetailQuestion');
        $router->get($base_url . '/noteurByOrigine', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.noteurByOrigine');
        $router->get($base_url . '/ajaxReOrder/{mode:' . $id_campagne . '+}/{idCamp:' . $id_campagne . '+}', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.ajaxReOrder');
        // POPUP NOTEUR // BIBLIOTHEQUE
        $router->get($base_url . '/popupNoteur/{origine_noteur:' . $id_campagne . '+}/{entity:' . $id_campagne . '+}', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.popupNoteur');
        $router->get($base_url . '/ajaxMenuContextuel/{mode:' . $id_campagne . '+}/{idCamp:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}', BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.ajaxMenuContextuel');

        // CONTROLLER Bibliothèque => Question
        $router->get($base_url . '/question/createEdit/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}[/{idQuestion:' . $id_campagne . '+}]', QuestionController::class, 'Evaluation.Question.createEdit');
        $router->get($base_url . '/question/deleteParentDependency/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}/{idQuestion:' . $id_campagne . '+}', QuestionController::class, 'Evaluation.Question.deleteParentDependency');
        $router->get($base_url . '/question/ajaxCheckRequest', QuestionController::class, 'Evaluation.Question.checkRequest');
        $router->get($base_url . '/question/validate/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}[/{idQuestion:' . $id_campagne . '+}]', QuestionController::class, 'Evaluation.Question.validate');
        $router->get($base_url . '/ajax/question/addResponse/{mode:' . $id_campagne . '+}', QuestionController::class, 'Evaluation.Question.addResponse');
        $router->get($base_url . '/ajax/question/addNote', QuestionController::class, 'Evaluation.Question.addNote');
        $router->get($base_url . '/ajax/question/addAnswer', QuestionController::class, 'Evaluation.Question.addExpectedAnswer');
        $router->get($base_url . '/question/delete/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}[/{idQuestion:' . $id_campagne . '+}]', QuestionController::class, 'Evaluation.Question.delete');
        $router->get($base_url . '/question/reOrder/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}', QuestionController::class, 'Evaluation.Question.reOrder');
        $router->get($base_url . '/ajax/question/noteur/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}', QuestionController::class, 'Evaluation.Question.ajaxNoteur');
        $router->get($base_url . '/ajax/question/dependency/{mode:' . $id_campagne . '+}/{id:' . $id_campagne . '+}/{theme:' . $id_campagne . '+}', QuestionController::class, 'Evaluation.Question.addDependency');
        $router->get($base_url . '/ajax/question/dependency/ruleTypes', QuestionController::class, 'Evaluation.Question.ruleTypes');
        $router->get($base_url . '/ajax/question/dependency/liste/{mode:' . $id_campagne . '+}/{id:' . $id_campagne . '+}/parentQuestionList[/{theme:' . $id_campagne . '+}[/{questionId:' . $id_campagne . '+}]]', QuestionController::class, 'Evaluation.Question.parentQuestionList');
        $router->get($base_url . '/ajax/question/dependency/options/{mode:' . $id_campagne . '+}/{id:' . $id_campagne . '+}/dependencyOptions', QuestionController::class, 'Evaluation.Question.generateDependencyOptions');
        $router->get($base_url . '/ajax/question/dependency/delete/{campId:' . $id_campagne . '+}/{parentThemeId:' . $id_campagne . '+}/{dependentThemeId:' . $id_campagne . '+}/{parentQuestionId:' . $id_campagne . '+}/{dependentQuestionId:' . $id_campagne . '+}', QuestionController::class, 'Evaluation.Question.deleteDependency');

        //AJAX GESTION EVALUATION Action modification
        $router->get($base_url . "/supprimerTableAssociation", AssociationController::class, 'Evaluation.Association.ajaxSupprimerTableAssociation');
        $router->get($base_url . "/ajouterLigneTableAssociation", BilbliothequeDeQuestionsController::class, 'Evaluation.BibliothequeDeQuestions.ajouterLigneTableAssociation');

        // ASSOCIATIONS
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/association", AssociationController::class, 'Evaluation.Association.index');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/association/new[/{type:$type+}[/{company:$company+}]]", AssociationController::class, 'Evaluation.Association.new');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/association/input/ajax", AssociationController::class, 'Evaluation.Association.input');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/association/validation/ajax[/{type:$type+}/{value:$value+}[/{company:$company+}]]", AssociationController::class, 'Evaluation.Association.ajaxValidation');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/association/edit/{type:$type+}/{value:$value+}[/{company:$company+}]", AssociationController::class, 'Evaluation.Association.edit');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/association/delete/{type:$type+}/{value:$value+}[/{company:$company+}]", AssociationController::class, 'Evaluation.Association.delete');

        // NOTEURS
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters", RaterController::class, 'Evaluation.Rater.index');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/table", RaterController::class, 'Evaluation.Rater.ratersTable');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/ajax/origin/{group:$id+}", RaterController::class, 'Evaluation.Rater.chooseOriginOfRater');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/new", RaterController::class, 'Evaluation.Rater.new');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/edit", RaterController::class, 'Evaluation.Rater.edit');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/delete", RaterController::class, 'Evaluation.Rater.delete');

            // groupe de noteurs
        $router->get($base_url . "/{mode:$mode+}/detail/groups/index[/{id:$id+}]", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.index');
        $router->get($base_url . "/{mode:$mode+}/detail/groups/createdit/{id:$id+}[/{group:$group+}]", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.creatEdit');
        $router->get($base_url . "/{mode:$mode+}/detail/groups/validate/{id:$id+}[/{group:$group+}]", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.validate');
        $router->get($base_url . "/{mode:$mode+}/detail/groups/delete/{group:$group+}[/{id:$id+}]", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.delete');
        $router->get($base_url . "/{mode:$mode+}/detail/groups/confirmedDelete/{group:$group+}[/{id:$id+}]", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.confirmedDelete');
        $router->get($base_url . "/{mode:$mode+}/detail/groups/export/{id:$id+}", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.export');
        $router->get($base_url . "/{mode:$mode+}/detail/groups/import/{id:$id+}", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.importIndex');
        $router->get($base_url . "/{mode:$mode+}/detail/groups/import/ajax/{id:$id+}", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.import');
        $router->get($base_url . "/{mode:$mode+}/detail/groups/import/summary/{id:$id+}", GroupOfRatersController::class, 'Evaluation.GroupOfRaters.importSummary');

            // noteurs pour groupe
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/groups/{group:$group+}/list", RaterController::class, 'Evaluation.Rater.ratersListForGroup');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/groups/add", RaterController::class, 'Evaluation.Rater.addRaterToGroup');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/groups/{group:$group+}/{rater:$rater+}/{origin:$rater+}/remove", RaterController::class, 'Evaluation.Rater.removeRaterFromGroup');
    
            // noteurs par fournisseurs
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/ratersBySuppliers/{supplier:$supplier+}/list", RaterController::class, 'Evaluation.Rater.ratersListForSupplier');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/ratersBySuppliers", RatersBySupplierController::class, 'Evaluation.RatersBySupplier.index');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/ratersBySuppliers/{supplier:$supplier+}/add", RatersBySupplierController::class, 'Evaluation.RatersBySupplier.addRaterToSuppplier');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/ratersBySuppliers/{supplier:$supplier+}/{rater:$rater+}/remove", RatersBySupplierController::class, 'Evaluation.RatersBySupplier.removeRaterFromSupplier');
    
            // noteurs pour campagne
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/list/{origin:$id+}", RaterController::class, 'Evaluation.Rater.ratersListForCampaign');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/external", RaterController::class, 'Evaluation.Rater.newExternalRater');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/add", RaterController::class, 'Evaluation.Rater.addRaterToCampaign');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/{rater:$rater+}/remove", RaterController::class, 'Evaluation.Rater.removeRaterFromCampaign');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/{rater:$rater+}/confirmedRemoval", RaterController::class, 'Evaluation.Rater.confirmedRaterRemoval');
        $router->get($base_url . "/{mode:$mode+}/detail/{id:$id+}/raters/validate/{origin:$id+}[/{group:$group+}]", RaterController::class, 'Evaluation.Rater.validateNewRaters');

        //controller import
        $router->get($base_url . '/import/listeModele/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}', ImportBibliothequeController::class, 'Evaluation.Import.listeImportModele');
        $router->get($base_url . '/import/modele/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{idModele:' . $id_campagne . '+}', ImportBibliothequeController::class, 'Evaluation.Import.importModele');

        $router->get($base_url . '/import/treeViewBibliotheque/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{typeImport:' . $id_campagne . '+}[/{idThemeCible:' . $id_campagne . '+}]', ImportBibliothequeController::class, 'Evaluation.Import.treeviewBibliotheque');
        $router->get($base_url . '/import/ajax/DetailTheme/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{typeImport:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}[/{idThemeCible:' . $id_campagne . '+}]', ImportBibliothequeController::class, 'Evaluation.Import.ajaxDetailTheme');
        $router->get($base_url . '/import/ajax/ajout/{mode:' . $id_campagne . '+}/{idMode:' . $id_campagne . '+}/{typeImport:' . $id_campagne . '+}/{idTheme:' . $id_campagne . '+}[/{idThemeCible:' . $id_campagne . '+}]', ImportBibliothequeController::class, 'Evaluation.Import.ajaxAjout');

        // Controller Catégories de Modèles
        $router->get($base_url . "/categorie", CategoryController::class, 'Evaluation.Category.index');
        $router->get($base_url . "/categorie/creation", CategoryController::class, 'Evaluation.Category.creationCategorie');
        $router->get($base_url . "/categorie/modification/{idCat:$idCategorie+}", CategoryController::class, 'Evaluation.Category.modificationCategorie');
        $router->get($base_url . "/categorie/suppression/{idCat:$idCategorie+}", CategoryController::class, 'Evaluation.Category.suppressionCategorie');
        $router->get($base_url . "/categorie/detail/{idCat:$idCategorie+}", CategoryController::class, 'Evaluation.Category.detailCategorie');
        $router->get($base_url . '/categorie/export', CategoryController::class, 'Evaluation.Category.export');
        $router->get($base_url . '/categorie/import', CategoryController::class, 'Evaluation.Category.importIndex');
        $router->get($base_url . '/categorie/import/ajax', CategoryController::class, 'Evaluation.Category.import');
        $router->get($base_url . '/categorie/import/summary', CategoryController::class, 'Evaluation.Category.importSummary');

        // Controller Modèles de questionnaires
        $router->get($base_url . "/modele", ModelController::class, 'Evaluation.Model.index');
        $router->get($base_url . "/modele/creation", ModelController::class, 'Evaluation.Model.creation');
        $router->get($base_url . "/modele/creatEdit[/{id:$campaignId+}]", ModelController::class, 'Evaluation.Model.createEdit');
        $router->get($base_url . "/modele/validate[/{id:$campaignId+}]", ModelController::class, 'Evaluation.Model.validate');
        $router->get($base_url . "/modele/modification/{id:$modelId+}", ModelController::class, 'Evaluation.Model.modification');
        $router->get($base_url . "/modele/suppression/{id:$modelId+}", ModelController::class, 'Evaluation.Model.suppression');
        $router->get($base_url . "/modele/detail/{id:$modelId+}", ModelController::class, 'Evaluation.Model.detail');
        $router->get($base_url . "/modele/export", ModelController::class, 'Evaluation.Model.export');

        // Controller Campagnes d'évaluation
        $router->get($base_url . "/campagne", CampaignController::class, 'Evaluation.Campaign.index');
        $router->get($base_url . "/campagne/createdit[/{id:$campaignId+}]", CampaignController::class, 'Evaluation.Campaign.createdit');
        $router->get($base_url . "/campagne/duplicate/{id:$campaignId+}", CampaignController::class, 'Evaluation.Campaign.duplicate');
        $router->get($base_url . "/campagne/validation/{id:$campaignId+}[/{confirm:$value+}]", CampaignController::class, 'Evaluation.Campaign.validation');
        $router->get($base_url . "/campagne/devalidation/{id:$campaignId+}", CampaignController::class, 'Evaluation.Campaign.devalidation');
        $router->get($base_url . "/campagne/close/{id:$campaignId+}[/{confirm:$value+}]", CampaignController::class, 'Evaluation.Campaign.cloture');
        $router->get($base_url . "/campagne/ajax/validate[/{id:$campaignId+}[/{action:$action+}]]", CampaignController::class, 'Evaluation.Campaign.validate');
        $router->get($base_url . "/campagne/suppression/{id:$campaignId+}", CampaignController::class, 'Evaluation.Campaign.suppression');
        $router->get($base_url . "/campagne/detail/{id:$campaignId+}[/{tab:$tab+}]", CampaignController::class, 'Evaluation.Campaign.detail');
        $router->get($base_url . "/campagne/export", CampaignController::class, 'Evaluation.Campaign.export');
        $router->get($base_url . "/campagne/{id:$campaignId+}/fournisseur", CampaignController::class, 'Evaluation.Campaign.supplierList');
        $router->get($base_url . "/campagne/{id:$campaignId+}/fournisseur/ajout", CampaignController::class, 'Evaluation.Campaign.addSupplier');
        $router->get($base_url . "/campagne/{id:$campaignId+}/fournisseur/{supplier:$supplier+}/suppression", CampaignController::class, 'Evaluation.Campaign.supplierRemove');
        $router->get($base_url . "/campagne/{id:$campaignId+}/fournisseur/import", CampaignController::class, 'Evaluation.Campaign.supplierImportIndex');
        $router->get($base_url . "/campagne/{id:$campaignId+}/fournisseur/import/ajax", CampaignController::class, 'Evaluation.Campaign.supplierImport');
        $router->get($base_url . "/campagne/{id:$campaignId+}/fournisseur/import/summary", CampaignController::class, 'Evaluation.Campaign.supplierImportSummary');
        $router->get($base_url . "/campagne/suivi[/{id:$campaignId+}]", CampaignController::class, 'Evaluation.Campaign.monitoring');
        $router->get($base_url . "/campagne/etat-avancement/{id:$campaignId+}", CampaignController::class, 'Evaluation.Campaign.etatAvancement');
        $router->get($base_url . "/campagne/detail-etat-avancement/{id:$campaignId+}/{user:$user+}/{externe:$value+}", CampaignController::class, 'Evaluation.Campaign.detailEtatAvancement');
        $router->get($base_url . "/campagne/resultatCampagne/{id:$campaignId+}", CampaignController::class, 'Evaluation.Campaign.resultatCampagne');
        $router->get($base_url . "/campagne/detail-etat-avancement-campagne/{id:$campaignId+}[/{type:$value+}]", CampaignController::class, 'Evaluation.Campaign.detailEtatAvancementByCampagne');
        $router->get($base_url . "/campagne/popup-confirmation-devalidation", CampaignController::class, 'Evaluation.Campaign.popupConfirmationDevalidation');
        $router->get($base_url . "/campagne/relance-evaluateurs/{id:$campaignId+}", CampaignController::class, 'Evaluation.Campaign.resumeRaters');

        // Controller Evaluation
        $router->get($base_url . "/notation[/{jwt:$jwt+}]", EvaluationController::class, 'Evaluation.Evaluation.index');
        $router->get($base_url . "/visu-not[/{visu:$value+}]", EvaluationController::class, 'Evaluation.Evaluation.indexVisu');
        $router->get($base_url . "/notation/detailParFournisseur/{idCamp:$campaignId+}[/{visu:$value+}]", EvaluationController::class, 'Evaluation.Evaluation.detailCampagneFounisseurByUser');
        $router->get($base_url . "/notation/saisie-de-reponse/{idCamp:$campaignId+}/{idFrs:$supplier+}[/{jwt:$jwt+}[/{user:$id+}/{externe:$id+}]]", EvaluationController::class, 'Evaluation.Evaluation.saisieDeReponse');
        $router->get($base_url . "/notation/saisie-de-reponse-visu/{idCamp:$campaignId+}/{idFrs:$supplier+}/{visu:$value+}", EvaluationController::class, 'Evaluation.Evaluation.saisieDeReponseVisu');
        $router->get($base_url . "/saisie-de-reponse/validation/{idCamp:$campaignId+}/{idFrs:$supplier+}", EvaluationController::class, 'Evaluation.Evaluation.validationReponse');
        $router->get($base_url . "/saisie-de-reponse/enregistrement/{idCamp:$campaignId+}/{idFrs:$supplier+}", EvaluationController::class, 'Evaluation.Evaluation.ajaxUpdateValue');
        
        $router->get($base_url . "/notation/question-calcule/question/{idCamp:$campaignId+}/{idFrs:$supplier+}", EvaluationController::class, 'Evaluation.Evaluation.questionDependante');
        
        $router->get($base_url . "/saisie-reponse/Confirmation", EvaluationController::class, 'Evaluation.Evaluation.popupValidationIfDependance');
    }
}
