Commit c9e9c4d6 authored by Jean-Baptiste Oellers's avatar Jean-Baptiste Oellers
Browse files

Ajout champ texte libre

parent e0293cfe
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ class ConventionModeleEtapeAdministrationController extends AbstractOscarControl
            return $this->redirect()->toRoute('administration/conventionModeles/configurer', ['id' => $conventionModele->id]);
        } else if ($this->params()->fromPost('action') == "ajouter_information") {
            $this->conventionModeleEtapeService->ajouterInformation($conventionModeleEtape,
             $this->params()->fromPost('nom'), $this->getCurrentPerson());
             $this->params()->fromPost('nom'), $this->params()->fromPost('type'), $this->getCurrentPerson());
        } else if ($this->params()->fromPost('action') == "supprimer_information") {
            /** @var \Oscar\Entity\ConventionModeleEtapeInformation $conventionModeleEtapeInformation */
            $conventionModeleEtapeInformation = $this->getEntityManager()->find(\Oscar\Entity\ConventionModeleEtapeInformation::class, $this->params()->fromPost('id'));
+21 −1
Original line number Diff line number Diff line
@@ -23,7 +23,27 @@ class ConventionModeleInstanceController extends AbstractOscarController impleme
            return ['conventionModeleInstance' => $conventionModeleInstance];
        }

        if ($this->params()->fromPost('action') == "enregistrer_reponse") {
        if ($this->params()->fromPost('action') == "enregistrer_reponses") {

            $reponses = [];
            foreach ($conventionModeleInstance->conventionModeleEtapeEnCours->informations as $information) {
                $reponses[$information->nom] = $this->params()->fromPost('reponse-' . $information->id, '');
            }

            $this->conventionModeleInstanceService->enregitrerRéponses($conventionModeleInstance, $reponses, $this->getCurrentPerson());

            if ($conventionModeleInstance->conventionModeleEtapeEnCours->conventionModeleEtapeSuivante != NULL) {
                $conventionModeleInstance->conventionModeleEtapeEnCours = $conventionModeleInstance->conventionModeleEtapeEnCours->conventionModeleEtapeSuivante;
            } else {
                $this->créerActivité($conventionModeleInstance->conventionModeleEtapeEnCours, $conventionModeleInstance);
                $conventionModeleInstance->conventionModeleEtapeEnCours = NULL;
            }
            
            $conventionModeleInstance->updatedBy = $this->getCurrentPerson();
            $conventionModeleInstance->dateUpdated = new \DateTime();
            $this->getEntityManager()->flush();

        } else if ($this->params()->fromPost('action') == "enregistrer_reponse") {
            $this->conventionModeleInstanceService->enregitrerRéponse($conventionModeleInstance, $this->params()->fromQuery('question', ''), $this->params()->fromQuery('reponse', ''), $this->getCurrentPerson());

            if ($conventionModeleInstance->conventionModeleEtapeEnCours->conventionModeleEtapeSuivante != NULL) {
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class ConventionModeleEtape
     *
     * @var \Doctrine\Common\Collections\ArrayCollection
     * @ORM\OneToMany(targetEntity="ConventionModeleEtapeInformation", mappedBy="conventionModeleEtape", cascade={"remove"}, fetch="EAGER")
     * @ORM\OrderBy({"nom" = "ASC"})
     * @ORM\OrderBy({"id" = "ASC"})
     */
    public $informations;

+12 −0
Original line number Diff line number Diff line
@@ -54,6 +54,18 @@ class ConventionModeleEtapeInformation
     */
    public $conventionModeleEtape;

    /**
     * Type d'information
     * 
     * @var string
     * @ORM\Column(type="text")
     */
    public $type;

    const TYPE_CHOIX_D_UNE_SEULE_REPONSE_PARMI_DES_PROPOSITIONS = 'Choix d\'une seule réponse parmi des propositions';
    const TYPE_SAISIE_LIBRE = 'Saisie libre';
    const TYPES = [\Oscar\Entity\ConventionModeleEtapeInformation::TYPE_CHOIX_D_UNE_SEULE_REPONSE_PARMI_DES_PROPOSITIONS, \Oscar\Entity\ConventionModeleEtapeInformation::TYPE_SAISIE_LIBRE];

    /**
     * Liste des réponses.
     *
+7 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class ConventionModeleEtapeService implements UseEntityManager, UseLoggerService
    $this->getEntityManager()->flush();
  }

  public function ajouterInformation(\Oscar\Entity\ConventionModeleEtape $etape, string $nom, \Oscar\Entity\Person $person): void
  public function ajouterInformation(\Oscar\Entity\ConventionModeleEtape $etape, string $nom, string $type, \Oscar\Entity\Person $person): void
  {
    $this->getLoggerService()->info("ConventionModeleEtapeService ajouterInformation");
    $this->getLoggerService()->info("by: " . $person);
@@ -64,6 +64,12 @@ class ConventionModeleEtapeService implements UseEntityManager, UseLoggerService
    $information = new \Oscar\Entity\ConventionModeleEtapeInformation();
    $information->createdBy = $person;
    $information->nom = $nom;
    $information->type = $type;

    if (!in_array($type, \Oscar\Entity\ConventionModeleEtapeInformation::TYPES)) {
      throw new \Exception("Type d'information invalide.");
    }

    $information->conventionModeleEtape = $etape;
    $this->getEntityManager()->persist($information);
    $this->getEntityManager()->flush();
Loading