Commit 7f8caf03 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction du problème de MAJ des valeurs des plafonds

parent 3c495ecc
Loading
Loading
Loading
Loading
+3 −6
Changes for module/Intervenant/src/Controller/StatutController.php: 3 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -72,17 +72,14 @@ class StatutController extends AbstractController
            $title = $statut->getLibelle();
        }

        $plafonds = $this->getServicePlafond()->getPlafondsConfig($statut);

        $canEdit = $this->isAllowed($statut, Privileges::INTERVENANT_STATUT_EDITION);
        if ($canEdit) {
            $request = $this->getRequest();
            $form->bindRequestSave($statut, $request, function (Statut $si) use ($plafonds, $request) {
            $form->bindRequestSave($statut, $request, function (Statut $si) use ($request) {
                $isNew = !$si->getId();
                $this->getServiceStatut()->save($si);
                $this->getFormPlafondConfig()->requestSaveConfigs($plafonds, $request);
                $this->getFormPlafondConfig()->requestSaveConfigs($si, $request);
                unset($this->getCacheContainer(RoleProvider::class)->statutsInfo);
                $plafonds = $this->getServicePlafond()->getPlafondsConfig($si);
                $this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
                if ($isNew) {
                    $this->redirect()->toRoute('statut/saisie', ['statut' => $si->getId()]);
@@ -95,7 +92,7 @@ class StatutController extends AbstractController

        $vm = new ViewModel();
        $vm->setTemplate('intervenant/statut/saisie');
        $vm->setVariables(compact('typesIntervenants', 'canEdit', 'statut', 'statuts', 'form', 'title', 'plafonds'));
        $vm->setVariables(compact('typesIntervenants', 'canEdit', 'statut', 'statuts', 'form', 'title'));

        return $vm;
    }
+0 −1
Changes for module/Intervenant/view/intervenant/statut/saisie.phtml: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ use Application\Provider\Privilege\Privileges;
 * @var $statuts           \Intervenant\Entity\Db\Statut[]
 * @var $statut            \Intervenant\Entity\Db\Statut
 * @var $form              \Intervenant\Form\StatutSaisieForm
 * @var $plafonds          \Plafond\Interfaces\PlafondConfigInterface[]
 * @var $title             string
 */

+20 −0
Changes for module/Plafond/src/Entity/Db/Plafond.php: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace Plafond\Entity\Db;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Plafond\Interfaces\PlafondConfigInterface;

/**
 * Plafond
@@ -154,6 +155,25 @@ class Plafond



    public function addConfig(PlafondConfigInterface $plafondConfig): self
    {
        if ($plafondConfig->getPlafond() !== $this) {
            throw new \Exception('Mauvais plafond transmis');
        }

        if ($plafondConfig instanceof PlafondStatut) {
            $this->plafondStatut->add($plafondConfig);
        } elseif ($plafondConfig instanceof PlafondStructure) {
            $this->plafondStructure->add($plafondConfig);
        } elseif ($plafondConfig instanceof PlafondReferentiel) {
            $this->plafondReferentiel->add($plafondConfig);
        }

        return $this;
    }



    /**
     * The __toString method allows a class to decide how it will react when it is converted to a string.
     *
+6 −1
Changes for module/Plafond/src/Form/PlafondConfigForm.php: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2,7 +2,10 @@

namespace Plafond\Form;

use Application\Entity\Db\FonctionReferentiel;
use Application\Entity\Db\Structure;
use Application\Form\AbstractForm;
use Intervenant\Entity\Db\Statut;
use Laminas\Form\Element;
use Laminas\Http\Request;
use Plafond\Entity\Db\Plafond;
@@ -126,12 +129,14 @@ class PlafondConfigForm extends AbstractForm
     *
     * @return void
     */
    public function requestSaveConfigs(array $plafondConfigs, Request $request)
    public function requestSaveConfigs(Statut|Structure|FonctionReferentiel $entity, Request $request)
    {
        $heures      = $request->getPost('heures', []);
        $etatPrevu   = $request->getPost('plafondEtatPrevu', []);
        $etatRealise = $request->getPost('plafondEtatRealise', []);

        $plafondConfigs = $this->getServicePlafond()->getPlafondsConfig($entity);

        foreach ($plafondConfigs as $plafondConfig) {
            if (isset($heures[$plafondConfig->getPlafond()->getId()])) {
                $v = stringToFloat($heures[$plafondConfig->getPlafond()->getId()]);
+4 −1
Changes for module/Plafond/src/Service/PlafondService.php: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -614,7 +614,7 @@ class PlafondService extends AbstractEntityService
        if ($entity instanceof FonctionReferentiel) {
            return PlafondReferentiel::class;
        }
        throw new \Exception("L'entité fournie ne permet pas e récupérer une configuration de plafond");
        throw new \Exception("L'entité fournie ne permet pas de récupérer une configuration de plafond");
    }


@@ -734,6 +734,9 @@ class PlafondService extends AbstractEntityService
            $plafondConfig->setEtatRealise($this->getEtat(PlafondEtat::DESACTIVE));
        }

        if (!$plafondConfig->getId()) {
            $plafondConfig->getPlafond()->addConfig($plafondConfig);
        }
        $this->getEntityManager()->persist($plafondConfig);
        $this->getEntityManager()->flush($plafondConfig);