Loading module/Application/config/merged/agent.config.php +0 −17 Original line number Diff line number Diff line Loading @@ -6,10 +6,6 @@ use Application\Assertion\AgentAssertion; use Application\Assertion\AgentAssertionFactory; use Application\Controller\AgentController; use Application\Controller\AgentControllerFactory; use Application\Form\Agent\AgentForm; use Application\Form\Agent\AgentFormFactory; use Application\Form\Agent\AgentHydrator; use Application\Form\Agent\AgentHydratorFactory; use Application\Form\AgentApplication\AgentApplicationForm; use Application\Form\AgentApplication\AgentApplicationFormFactory; use Application\Form\AgentApplication\AgentApplicationHydrator; Loading Loading @@ -103,7 +99,6 @@ return [ [ 'controller' => AgentController::class, 'action' => [ 'modifier', 'upload-fichier', ], 'privileges' => [ Loading Loading @@ -446,16 +441,6 @@ return [ /** AUTRE ****************************************************************************************/ 'modifier' => [ 'type' => Segment::class, 'options' => [ 'route' => '/modifier/:agent', 'defaults' => [ 'controller' => AgentController::class, 'action' => 'modifier', ], ], ], 'upload-fichier' => [ 'type' => Segment::class, 'options' => [ Loading Loading @@ -523,7 +508,6 @@ return [ ], 'form_elements' => [ 'factories' => [ AgentForm::class => AgentFormFactory::class, AgentApplicationForm::class => AgentApplicationFormFactory::class, AgentCompetenceForm::class => AgentCompetenceFormFactory::class, AgentFormationForm::class => AgentFormationFormFactory::class, Loading @@ -531,7 +515,6 @@ return [ ], 'hydrators' => [ 'factories' => [ AgentHydrator::class => AgentHydratorFactory::class, AgentApplicationHydrator::class => AgentApplicationHydratorFactory::class, AgentCompetenceHydrator::class => AgentCompetenceHydratorFactory::class, AgentFormationHydrator::class => AgentFormationHydratorFactory::class, Loading module/Application/src/Application/Controller/AgentController.php +0 −28 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ use Application\Entity\Db\AgentCompetence; use Application\Entity\Db\AgentFormation; use Application\Entity\Db\AgentGrade; use Application\Entity\Db\AgentStatut; use Application\Form\Agent\AgentFormAwareTrait; use Application\Form\AgentApplication\AgentApplicationForm; use Application\Form\AgentApplication\AgentApplicationFormAwareTrait; use Application\Form\AgentCompetence\AgentCompetenceFormAwareTrait; Loading Loading @@ -48,7 +47,6 @@ class AgentController extends AbstractActionController use StructureServiceAwareTrait; use UserServiceAwareTrait; use AgentFormAwareTrait; use AgentApplicationFormAwareTrait; use AgentCompetenceFormAwareTrait; use AgentFormationFormAwareTrait; Loading Loading @@ -110,32 +108,6 @@ class AgentController extends AbstractActionController ]); } public function modifierAction() { $agent = $this->getAgentService()->getRequestedAgent($this); $form = $this->getAgentForm(); $form->setAttribute('action', $this->url()->fromRoute('agent/modifier', ['agent' => $agent->getId()], [], true)); $form->bind($agent); /** @var Request $request */ $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $this->getAgentService()->update($agent); } } $vm = new ViewModel(); $vm->setTemplate('application/default/default-form'); $vm->setVariables([ 'title' => 'Modifier l\'agent', 'form' => $form, ]); return $vm; } /** Gestion des applications***************************************************************************************/ public function ajouterAgentApplicationAction() Loading module/Application/src/Application/Controller/AgentControllerFactory.php +0 −3 Original line number Diff line number Diff line Loading @@ -44,13 +44,11 @@ class AgentControllerFactory { $structureService = $container->get(StructureService::class); /** * @var AgentForm $agentForm * @var AgentApplicationForm $agentApplicationForm * @var AgentCompetenceForm $agentCompetenceForm * @var AgentFormationForm $agentFormationForm * @var UploadForm $uploadForm */ $agentForm = $container->get('FormElementManager')->get(AgentForm::class); $agentApplicationForm = $container->get('FormElementManager')->get(AgentApplicationForm::class); $agentCompetenceForm = $container->get('FormElementManager')->get(AgentCompetenceForm::class); $agentFormationForm = $container->get('FormElementManager')->get(AgentFormationForm::class); Loading @@ -69,7 +67,6 @@ class AgentControllerFactory { $controller->setUserService($userService); $controller->setStructureService($structureService); $controller->setAgentForm($agentForm); $controller->setAgentApplicationForm($agentApplicationForm); $controller->setAgentCompetenceForm($agentCompetenceForm); $controller->setAgentFormationForm($agentFormationForm); Loading module/Application/src/Application/Entity/Db/Agent.php +29 −34 Original line number Diff line number Diff line Loading @@ -32,11 +32,11 @@ class Agent implements ResourceInterface private $utilisateur; /** @var int */ private $harpId; /** @var int */ private $quotite; /** @var DateTime */ private $delete; /** @var ArrayCollection (AgentQuotite) */ private $quotites; /** @var ArrayCollection (AgentAffectation) */ private $affectations; /** @var ArrayCollection (AgentGrade) */ Loading Loading @@ -139,7 +139,7 @@ class Agent implements ResourceInterface $affectations = []; /** @var AgentAffectation $affectation */ foreach ($this->affectations as $affectation) { if ($affectation->isActive()) $affectations[] = $affectation; if ($affectation->isActive($date)) $affectations[] = $affectation; } return $affectations; } Loading Loading @@ -214,24 +214,6 @@ class Agent implements ResourceInterface return $this; } /** * @return int */ public function getQuotite() { return $this->quotite; } /** * @param int $quotite * @return Agent */ public function setQuotite($quotite) { $this->quotite = $quotite; return $this; } /** * @return FichePoste[] */ Loading @@ -240,16 +222,6 @@ class Agent implements ResourceInterface return $this->fiches->toArray(); } /** * @param FichePoste $fiche * @return Agent */ public function setFiche($fiche) { $this->fiche = $fiche; return $this; } /** * @return Fichier[] */ Loading @@ -262,7 +234,7 @@ class Agent implements ResourceInterface * @param Fichier $fichier * @return Agent */ public function addFichier($fichier) public function addFichier(Fichier $fichier) { $this->fichiers->add($fichier); return $this; Loading @@ -272,7 +244,7 @@ class Agent implements ResourceInterface * @param Fichier $fichier * @return Agent */ public function removeFichier($fichier) public function removeFichier(Fichier $fichier) { $this->fichiers->removeElement($fichier); return $this; Loading @@ -282,7 +254,7 @@ class Agent implements ResourceInterface * @param string $nature * @return Fichier[] */ public function fetchFiles($nature) public function fetchFiles(string $nature) { $fichiers = $this->getFichiers(); $fichiers = array_filter($fichiers, function (Fichier $f) use ($nature) { Loading Loading @@ -456,6 +428,29 @@ class Agent implements ResourceInterface if ($level !== null and $level <= $niveau) $niveau = $level; } return ($niveau !== 999)?$niveau:null; } /** QUOTITES *****************************************************************************************/ /** * @return AgentQuotite[] */ public function getQuotites() { $quotites = $this->quotites->toArray(); array_filter($quotites, function (AgentQuotite $q) { return $q->getImportationHistorisation(); }); usort($quotites, function(AgentQuotite $a, AgentQuotite $b) { return $a->getDebut() > $b->getDebut();}); return $quotites; } /** * @param DateTime|null $date * @return AgentQuotite|null */ public function getQuotiteCourante(?DateTime $date = null) { /** @var AgentQuotite $quotite */ foreach ($this->quotites as $quotite) { if ($quotite->isEnCours($date)) return $quotite; } return null; } } No newline at end of file module/Application/src/Application/Entity/Db/AgentQuotite.php 0 → 100644 +111 −0 Original line number Diff line number Diff line <?php namespace Application\Entity\Db; use DateTime; use UnicaenUtilisateur\Entity\DateTimeAwareTrait; class AgentQuotite { use ImportableAwareTrait; use DateTimeAwareTrait; /** @var int */ private $id; /** @var Agent */ private $agent; /** @var DateTime */ private $debut; /** @var DateTime */ private $fin; /** @var integer */ private $quotite; /** * @return int */ public function getId(): int { return $this->id; } /** * @return Agent */ public function getAgent(): Agent { return $this->agent; } /** * @param Agent $agent * @return AgentQuotite */ public function setAgent(Agent $agent): AgentQuotite { $this->agent = $agent; return $this; } /** * @return DateTime|null */ public function getDebut(): ?DateTime { return $this->debut; } /** * @param DateTime|null $debut * @return AgentQuotite */ public function setDebut(?DateTime $debut): AgentQuotite { $this->debut = $debut; return $this; } /** * @return DateTime|null */ public function getFin(): ?DateTime { return $this->fin; } /** * @param DateTime|null $fin * @return AgentQuotite */ public function setFin(?DateTime $fin): AgentQuotite { $this->fin = $fin; return $this; } /** * @return int|null */ public function getQuotite(): ?int { return $this->quotite; } /** * @param int $quotite * @return AgentQuotite */ public function setQuotite(int $quotite): AgentQuotite { $this->quotite = $quotite; return $this; } public function isEnCours(?DateTime $date = null) { $date = $date ? : $this->getDateTime(); if ($date < $this->getDebut()) return false; if ($this->getFin() !== null and $date < $this->getFin()) return false; return true; } } No newline at end of file Loading
module/Application/config/merged/agent.config.php +0 −17 Original line number Diff line number Diff line Loading @@ -6,10 +6,6 @@ use Application\Assertion\AgentAssertion; use Application\Assertion\AgentAssertionFactory; use Application\Controller\AgentController; use Application\Controller\AgentControllerFactory; use Application\Form\Agent\AgentForm; use Application\Form\Agent\AgentFormFactory; use Application\Form\Agent\AgentHydrator; use Application\Form\Agent\AgentHydratorFactory; use Application\Form\AgentApplication\AgentApplicationForm; use Application\Form\AgentApplication\AgentApplicationFormFactory; use Application\Form\AgentApplication\AgentApplicationHydrator; Loading Loading @@ -103,7 +99,6 @@ return [ [ 'controller' => AgentController::class, 'action' => [ 'modifier', 'upload-fichier', ], 'privileges' => [ Loading Loading @@ -446,16 +441,6 @@ return [ /** AUTRE ****************************************************************************************/ 'modifier' => [ 'type' => Segment::class, 'options' => [ 'route' => '/modifier/:agent', 'defaults' => [ 'controller' => AgentController::class, 'action' => 'modifier', ], ], ], 'upload-fichier' => [ 'type' => Segment::class, 'options' => [ Loading Loading @@ -523,7 +508,6 @@ return [ ], 'form_elements' => [ 'factories' => [ AgentForm::class => AgentFormFactory::class, AgentApplicationForm::class => AgentApplicationFormFactory::class, AgentCompetenceForm::class => AgentCompetenceFormFactory::class, AgentFormationForm::class => AgentFormationFormFactory::class, Loading @@ -531,7 +515,6 @@ return [ ], 'hydrators' => [ 'factories' => [ AgentHydrator::class => AgentHydratorFactory::class, AgentApplicationHydrator::class => AgentApplicationHydratorFactory::class, AgentCompetenceHydrator::class => AgentCompetenceHydratorFactory::class, AgentFormationHydrator::class => AgentFormationHydratorFactory::class, Loading
module/Application/src/Application/Controller/AgentController.php +0 −28 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ use Application\Entity\Db\AgentCompetence; use Application\Entity\Db\AgentFormation; use Application\Entity\Db\AgentGrade; use Application\Entity\Db\AgentStatut; use Application\Form\Agent\AgentFormAwareTrait; use Application\Form\AgentApplication\AgentApplicationForm; use Application\Form\AgentApplication\AgentApplicationFormAwareTrait; use Application\Form\AgentCompetence\AgentCompetenceFormAwareTrait; Loading Loading @@ -48,7 +47,6 @@ class AgentController extends AbstractActionController use StructureServiceAwareTrait; use UserServiceAwareTrait; use AgentFormAwareTrait; use AgentApplicationFormAwareTrait; use AgentCompetenceFormAwareTrait; use AgentFormationFormAwareTrait; Loading Loading @@ -110,32 +108,6 @@ class AgentController extends AbstractActionController ]); } public function modifierAction() { $agent = $this->getAgentService()->getRequestedAgent($this); $form = $this->getAgentForm(); $form->setAttribute('action', $this->url()->fromRoute('agent/modifier', ['agent' => $agent->getId()], [], true)); $form->bind($agent); /** @var Request $request */ $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $this->getAgentService()->update($agent); } } $vm = new ViewModel(); $vm->setTemplate('application/default/default-form'); $vm->setVariables([ 'title' => 'Modifier l\'agent', 'form' => $form, ]); return $vm; } /** Gestion des applications***************************************************************************************/ public function ajouterAgentApplicationAction() Loading
module/Application/src/Application/Controller/AgentControllerFactory.php +0 −3 Original line number Diff line number Diff line Loading @@ -44,13 +44,11 @@ class AgentControllerFactory { $structureService = $container->get(StructureService::class); /** * @var AgentForm $agentForm * @var AgentApplicationForm $agentApplicationForm * @var AgentCompetenceForm $agentCompetenceForm * @var AgentFormationForm $agentFormationForm * @var UploadForm $uploadForm */ $agentForm = $container->get('FormElementManager')->get(AgentForm::class); $agentApplicationForm = $container->get('FormElementManager')->get(AgentApplicationForm::class); $agentCompetenceForm = $container->get('FormElementManager')->get(AgentCompetenceForm::class); $agentFormationForm = $container->get('FormElementManager')->get(AgentFormationForm::class); Loading @@ -69,7 +67,6 @@ class AgentControllerFactory { $controller->setUserService($userService); $controller->setStructureService($structureService); $controller->setAgentForm($agentForm); $controller->setAgentApplicationForm($agentApplicationForm); $controller->setAgentCompetenceForm($agentCompetenceForm); $controller->setAgentFormationForm($agentFormationForm); Loading
module/Application/src/Application/Entity/Db/Agent.php +29 −34 Original line number Diff line number Diff line Loading @@ -32,11 +32,11 @@ class Agent implements ResourceInterface private $utilisateur; /** @var int */ private $harpId; /** @var int */ private $quotite; /** @var DateTime */ private $delete; /** @var ArrayCollection (AgentQuotite) */ private $quotites; /** @var ArrayCollection (AgentAffectation) */ private $affectations; /** @var ArrayCollection (AgentGrade) */ Loading Loading @@ -139,7 +139,7 @@ class Agent implements ResourceInterface $affectations = []; /** @var AgentAffectation $affectation */ foreach ($this->affectations as $affectation) { if ($affectation->isActive()) $affectations[] = $affectation; if ($affectation->isActive($date)) $affectations[] = $affectation; } return $affectations; } Loading Loading @@ -214,24 +214,6 @@ class Agent implements ResourceInterface return $this; } /** * @return int */ public function getQuotite() { return $this->quotite; } /** * @param int $quotite * @return Agent */ public function setQuotite($quotite) { $this->quotite = $quotite; return $this; } /** * @return FichePoste[] */ Loading @@ -240,16 +222,6 @@ class Agent implements ResourceInterface return $this->fiches->toArray(); } /** * @param FichePoste $fiche * @return Agent */ public function setFiche($fiche) { $this->fiche = $fiche; return $this; } /** * @return Fichier[] */ Loading @@ -262,7 +234,7 @@ class Agent implements ResourceInterface * @param Fichier $fichier * @return Agent */ public function addFichier($fichier) public function addFichier(Fichier $fichier) { $this->fichiers->add($fichier); return $this; Loading @@ -272,7 +244,7 @@ class Agent implements ResourceInterface * @param Fichier $fichier * @return Agent */ public function removeFichier($fichier) public function removeFichier(Fichier $fichier) { $this->fichiers->removeElement($fichier); return $this; Loading @@ -282,7 +254,7 @@ class Agent implements ResourceInterface * @param string $nature * @return Fichier[] */ public function fetchFiles($nature) public function fetchFiles(string $nature) { $fichiers = $this->getFichiers(); $fichiers = array_filter($fichiers, function (Fichier $f) use ($nature) { Loading Loading @@ -456,6 +428,29 @@ class Agent implements ResourceInterface if ($level !== null and $level <= $niveau) $niveau = $level; } return ($niveau !== 999)?$niveau:null; } /** QUOTITES *****************************************************************************************/ /** * @return AgentQuotite[] */ public function getQuotites() { $quotites = $this->quotites->toArray(); array_filter($quotites, function (AgentQuotite $q) { return $q->getImportationHistorisation(); }); usort($quotites, function(AgentQuotite $a, AgentQuotite $b) { return $a->getDebut() > $b->getDebut();}); return $quotites; } /** * @param DateTime|null $date * @return AgentQuotite|null */ public function getQuotiteCourante(?DateTime $date = null) { /** @var AgentQuotite $quotite */ foreach ($this->quotites as $quotite) { if ($quotite->isEnCours($date)) return $quotite; } return null; } } No newline at end of file
module/Application/src/Application/Entity/Db/AgentQuotite.php 0 → 100644 +111 −0 Original line number Diff line number Diff line <?php namespace Application\Entity\Db; use DateTime; use UnicaenUtilisateur\Entity\DateTimeAwareTrait; class AgentQuotite { use ImportableAwareTrait; use DateTimeAwareTrait; /** @var int */ private $id; /** @var Agent */ private $agent; /** @var DateTime */ private $debut; /** @var DateTime */ private $fin; /** @var integer */ private $quotite; /** * @return int */ public function getId(): int { return $this->id; } /** * @return Agent */ public function getAgent(): Agent { return $this->agent; } /** * @param Agent $agent * @return AgentQuotite */ public function setAgent(Agent $agent): AgentQuotite { $this->agent = $agent; return $this; } /** * @return DateTime|null */ public function getDebut(): ?DateTime { return $this->debut; } /** * @param DateTime|null $debut * @return AgentQuotite */ public function setDebut(?DateTime $debut): AgentQuotite { $this->debut = $debut; return $this; } /** * @return DateTime|null */ public function getFin(): ?DateTime { return $this->fin; } /** * @param DateTime|null $fin * @return AgentQuotite */ public function setFin(?DateTime $fin): AgentQuotite { $this->fin = $fin; return $this; } /** * @return int|null */ public function getQuotite(): ?int { return $this->quotite; } /** * @param int $quotite * @return AgentQuotite */ public function setQuotite(int $quotite): AgentQuotite { $this->quotite = $quotite; return $this; } public function isEnCours(?DateTime $date = null) { $date = $date ? : $this->getDateTime(); if ($date < $this->getDebut()) return false; if ($this->getFin() !== null and $date < $this->getFin()) return false; return true; } } No newline at end of file