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

Substitution Ajout del'action détruire substitution

parent 1c7e039d
Loading
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -128,7 +128,14 @@ class SubstitutionController extends AbstractController

    public function detruireAction()
    {
        return new ViewModel();
        $idCible = $this->params()->fromRoute('cible');
        $structure = $this->structureService->findStructureById($idCible);
        $cible = $this->structureService->findStructureConcreteFromStructure($structure);

        //retirer les substitions
        $this->structureService->removeSubstitution($cible);

        return $this->redirect()->toRoute('substitution-index', [],[], true);
    }

    public function generateSourceInputAction() {
+29 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Application\Entity\Db\StructureSubstit;
use Application\Entity\Db\TypeStructure;
use Application\Entity\Db\UniteRecherche;
use Application\Service\BaseService;
use Application\Service\Source\SourceService;
use Application\Service\Source\SourceServiceAwareTrait;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NonUniqueResultException;
@@ -293,4 +294,32 @@ class StructureService extends BaseService
        $results = $qb->getQuery()->getResult();
        return $results;
    }


    /**
     * @param $idCible
     * @return Structure
     */
    public function findStructureById($idCible)
    {
        $result = $this->getRepository()->findOneBy(["id" => $idCible]);
        return $result;
    }

    public function removeSubstitution(StructureConcreteInterface $cibleConcrete)
    {
        $qb = $this->getEntityManager()->getRepository(StructureSubstit::class)->createQueryBuilder("ss")
            ->andWhere("ss.toStructure = :cible")
            ->setParameter("cible", $cibleConcrete->getStructure());
        $result = $qb->getQuery()->getResult();

        foreach($result as $entry) {
            $this->getEntityManager()->remove($entry);
        }
        $this->getEntityManager()->flush($result);

        $this->getEntityManager()->remove($cibleConcrete);
        $this->getEntityManager()->flush($cibleConcrete);

    }
}
 No newline at end of file
+0 −2
Original line number Diff line number Diff line
SUBSTITUTION DETRUIRE
NOT YET IMPLEMENTED
 No newline at end of file
+4 −4
Original line number Diff line number Diff line
@@ -11,12 +11,12 @@ use Application\Entity\Db\UniteRecherche;
 */
?>

<?php $this->headTitle($this->translate("Substitution d'établissements")) ?>
<?php $this->headTitle($this->translate("Substitution de structures")) ?>


<h1 class="page-header first">
    <?php echo $this->translate("Substitution d'établissements"); ?>
        <span class="badge"><?php echo "TODO" ?></span>
    <?php echo $this->translate("Substitution  de structures"); ?>
        <span class="badge"><?php echo count($etablissementsSubstitues) + count($ecolesSubstituees) + count($unitesSubstituees); ?></span>
</h1>

<div class="col-md-4" >
@@ -83,7 +83,7 @@ use Application\Entity\Db\UniteRecherche;
            foreach ($structuresSubstituees as $structureSubstituee) {
                $texte .= '<tr>';
                $texte .= '    <td>' . $structureSubstituee->getLibelle() . '</td>';
                $texte .= '    <td>';
                $texte .= '    <td style="text-align:center;">';
                $texte .= '      <a href="' . $view->url('substitution-modifier', ['cible' => $structureSubstituee->getStructure()->getId()], [], true) . '"><span class="glyphicon glyphicon-pencil"></span></a>';
                $texte .= "&nbsp;";
                $texte .= '      <a href="' . $view->url('substitution-detruire', ['cible' => $structureSubstituee->getStructure()->getId()], [], true) . '"><span class="glyphicon glyphicon-remove"></span></a>';