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

Fix

parent 977fded8
Loading
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -143,6 +143,9 @@ class FormulaireController extends AbstractActionController
            $data = $request->getPost();
            if ($data["reponse"] === "oui") {
                foreach ($instances as $instance) {
                    foreach ($instance->getReponses() as $reponse) {
                        $this->getFormulaireReponseService()->delete($reponse);
                    }
                    $this->getFormulaireInstanceService()->delete($instance);
                }
                $this->getFormulaireService()->delete($formulaire);
@@ -581,16 +584,17 @@ class FormulaireController extends AbstractActionController
            $this->getCategorieService()->create($newCategorie);
            $duplicata->addCategorie($newCategorie);

            foreach ($newCategorie->getChamps() as $champ) {
            foreach ($categorie->getChamps() as $champ) {
                $newChamp = Champ::clone($champ, true, $newCategorie);
                $this->getChampService()->create($newChamp);
                $newCategorie->addChamp($newChamp);
                $this->getCategorieService()->update($newCategorie);
            }
        }

        $this->getFormulaireService()->update($duplicata);

        /** @see FormulaireController::modifierAction() */
        return $this->redirect()->toRoute('autoform/formulaire/modifier',['formulaire' => $formulaire->getId()], [], true);
        return $this->redirect()->toRoute('autoform/formulaire/modifier',['formulaire' => $duplicata->getId()], [], true);
    }
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace UnicaenAutoform\Entity\Db;

use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use UnicaenAutoform\Entity\HasMotsClefsAwareTrait;
@@ -29,7 +30,7 @@ class Categorie implements HistoriqueAwareInterface, HasMotsClefsInterface
    public static function clone(Categorie $categorie, bool $withHisto = true): Categorie
    {
        $clone = new Categorie();
        $clone->setCode($categorie->getCode() . " DUPLICATA");
        $clone->setCode($categorie->getCode() . " DUPLICATA " . (new DateTime())->getTimestamp());
        $clone->setLibelle($categorie->getLibelle());
        $clone->setOrdre($categorie->getOrdre());
        $clone->setMotsClefs($categorie->getMotsClefs());
+3 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace UnicaenAutoform\Entity\Db;

use DateTime;
use UnicaenAutoform\Entity\HasMotsClefsAwareTrait;
use UnicaenAutoform\Entity\HasMotsClefsInterface;
use UnicaenUtilisateur\Entity\Db\HistoriqueAwareInterface;
@@ -48,9 +49,9 @@ class Champ implements HistoriqueAwareInterface, HasMotsClefsInterface {
    {
        $clone = new Champ();
        if ($newCategorie !== null) $clone->setCategorie($newCategorie);
        $clone->setCode($champ->getCode() . " DUPLICATA");
        $clone->setCode($champ->getCode() . " DUPLICATA ". (new DateTime())->getTimestamp());
        $clone->setLibelle($champ->getLibelle());
        $clone->setType($champ->getTexte());
        $clone->setTexte($champ->getTexte());
        $clone->setOrdre($champ->getOrdre());
        $clone->setType($champ->getType());
        $clone->setBalise($champ->getBalise());