Loading module/Application/src/Application/Controller/FichePoste/FichePosteController.php +19 −2 Changes for module/Application/src/Application/Controller/FichePoste/FichePosteController.php: 19 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -186,7 +186,16 @@ class FichePosteController extends AbstractActionController { if ($form->isValid()) { $ficheTypeExterne->setFichePoste($fiche); $this->getFichePosteService()->createFicheTypeExterne($ficheTypeExterne); //$this->redirect()->toRoute('fiche-metier/afficher',['fiche' => $fiche->getId()], [], true); if ($ficheTypeExterne->getPrincipale()) { foreach ($fiche->getFichesMetiers() as $ficheMetier) { if ($ficheMetier !== $ficheTypeExterne && $ficheMetier->getPrincipale()) { $ficheMetier->setPrincipale(false); $this->getFichePosteService()->updateFicheTypeExterne($ficheMetier); } } } } } Loading Loading @@ -228,7 +237,15 @@ class FichePosteController extends AbstractActionController { if ($form->isValid()) { $ficheTypeExterne->setFichePoste($fichePoste); $this->getFichePosteService()->updateFicheTypeExterne($ficheTypeExterne); //$this->redirect()->toRoute('fiche-metier/afficher',['fiche' => $fiche->getId()], [], true); if ($ficheTypeExterne->getPrincipale()) { foreach ($fichePoste->getFichesMetiers() as $ficheMetier) { if ($ficheMetier !== $ficheTypeExterne && $ficheMetier->getPrincipale()) { $ficheMetier->setPrincipale(false); $this->getFichePosteService()->updateFicheTypeExterne($ficheMetier); } } } } } Loading module/Application/src/Application/Entity/Db/FichePoste.php +20 Changes for module/Application/src/Application/Entity/Db/FichePoste.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Application\Entity\Db; use Doctrine\Common\Collections\ArrayCollection; use UnicaenApp\Entity\HistoriqueAwareTrait; use UnicaenApp\Exception\RuntimeException; class FichePoste { Loading Loading @@ -134,6 +135,25 @@ class FichePoste return $this; } /** * @return FicheTypeExterne */ public function getFicheTypeExternePrincipale() { $res = []; /** @var FicheTypeExterne $ficheMetier */ foreach ($this->fichesMetiers as $ficheMetier) { if ($ficheMetier->getPrincipale()) { $res[] = $ficheMetier; } } $nb = count($res); if ( $nb > 1) { throw new RuntimeException("Plusieurs fiches metiers sont déclarées comme principale"); } if ($nb === 1) return current($res); return null; } } No newline at end of file module/Application/src/Application/View/Helper/FicheTypeExterneViewHelper.php +3 −1 Changes for module/Application/src/Application/View/Helper/FicheTypeExterneViewHelper.php: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class FicheTypeExterneViewHelper extends AbstractHelper * @param FicheTypeExterne $ficheTypeExterne * @return string */ public function render($ficheTypeExterne) public function render($ficheTypeExterne, $actionnable = true) { $texte = ''; $texte .= '<div class="panel panel-info">'; Loading @@ -42,12 +42,14 @@ class FicheTypeExterneViewHelper extends AbstractHelper $texte .= ' <h2>'.$ficheTypeExterne->getFicheType()->getMetier()->getLibelle().'</h2>'; $texte .= ' </div>'; $texte .= ' <div class="col-md-1 pull-right">'; if ($actionnable === true) { $texte .= ' <a href="' . $this->getView()->url('fiche-poste/modifier-fiche-metier', ['fiche-poste' => $ficheTypeExterne->getFichePoste()->getId(), 'fiche-type-externe' => $ficheTypeExterne->getId()], [], true) . '" class="ajax-modal" data-event="modification">'; $texte .= ' <span class="icon editer" title="Éditer la fiche type externe"></span></a>'; $texte .= ' <a href="' . $this->getView()->url('fiche-poste/selectionner-activite', ['fiche-poste' => $ficheTypeExterne->getFichePoste()->getId(), 'fiche-type-externe' => $ficheTypeExterne->getId()], [], true) . '" class="ajax-modal" data-event="modification">'; $texte .= ' <span class="icon listing" title="Sélectionner les activités associées"></span></a>'; $texte .= ' <a href="' . $this->getView()->url('fiche-poste/retirer-fiche-metier', ['fiche-poste' => $ficheTypeExterne->getFichePoste()->getId(), 'fiche-type-externe' => $ficheTypeExterne->getId()], [], true) . '">'; $texte .= ' <span class="icon detruire" title="Retirer la fiche type externe"></span></a>'; } $texte .= ' </div>'; $texte .= ' <div class="col-md-3 pull-right">'; if ($ficheTypeExterne->getPrincipale()) { Loading module/Application/view/application/fiche-poste/afficher.phtml +18 −3 Changes for module/Application/view/application/fiche-poste/afficher.phtml: 18 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -67,13 +67,27 @@ $canAssocierMetierType = true; </div> <!-- FICHES TYPES -----------------------------------------------------------------------------------------------------> <?php $principal = $fiche->getFicheTypeExternePrincipale(); $fichesMetiers = $fiche->getFichesMetiers(); $fichesMetiers = array_filter($fichesMetiers, function (FicheTypeExterne $a) { return !$a->getPrincipale(); }); usort($fiche->getFichesMetiers(), function (FicheTypeExterne $a, FicheTypeExterne $b) { return ($a->getQuotite() > $b->getQuotite()); }); ?> <?php /** @var FicheTypeExterne $ficheType **/ ?> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <h2>Fiche composée de <?php echo count($fiche->getFichesMetiers()); ?> fiche(s) type(s).</h2> <ul> <?php foreach ($fiche->getFichesMetiers() as $ficheType) : ?> <?php if ($principal) : ?> <li> <strong> <?php echo $principal->getFicheType()->getMetier() ?> à <?php echo $principal->getQuotite(); ?>%</strong></li> <?php endif; ?> <?php foreach ($fichesMetiers as $ficheType) : ?> <li> <?php echo $ficheType->getFicheType()->getMetier(); ?> à <?php echo $ficheType->getQuotite(); ?>% </li> <?php endforeach; ?> </ul> Loading @@ -81,8 +95,9 @@ $canAssocierMetierType = true; </div> </div> <?php foreach ($fiche->getFichesMetiers() as $ficheType) : ?> <?php echo $this->ficheTypeExterne()->render($ficheType); ?> <?php if ($principal) echo $this->ficheTypeExterne()->render($principal, false); ?> <?php foreach ($fichesMetiers as $ficheType) : ?> <?php echo $this->ficheTypeExterne()->render($ficheType, false); ?> <?php endforeach; ?> Loading module/Application/view/application/fiche-poste/editer.phtml +17 −3 Changes for module/Application/view/application/fiche-poste/editer.phtml: 17 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Application\Entity\Db\FichePoste; use Application\Entity\Db\FicheMetierTypeActivite; use Application\Entity\Db\FicheTypeExterne; use Application\Entity\Db\SpecificitePoste; use Application\Provider\Privilege\FicheMetierPrivileges; Loading Loading @@ -111,6 +112,16 @@ $canEditer = $this->isAllowed(FicheMetierPrivileges::getResourceId(FicheMetierPr </div> <!-- FICHES TYPES -----------------------------------------------------------------------------------------------------> <?php $principal = $fiche->getFicheTypeExternePrincipale(); $fichesMetiers = $fiche->getFichesMetiers(); $fichesMetiers = array_filter($fichesMetiers, function (FicheTypeExterne $a) { return !$a->getPrincipale(); }); usort($fiche->getFichesMetiers(), function (FicheTypeExterne $a, FicheTypeExterne $b) { return ($a->getQuotite() > $b->getQuotite()); }); ?> <?php /** @var \Application\Entity\Db\FicheTypeExterne $ficheType **/ ?> <div class="panel panel-default"> <div class="panel-heading"> Loading @@ -118,7 +129,10 @@ $canEditer = $this->isAllowed(FicheMetierPrivileges::getResourceId(FicheMetierPr <div class="col-md-8"> <h2>Fiche composée de <?php echo count($fiche->getFichesMetiers()); ?> fiche(s) type(s).</h2> <ul> <?php foreach ($fiche->getFichesMetiers() as $ficheType) : ?> <?php if ($principal) : ?> <li> <strong> <?php echo $principal->getFicheType()->getMetier() ?> à <?php echo $principal->getQuotite(); ?>%</strong></li> <?php endif; ?> <?php foreach ($fichesMetiers as $ficheType) : ?> <li> <?php echo $ficheType->getFicheType()->getMetier(); ?> à <?php echo $ficheType->getQuotite(); ?>% </li> <?php endforeach; ?> </ul> Loading @@ -136,11 +150,11 @@ $canEditer = $this->isAllowed(FicheMetierPrivileges::getResourceId(FicheMetierPr </div> </div> <?php foreach ($fiche->getFichesMetiers() as $ficheType) : ?> <?php if ($principal) echo $this->ficheTypeExterne()->render($principal); ?> <?php foreach ($fichesMetiers as $ficheType) : ?> <?php echo $this->ficheTypeExterne()->render($ficheType); ?> <?php endforeach; ?> <!-- SPECIFICITE DU POSTE ---------------------------------------------------------------------------------------------> <div class="panel panel-info"> <div class="panel-heading"> Loading Loading
module/Application/src/Application/Controller/FichePoste/FichePosteController.php +19 −2 Changes for module/Application/src/Application/Controller/FichePoste/FichePosteController.php: 19 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -186,7 +186,16 @@ class FichePosteController extends AbstractActionController { if ($form->isValid()) { $ficheTypeExterne->setFichePoste($fiche); $this->getFichePosteService()->createFicheTypeExterne($ficheTypeExterne); //$this->redirect()->toRoute('fiche-metier/afficher',['fiche' => $fiche->getId()], [], true); if ($ficheTypeExterne->getPrincipale()) { foreach ($fiche->getFichesMetiers() as $ficheMetier) { if ($ficheMetier !== $ficheTypeExterne && $ficheMetier->getPrincipale()) { $ficheMetier->setPrincipale(false); $this->getFichePosteService()->updateFicheTypeExterne($ficheMetier); } } } } } Loading Loading @@ -228,7 +237,15 @@ class FichePosteController extends AbstractActionController { if ($form->isValid()) { $ficheTypeExterne->setFichePoste($fichePoste); $this->getFichePosteService()->updateFicheTypeExterne($ficheTypeExterne); //$this->redirect()->toRoute('fiche-metier/afficher',['fiche' => $fiche->getId()], [], true); if ($ficheTypeExterne->getPrincipale()) { foreach ($fichePoste->getFichesMetiers() as $ficheMetier) { if ($ficheMetier !== $ficheTypeExterne && $ficheMetier->getPrincipale()) { $ficheMetier->setPrincipale(false); $this->getFichePosteService()->updateFicheTypeExterne($ficheMetier); } } } } } Loading
module/Application/src/Application/Entity/Db/FichePoste.php +20 Changes for module/Application/src/Application/Entity/Db/FichePoste.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Application\Entity\Db; use Doctrine\Common\Collections\ArrayCollection; use UnicaenApp\Entity\HistoriqueAwareTrait; use UnicaenApp\Exception\RuntimeException; class FichePoste { Loading Loading @@ -134,6 +135,25 @@ class FichePoste return $this; } /** * @return FicheTypeExterne */ public function getFicheTypeExternePrincipale() { $res = []; /** @var FicheTypeExterne $ficheMetier */ foreach ($this->fichesMetiers as $ficheMetier) { if ($ficheMetier->getPrincipale()) { $res[] = $ficheMetier; } } $nb = count($res); if ( $nb > 1) { throw new RuntimeException("Plusieurs fiches metiers sont déclarées comme principale"); } if ($nb === 1) return current($res); return null; } } No newline at end of file
module/Application/src/Application/View/Helper/FicheTypeExterneViewHelper.php +3 −1 Changes for module/Application/src/Application/View/Helper/FicheTypeExterneViewHelper.php: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ class FicheTypeExterneViewHelper extends AbstractHelper * @param FicheTypeExterne $ficheTypeExterne * @return string */ public function render($ficheTypeExterne) public function render($ficheTypeExterne, $actionnable = true) { $texte = ''; $texte .= '<div class="panel panel-info">'; Loading @@ -42,12 +42,14 @@ class FicheTypeExterneViewHelper extends AbstractHelper $texte .= ' <h2>'.$ficheTypeExterne->getFicheType()->getMetier()->getLibelle().'</h2>'; $texte .= ' </div>'; $texte .= ' <div class="col-md-1 pull-right">'; if ($actionnable === true) { $texte .= ' <a href="' . $this->getView()->url('fiche-poste/modifier-fiche-metier', ['fiche-poste' => $ficheTypeExterne->getFichePoste()->getId(), 'fiche-type-externe' => $ficheTypeExterne->getId()], [], true) . '" class="ajax-modal" data-event="modification">'; $texte .= ' <span class="icon editer" title="Éditer la fiche type externe"></span></a>'; $texte .= ' <a href="' . $this->getView()->url('fiche-poste/selectionner-activite', ['fiche-poste' => $ficheTypeExterne->getFichePoste()->getId(), 'fiche-type-externe' => $ficheTypeExterne->getId()], [], true) . '" class="ajax-modal" data-event="modification">'; $texte .= ' <span class="icon listing" title="Sélectionner les activités associées"></span></a>'; $texte .= ' <a href="' . $this->getView()->url('fiche-poste/retirer-fiche-metier', ['fiche-poste' => $ficheTypeExterne->getFichePoste()->getId(), 'fiche-type-externe' => $ficheTypeExterne->getId()], [], true) . '">'; $texte .= ' <span class="icon detruire" title="Retirer la fiche type externe"></span></a>'; } $texte .= ' </div>'; $texte .= ' <div class="col-md-3 pull-right">'; if ($ficheTypeExterne->getPrincipale()) { Loading
module/Application/view/application/fiche-poste/afficher.phtml +18 −3 Changes for module/Application/view/application/fiche-poste/afficher.phtml: 18 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -67,13 +67,27 @@ $canAssocierMetierType = true; </div> <!-- FICHES TYPES -----------------------------------------------------------------------------------------------------> <?php $principal = $fiche->getFicheTypeExternePrincipale(); $fichesMetiers = $fiche->getFichesMetiers(); $fichesMetiers = array_filter($fichesMetiers, function (FicheTypeExterne $a) { return !$a->getPrincipale(); }); usort($fiche->getFichesMetiers(), function (FicheTypeExterne $a, FicheTypeExterne $b) { return ($a->getQuotite() > $b->getQuotite()); }); ?> <?php /** @var FicheTypeExterne $ficheType **/ ?> <div class="panel panel-default"> <div class="panel-heading"> <div class="row"> <h2>Fiche composée de <?php echo count($fiche->getFichesMetiers()); ?> fiche(s) type(s).</h2> <ul> <?php foreach ($fiche->getFichesMetiers() as $ficheType) : ?> <?php if ($principal) : ?> <li> <strong> <?php echo $principal->getFicheType()->getMetier() ?> à <?php echo $principal->getQuotite(); ?>%</strong></li> <?php endif; ?> <?php foreach ($fichesMetiers as $ficheType) : ?> <li> <?php echo $ficheType->getFicheType()->getMetier(); ?> à <?php echo $ficheType->getQuotite(); ?>% </li> <?php endforeach; ?> </ul> Loading @@ -81,8 +95,9 @@ $canAssocierMetierType = true; </div> </div> <?php foreach ($fiche->getFichesMetiers() as $ficheType) : ?> <?php echo $this->ficheTypeExterne()->render($ficheType); ?> <?php if ($principal) echo $this->ficheTypeExterne()->render($principal, false); ?> <?php foreach ($fichesMetiers as $ficheType) : ?> <?php echo $this->ficheTypeExterne()->render($ficheType, false); ?> <?php endforeach; ?> Loading
module/Application/view/application/fiche-poste/editer.phtml +17 −3 Changes for module/Application/view/application/fiche-poste/editer.phtml: 17 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Application\Entity\Db\FichePoste; use Application\Entity\Db\FicheMetierTypeActivite; use Application\Entity\Db\FicheTypeExterne; use Application\Entity\Db\SpecificitePoste; use Application\Provider\Privilege\FicheMetierPrivileges; Loading Loading @@ -111,6 +112,16 @@ $canEditer = $this->isAllowed(FicheMetierPrivileges::getResourceId(FicheMetierPr </div> <!-- FICHES TYPES -----------------------------------------------------------------------------------------------------> <?php $principal = $fiche->getFicheTypeExternePrincipale(); $fichesMetiers = $fiche->getFichesMetiers(); $fichesMetiers = array_filter($fichesMetiers, function (FicheTypeExterne $a) { return !$a->getPrincipale(); }); usort($fiche->getFichesMetiers(), function (FicheTypeExterne $a, FicheTypeExterne $b) { return ($a->getQuotite() > $b->getQuotite()); }); ?> <?php /** @var \Application\Entity\Db\FicheTypeExterne $ficheType **/ ?> <div class="panel panel-default"> <div class="panel-heading"> Loading @@ -118,7 +129,10 @@ $canEditer = $this->isAllowed(FicheMetierPrivileges::getResourceId(FicheMetierPr <div class="col-md-8"> <h2>Fiche composée de <?php echo count($fiche->getFichesMetiers()); ?> fiche(s) type(s).</h2> <ul> <?php foreach ($fiche->getFichesMetiers() as $ficheType) : ?> <?php if ($principal) : ?> <li> <strong> <?php echo $principal->getFicheType()->getMetier() ?> à <?php echo $principal->getQuotite(); ?>%</strong></li> <?php endif; ?> <?php foreach ($fichesMetiers as $ficheType) : ?> <li> <?php echo $ficheType->getFicheType()->getMetier(); ?> à <?php echo $ficheType->getQuotite(); ?>% </li> <?php endforeach; ?> </ul> Loading @@ -136,11 +150,11 @@ $canEditer = $this->isAllowed(FicheMetierPrivileges::getResourceId(FicheMetierPr </div> </div> <?php foreach ($fiche->getFichesMetiers() as $ficheType) : ?> <?php if ($principal) echo $this->ficheTypeExterne()->render($principal); ?> <?php foreach ($fichesMetiers as $ficheType) : ?> <?php echo $this->ficheTypeExterne()->render($ficheType); ?> <?php endforeach; ?> <!-- SPECIFICITE DU POSTE ---------------------------------------------------------------------------------------------> <div class="panel panel-info"> <div class="panel-heading"> Loading