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

Ajout des actions manquantes pour le parcours de formations

parent cb26f609
Loading
Loading
Loading
Loading
+47
Changes for module/Application/src/Application/Controller/ParcoursDeFormationController.php: 47 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -92,4 +92,51 @@ class ParcoursDeFormationController extends AbstractActionController
        ]);
        return $vm;
    }

    private function getFragment(ParcoursDeFormation $parcours)
    {
        $type = $parcours->getType();
        if ($type === ParcoursDeFormation::TYPE_METIER) return "metier";
        if ($type === ParcoursDeFormation::TYPE_CATEGORIE) return "categorie";
        return "";
    }

    public function historiserAction()
    {
        $parcours = $this->getParcoursDeFormationService()->getRequestedParcoursDeFormation($this);
        $this->getParcoursDeFormationService()->historise($parcours);
        return $this->redirect()->toRoute('parcours-de-formation', [], ['fragment' => $this->getFragment($parcours)], true);
    }

    public function restaurerAction()
    {
        $parcours = $this->getParcoursDeFormationService()->getRequestedParcoursDeFormation($this);
        $this->getParcoursDeFormationService()->restore($parcours);
        return $this->redirect()->toRoute('parcours-de-formation', [], ['fragment' => $this->getFragment($parcours)], true);
    }

    public function detruireAction()
    {
        /** @var ParcoursDeFormation $parcours */
        $parcours = $this->getParcoursDeFormationService()->getRequestedParcoursDeFormation($this);

        /** @var Request $request */
        $request = $this->getRequest();
        if ($request->isPost()) {
            $data = $request->getPost();
            if ($data["reponse"] === "oui") $this->getParcoursDeFormationService()->delete($parcours);
            exit();
        }

        $vm = new ViewModel();
        if ($parcours !== null) {
            $vm->setTemplate('application/default/confirmation');
            $vm->setVariables([
                'title' => "Suppression du parcours de formation [" . $parcours->getLibelle() . "]",
                'text' => "La suppression est définitive êtes-vous sûr·e de vouloir continuer ?",
                'action' => $this->url()->fromRoute('parcours-de-formation/detruire', ["parcours-de-formation" => $parcours->getId()], [], true),
            ]);
        }
        return $vm;
    }
}
 No newline at end of file
+28
Changes for module/Application/view/application/parcours-de-formation/partial/index-parcours.phtml: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,7 +9,10 @@
use Application\Entity\Db\ParcoursDeFormation;

$canAfficher = true;
$canAjouter = true;
$canModifier = true;
$canHistoriser = true;
$canDetruire = true;
?>

<div class="row">
@@ -20,6 +23,7 @@ $canModifier = true;
    </div>
    <div class="pull-right">
        <br/>
        <?php if($canAjouter) : ?>
        <a
            <?php /** @see \Application\Controller\ParcoursDeFormationController::ajouterAction() */ ?>
                href="<?php echo $this->url('parcours-de-formation/ajouter', ['type' => $type], [], true); ?>"
@@ -27,6 +31,7 @@ $canModifier = true;
            >
            <span class="icon ajouter"> Ajouter un parcours de formation</span>
        </a>
        <?php endif; ?>
        <br/>
        <br/>
    </div>
@@ -72,6 +77,29 @@ $canModifier = true;
                        >
                            <span class="icon editer" title="Modifier le parcours de formation"></span></a>
                    <?php endif; ?>
                    <?php if($canHistoriser) : ?>
                        <?php if ($parcour->estHistorise()) : ?>
                            <a
                                <?php /** @see \Application\Controller\ParcoursDeFormationController::restaurerAction() */?>
                                    href="<?php echo $this->url('parcours-de-formation/restaurer', ['parcours-de-formation' => $parcour->getId()], [], true); ?>"
                            >
                                <span class="icon restaurer" title="Restaurer le parcours de formation"></span></a>
                        <?php else : ?>
                            <a
                                <?php /** @see \Application\Controller\ParcoursDeFormationController::historiserAction() */?>
                                    href="<?php echo $this->url('parcours-de-formation/historiser', ['parcours-de-formation' => $parcour->getId()], [], true); ?>"
                            >
                                <span class="icon historiser" title="Historiser le parcours de formation"></span></a>
                        <?php endif; ?>
                    <?php endif; ?>
                    <?php if($canDetruire) : ?>
                        <a
                            <?php /** @see \Application\Controller\ParcoursDeFormationController::detruireAction() */?>
                                href="<?php echo $this->url('parcours-de-formation/detruire', ['parcours-de-formation' => $parcour->getId()], [], true); ?>"
                                class="ajax-modal" data-event="modification"
                        >
                            <span class="icon detruire" title="Detruire le parcours de formation"></span></a>
                    <?php endif; ?>
                </td>
            </tr>
        <?php endforeach; ?>