Commit 0f6ba2cc authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

PlafondStructure devenu inutile

parent 02c89763
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -9,8 +9,6 @@ return [
    'Plafond\Controller\DerogationControllerFactory'            => __DIR__ . '/src/Controller/DerogationControllerFactory.php',
    'Plafond\Controller\PlafondController'                      => __DIR__ . '/src/Controller/PlafondController.php',
    'Plafond\Controller\PlafondControllerFactory'               => __DIR__ . '/src/Controller/PlafondControllerFactory.php',
    'Plafond\Controller\PlafondStructureController'             => __DIR__ . '/src/Controller/PlafondStructureController.php',
    'Plafond\Controller\PlafondStructureControllerFactory'      => __DIR__ . '/src/Controller/PlafondStructureControllerFactory.php',
    'Plafond\Entity\Db\Plafond'                                 => __DIR__ . '/src/Entity/Db/Plafond.php',
    'Plafond\Entity\Db\PlafondApplication'                      => __DIR__ . '/src/Entity/Db/PlafondApplication.php',
    'Plafond\Entity\Db\PlafondDerogation'                       => __DIR__ . '/src/Entity/Db/PlafondDerogation.php',
@@ -29,8 +27,6 @@ return [
    'Plafond\Processus\PlafondProcessusFactory'                 => __DIR__ . '/src/Processus/PlafondProcessusFactory.php',
    'Plafond\Service\PlafondService'                            => __DIR__ . '/src/Service/PlafondService.php',
    'Plafond\Service\PlafondServiceFactory'                     => __DIR__ . '/src/Service/PlafondServiceFactory.php',
    'Plafond\Service\PlafondStructureService'                   => __DIR__ . '/src/Service/PlafondStructureService.php',
    'Plafond\Service\PlafondStructureServiceFactory'            => __DIR__ . '/src/Service/PlafondStructureServiceFactory.php',
    'Plafond\View\Helper\PlafondConfigElementViewHelper'        => __DIR__ . '/src/View/Helper/PlafondConfigElementViewHelper.php',
    'Plafond\View\Helper\PlafondConfigElementViewHelperFactory' => __DIR__ . '/src/View/Helper/PlafondConfigElementViewHelperFactory.php',
];
 No newline at end of file
+0 −80
Original line number Diff line number Diff line
<?php

namespace Plafond\Controller;

use Application\Controller\AbstractController;
use Application\Entity\Db\Structure;
use Application\Service\Traits\ContextServiceAwareTrait;
use Laminas\View\Model\JsonModel;
use Plafond\Entity\Db\Plafond;
use Plafond\Entity\Db\PlafondEtat;
use Plafond\Entity\Db\PlafondPerimetre;
use Plafond\Form\PlafondConfigFormAwareTrait;
use Plafond\Service\PlafondStructureServiceAwareTrait;


/**
 * Description of PlafondStructureController
 *
 * @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
 */
class PlafondStructureController extends AbstractController
{
    use PlafondStructureServiceAwareTrait;
    use ContextServiceAwareTrait;
    use PlafondConfigFormAwareTrait;

    public function indexAction()
    {
        $title = 'Gestion des plafonds';
        $form  = $this->getFormPlafondConfig();
        $annee = $this->getServiceContext()->getAnnee();
        /* @var $structure Structure */
        $structure = $this->getEvent()->getParam('structure');

        $dql = "
        SELECT
          p, prm, ps
        FROM
          " . Plafond::class . " p
          JOIN p.plafondPerimetre prm WITH prm.code = '" . PlafondPerimetre::STRUCTURE . "'
          LEFT JOIN p.plafondStructure ps WITH ps.annee = :annee AND ps.histoDestruction IS NULL AND ps.structure = :structure
        ORDER BY
            p.libelle
        ";

        /* @var $plafonds Plafond[] */
        $query = $this->em()->createQuery($dql)->setParameters(['annee' => $annee->getId(), 'structure' => $structure->getId()]);
        $form->setPlafonds($query->getResult());

        return compact('title', 'structure', 'form');
    }



    public function editerAction()
    {
        /** @var Plafond $plafond */
        $plafond = $this->em()->find(Plafond::class, $this->params()->fromPost('plafond'));
        $name    = $this->params()->fromPost('name');
        $value   = $this->params()->fromPost('value');

        $ps = $plafond->getPlafondStructure();

        switch ($name) {
            case 'plafondEtatPrevu':
                $ps->setEtatPrevu($this->em()->find(PlafondEtat::class, $value));
            break;
            case 'plafondEtatRealise':
                $ps->setEtatRealise($this->em()->find(PlafondEtat::class, $value));
            break;
            case 'heures':
                $ps->setHeures(stringToFloat($value));
            break;
        }
        $this->getServicePlafond()->saveConfig($ps);

        return new JsonModel([]);
    }

}
 No newline at end of file
+0 −31
Original line number Diff line number Diff line
<?php

namespace Plafond\Controller;

use Psr\Container\ContainerInterface;


/**
 * Description of PlafondStructureControllerFactory
 *
 * @author UnicaenCode
 */
class PlafondStructureControllerFactory
{

    /**
     * @param ContainerInterface $container
     * @param string             $requestedName
     * @param array|null         $options
     *
     * @return PlafondStructureController
     */
    public function __invoke(ContainerInterface $container, $requestedName, $options = null): PlafondStructureController
    {
        $controller = new PlafondStructureController;

        /* Injectez vos dépendances ICI */

        return $controller;
    }
}
 No newline at end of file
+0 −59
Original line number Diff line number Diff line
<?php

namespace Plafond\Service;

use Application\Service\AbstractEntityService;
use Plafond\Entity\Db\PlafondStructure;

/**
 * Description of PlafondStructureService
 *
 * @author UnicaenCode
 *
 * @method PlafondStructure get($id)
 * @method PlafondStructure[] getList(\Doctrine\ORM\QueryBuilder $qb = null, $alias = null)
 *
 */
class PlafondStructureService extends AbstractEntityService
{

    /**
     * retourne la classe des entités
     *
     * @return string
     * @throws RuntimeException
     */
    public function getEntityClass(): string
    {
        return PlafondStructure::class;
    }



    /**
     * Retourne l'alias d'entité courante
     *
     * @return string
     */
    public function getAlias(): string
    {
        return 'plastruct';
    }



    /**
     * Retourne une nouvelle entité de la classe donnée
     *
     * @return PlafondStructure
     */
    public function newEntity()
    {
        /** @var $entity \Plafond\Entity\Db\PlafondStructure */
        $entity = parent::newEntity();
        $entity->setAnnee($this->getServiceContext()->getAnnee());

        return $entity;
    }

}
 No newline at end of file
+0 −39
Original line number Diff line number Diff line
<?php

namespace Plafond\Service;


/**
 * Description of PlafondStructureServiceAwareTrait
 *
 * @author UnicaenCode
 */
trait PlafondStructureServiceAwareTrait
{
    protected ?PlafondStructureService $servicePlafondStructure = null;



    /**
     * @param PlafondStructureService $servicePlafondStructure
     *
     * @return self
     */
    public function setServicePlafondStructure( ?PlafondStructureService $servicePlafondStructure )
    {
        $this->servicePlafondStructure = $servicePlafondStructure;

        return $this;
    }



    public function getServicePlafondStructure(): ?PlafondStructureService
    {
        if (empty($this->servicePlafondStructure)){
            $this->servicePlafondStructure = \Application::$container->get(PlafondStructureService::class);
        }

        return $this->servicePlafondStructure;
    }
}
 No newline at end of file
Loading