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

(WIP) Remise en forme de l'affichage des compétences et applications (vers la GPEC)

parent e63fad98
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ use Formation\Entity\Db\Formation;
                $class = 'raison formation';
                break;
            case $raison instanceof Agent :
                $text = "Liée à l'agent <span class='highlight formation'>" . $raison->getDenomination() . "</span>";
                $text = "Liée à l'agent <span class='highlight agent'>" . $raison->getDenomination(true) . "</span>";
                $label = "Agent";
                $class = 'agent';
                break;
@@ -51,7 +51,7 @@ use Formation\Entity\Db\Formation;

        }
        ?>
        <span class="raison <?php echo $class; ?>" title="<?php echo $text; ?>" ><?php echo $label; ?></span>
        <span data-bs-toggle='tooltip' data-bs-html='true' class="raison <?php echo $class; ?>" title="<?php echo $text; ?>" ><?php echo $label; ?></span>
    <?php endforeach;?>
<?php endif; ?>

+5 −0
Original line number Diff line number Diff line
@@ -164,9 +164,14 @@ class ApplicationController extends AbstractActionController {
    {
        $application = $this->getApplicationService()->getRequestedApplication($this, 'id');

        $agents = $this->getApplicationElementService()->getAgentsHavingApplicationFromAgent($application);
        $fichesmetiers = $this->getApplicationElementService()->getFicheMetierHavingApplication($application);

        return new ViewModel([
            'title' => "Description de l'application",
            'application' => $application,
            'agents' => $agents,
            'fichesmetiers' => $fichesmetiers,
        ]);
    }

+2 −0
Original line number Diff line number Diff line
@@ -52,11 +52,13 @@ class CompetenceController extends AbstractActionController
    public function afficherAction() : ViewModel
    {
        $competence = $this->getCompetenceService()->getRequestedCompetence($this);
        $agents = $this->getCompetenceElementService()->getAgentsHavinCompetenceFromAgent($competence);
        $missions = $this->getMissionPrincipaleService()->getMissionsHavingCompetence($competence);
        $fiches = $this->getFicheMetierService()->getFichesMetiersByCompetence($competence);
        return new ViewModel([
            'title' => "Affiche d'une compétence",
            'competence' => $competence,
            'agents' => $agents,
            'missions' => $missions,
            'fiches' => $fiches,
        ]);
+37 −31
Original line number Diff line number Diff line
@@ -2,70 +2,53 @@

namespace Element\Service\ApplicationElement;

use Application\Entity\Db\Agent;
use DoctrineModule\Persistence\ProvidesObjectManager;
use Element\Entity\Db\Application;
use Element\Entity\Db\ApplicationElement;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\QueryBuilder;
use FicheMetier\Entity\Db\FicheMetier;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Service\EntityManagerAwareTrait;
use Laminas\Mvc\Controller\AbstractActionController;

class ApplicationElementService {
    use EntityManagerAwareTrait;
    use ProvidesObjectManager;
    
    /** Gestion des entites ***************************************************************************************/

    public function create(ApplicationElement $element) : ApplicationElement
    {
        try {
            $this->getEntityManager()->persist($element);
            $this->getEntityManager()->flush($element);
        } catch (ORMException $e) {
            throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
        }
        $this->getObjectManager()->persist($element);
        $this->getObjectManager()->flush($element);
        return $element;
    }

    public function update(ApplicationElement $element) : ApplicationElement
    {
        try {
            $this->getEntityManager()->flush($element);
        } catch (ORMException $e) {
            throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
        }
        $this->getObjectManager()->flush($element);
        return $element;
    }

    public function historise(ApplicationElement $element) : ApplicationElement
    {
        try {
        $element->historiser();
            $this->getEntityManager()->flush($element);
        } catch (ORMException $e) {
            throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
        }
        $this->getObjectManager()->flush($element);
        return $element;
    }

    public function restore(ApplicationElement $element) : ApplicationElement
    {
        try {
        $element->dehistoriser();
            $this->getEntityManager()->flush($element);
        } catch (ORMException $e) {
            throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
        }
        $this->getObjectManager()->flush($element);
        return $element;
    }

    public function delete(ApplicationElement $element) : ApplicationElement
    {
        try {
            $this->getEntityManager()->remove($element);
            $this->getEntityManager()->flush($element);
        } catch (ORMException $e) {
            throw new RuntimeException("Un problème est survenue lors de l'enregistrement en BD.", $e);
        }
        $this->getObjectManager()->remove($element);
        $this->getObjectManager()->flush($element);
        return $element;
    }

@@ -73,7 +56,7 @@ class ApplicationElementService {

    public function createQueryBuilder() : QueryBuilder
    {
        $qb = $this->getEntityManager()->getRepository(ApplicationElement::class)->createQueryBuilder('applicationelement')
        $qb = $this->getObjectManager()->getRepository(ApplicationElement::class)->createQueryBuilder('applicationelement')
            ->addSelect('application')->join('applicationelement.application', 'application')
;
        return $qb;
@@ -88,7 +71,7 @@ class ApplicationElementService {
        try {
            $result = $qb->getQuery()->getOneOrNullResult();
        } catch (NonUniqueResultException $e) {
            throw new RuntimeException("Plusieurs ApplicationElement partagent le même id [".$id."]");
            throw new RuntimeException("Plusieurs ApplicationElement partagent le même id [".$id."]", 0 , $e);
        }
        return $result;
    }
@@ -99,4 +82,27 @@ class ApplicationElementService {
        return $this->getApplicationElement($id);
    }

    /** FACADE ********************************************************************************************************/

    /** @return Agent[] */
    public function getAgentsHavingApplicationFromAgent(Application $application): array
    {
        $qb = $this->getObjectManager()->getRepository(Agent::class)->createQueryBuilder("agent")
            ->join('agent.applications', 'applicationelement')->addSelect('applicationelement')
            ->andWhere('applicationelement.application = :application')->setParameter('application', $application)
            ->andWhere('applicationelement.histoDestruction IS NULL')
        ;
        return $qb->getQuery()->getResult();
    }

    /** @return FicheMetier[] */
    public function getFicheMetierHavingApplication(Application $application): array
    {
        $qb = $this->getObjectManager()->getRepository(FicheMetier::class)->createQueryBuilder("fichemetier")
            ->join('fichemetier.applications', 'applicationelement')->addSelect('applicationelement')
            ->andWhere('applicationelement.application = :application')->setParameter('application', $application)
            ->andWhere('applicationelement.histoDestruction IS NULL')
        ;
        return $qb->getQuery()->getResult();
    }
}
 No newline at end of file
+3 −2
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ use Interop\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class ApplicationElementServiceFactory {
class ApplicationElementServiceFactory
{

    /**
     * @param ContainerInterface $container
@@ -23,7 +24,7 @@ class ApplicationElementServiceFactory {
        $entityManager = $container->get('doctrine.entitymanager.orm_default');

        $service = new ApplicationElementService();
        $service->setEntityManager($entityManager);
        $service->setObjectManager($entityManager);
        return $service;
    }
}
 No newline at end of file
Loading