Commit fea0cc4b authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Fin refonte enquete + refonte affiche Structure > formation

parent 5fd8a7d0
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ return [
                    'controller' => FormationController::class,
                    'action' => [
                        'rechercher-formation',
                        'rechercher-formateur',
                    ],
                    'roles' => [],
                ],
@@ -250,6 +251,17 @@ return [
                            ],
                        ],
                    ],
                    'rechercher-formateur' => [
                        'type'  => Literal::class,
                        'may_terminate' => true,
                        'options' => [
                            'route'    => '/rechercher-formateur',
                            'defaults' => [
                                'controller' => FormationController::class,
                                'action'     => 'rechercher-formateur',
                            ],
                        ],
                    ],
                ],
            ],
        ],
+16 −1
Original line number Diff line number Diff line
@@ -5,17 +5,30 @@ namespace Formation\Controller;
use Formation\Entity\Db\EnqueteReponse;
use Formation\Service\EnqueteCategorie\EnqueteCategorieServiceAwareTrait;
use Formation\Service\EnqueteReponse\EnqueteReponseServiceAwareTrait;
use Formation\Service\Formateur\FormateurServiceAwareTrait;
use Formation\Service\Formation\FormationServiceAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;

class EnqueteReponseController extends AbstractActionController {
    use EnqueteCategorieServiceAwareTrait;
    use EnqueteReponseServiceAwareTrait;
    use FormationServiceAwareTrait;
    use FormateurServiceAwareTrait;

    public function afficherResultatsAction() : ViewModel
    {
        $fromQueries  = $this->params()->fromQuery();
        $formationId = (isset($fromQueries['formation']) AND isset($fromQueries['formation']['id']))?((int) $fromQueries['formation']['id']):null;
        $params = [
            'formation' => $this->getFormationService()->getFormation($formationId),
            'formateur' => $fromQueries['formateur']['id'],
            'formateur_denomination' => $fromQueries['formateur']['label'],
            'annee'     =>  $fromQueries['annee'],
        ];

        $categories = $this->getEnqueteCategorieService()->getEnqueteCateories();
        $reponses = $this->getEnqueteReponseService()->getEnqueteReponses();
        $reponses = $this->getEnqueteReponseService()->getEnqueteReponsesWithFiltre($params);

        $histogramme = [];
        foreach ($categories as $categorie) {
@@ -46,6 +59,8 @@ class EnqueteReponseController extends AbstractActionController {
            "reponses" => $reponses,
            "array" => $array,
            "histogramme" => $histogramme,

            "params" => $params,
        ]);
    }
}
 No newline at end of file
+8 −0
Original line number Diff line number Diff line
@@ -9,6 +9,8 @@ use Formation\Form\EnqueteReponse\EnqueteReponseForm;
use Formation\Service\EnqueteCategorie\EnqueteCategorieService;
use Formation\Service\EnqueteQuestion\EnqueteQuestionService;
use Formation\Service\EnqueteReponse\EnqueteReponseService;
use Formation\Service\Formateur\FormateurService;
use Formation\Service\Formation\FormationService;
use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@@ -26,13 +28,19 @@ class EnqueteReponseControllerFactory {
        /**
         * @var EnqueteCategorieService $enqueteCategorieService
         * @var EnqueteReponseService $enqueteReponseService
         * @var FormationService $formationService
         * @var FormateurService $formateurService
         */
        $enqueteCategorieService = $container->get(EnqueteCategorieService::class);
        $enqueteReponseService = $container->get(EnqueteReponseService::class);
        $formationService = $container->get(FormationService::class);
        $formateurService = $container->get(FormateurService::class);

        $controller = new EnqueteReponseController();
        $controller->setEnqueteCategorieService($enqueteCategorieService);
        $controller->setEnqueteReponseService($enqueteReponseService);
        $controller->setFormationService($formationService);
        $controller->setFormateurService($formateurService);

        return $controller;
    }
+16 −0
Original line number Diff line number Diff line
@@ -20,11 +20,14 @@ use Formation\Service\FormationInstance\FormationInstanceServiceAwareTrait;
use Laminas\Http\Request;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\Mvc\Plugin\FlashMessenger\FlashMessenger;
use Laminas\View\Model\JsonModel;
use Laminas\View\Model\ViewModel;
use UnicaenDbImport\Entity\Db\Service\Source\SourceServiceAwareTrait;
use UnicaenDbImport\Entity\Db\Source;

/** @method FlashMessenger flashMessenger() */

class FormationController extends AbstractActionController
{
    use FormationInstanceServiceAwareTrait;
@@ -87,6 +90,9 @@ class FormationController extends AbstractActionController
                $formation->setSource($source);
                $formation->setIdSource($formation->getId());
                $this->getFormationService()->update($formation);

                $url = $this->url()->fromRoute('formation/editer', ['formation' => $formation->getId()], ['force_canonical' => true], true);
                $this->flashMessenger()->addSuccessMessage("Action de formation <strong>".$formation->getLibelle()."</strong> créée. Pour accéder à celle-ci vous pouvez utiliser le lien suivant : <a href='".$url."'>".$url."</a>");
                exit;
            }
        }
@@ -279,6 +285,16 @@ class FormationController extends AbstractActionController
        exit;
    }

    public function rechercherFormateurAction() : JsonModel
    {
        if (($term = $this->params()->fromQuery('term'))) {
            $formateurs = $this->getFormationService()->findFormateurByTerm($term);
            $result = $this->getFormationService()->formatFormateurJSON($formateurs);
            return new JsonModel($result);
        }
        exit;
    }

    /** DEBOULONNAGE **************************************************************************************************/

    public function dedoublonnerAction() : ViewModel
+6 −0
Original line number Diff line number Diff line
@@ -141,6 +141,12 @@ class DemandeExterne implements HistoriqueAwareInterface, ResourceInterface {
        return $this->getFin()->format('d/m/Y');
    }

    public function getPeriodeAsString() : string
    {
        if ($this->getDebut() === $this->getFin()) return $this->getDebutAsString();
        return $this->getDebutAsString()." au ".$this->getFinAsString();
    }

    public function setFin(?DateTime $fin): void
    {
        $this->fin = $fin;
Loading