Commit 25bbf680 authored by Florian Joriot's avatar Florian Joriot
Browse files

Passage du bouton ajouter type formation dans chaque groupe

parent 692614fd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ return [
                    'saisie'           => [
                        'type'          => 'Segment',
                        'options'       => [
                            'route'       => '/saisie[/:typeFormation]',
                            'route'       => '/saisie[/:typeFormation][/:groupeTypeFormation]',
                            'constraints' => [
                                'typeFormation' => '[0-9]*',
                            ],
+9 −5
Original line number Diff line number Diff line
@@ -54,19 +54,23 @@ class TypeFormationController extends AbstractController
            GroupeTypeFormation::class,
        ]);

        $typeFormations = $this->getEvent()->getParam('typeFormation');
        $typeFormation = $this->getEvent()->getParam('typeFormation');

        $form           = $this->getFormTypeFormationTypeFormationSaisie();

        if (empty($typeFormations)) {
        if (empty($typeFormation)) {
            $title          = "Création d'un nouveau type de formation";
            $typeFormations = $this->getServiceTypeFormation()->newEntity();
            /** @var TypeFormation $typeFormation */
            $typeFormation = $this->getServiceTypeFormation()->newEntity();
            $groupeTypeFormation = $this->getEvent()->getParam('groupeTypeFormation');
            $typeFormation->setGroupe($groupeTypeFormation);
        } else {
            $title = "Édition d'un type de formation";
        }

        $form->bindRequestSave($typeFormations, $this->getRequest(), function () use ($typeFormations, $form) {
        $form->bindRequestSave($typeFormation, $this->getRequest(), function () use ($typeFormation, $form) {

            $this->getServiceTypeFormation()->save($typeFormations);
            $this->getServiceTypeFormation()->save($typeFormation);
            $this->flashMessenger()->addSuccessMessage(
                "Ajout réussi"
            );
+41 −2
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@

namespace Application\Entity\Db;

use Application\Service\AbstractEntityService;
use Application\Service\Traits\SourceServiceAwareTrait;
use RuntimeException;
use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait;
use UnicaenImport\Entity\Db\Interfaces\ImportAwareInterface;
@@ -10,11 +13,11 @@ use UnicaenImport\Entity\Db\Traits\ImportAwareTrait;
/**
 * TypeFormation
 */
class TypeFormation implements HistoriqueAwareInterface, ImportAwareInterface
class TypeFormation extends AbstractEntityService implements HistoriqueAwareInterface, ImportAwareInterface
{
    use HistoriqueAwareTrait;
    use ImportAwareTrait;

    use SourceServiceAwareTrait;
    /**
     * @var string
     */
@@ -41,6 +44,29 @@ class TypeFormation implements HistoriqueAwareInterface, ImportAwareInterface
    protected bool $serviceStatutaire = true;


    /**
     * retourne la classe des entités
     *
     * @return string
     * @throws RuntimeException
     */
    public function getEntityClass()
    {
        return TypeFormation::class;
    }



    /**
     * Retourne l'alias d'entité courante
     *
     * @return string
     */
    public function getAlias()
    {
        return 'typeFormation';
    }


    /**
     * @return string
@@ -147,4 +173,17 @@ class TypeFormation implements HistoriqueAwareInterface, ImportAwareInterface
        return $this->getLibelleLong();
    }

    /**
     * Retourne une nouvelle entité, initialisée avec les bons paramètres
     *
     * @return TypeFormation
     */
    public function newEntity(): TypeFormation
    {
        $entity = parent::newEntity();
        // toutes les entités créées ont OSE pour source!!
        $entity->setSource($this->getServiceSource()->getOse());

        return $entity;
    }
}
+10 −12
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
                        </div>
                    <?php endif; ?>
                </div>

                <div class="card-body">
                <table class="table table-bordered table-sm">
                    <thead>
                    <tr>
@@ -66,7 +66,7 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
                            <?php if ($canEdit): ?>
                                <td style="text-align: center">
                                    <a class="ajax-modal" data-event="type-formation-edition"
                                       href="<?= $this->url('type-formation/saisie', ['typeFormation' => $typeFormation->getId()], ['query' => ['tab' => 'edition']]) ?>"
                                       href="<?= $this->url('type-formation/saisie', ['typeFormation' => $typeFormation->getId(), 'groupeTypeFormation' => $groupeTypeFormation->getId()], ['query' => ['tab' => 'edition']]) ?>"
                                       title="Modifier le type de formation"><i class="fas fa-pen-to-square"></i></a>
                                    <?php if (!$typeFormation->getSource()->getImportable()): ?>
                                        <a class="pop-ajax" data-title="Suppression du type de formation" data-content="Êtes-vous sur de vouloir supprimer ?"
@@ -82,8 +82,14 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
                    <?php endforeach; ?>
                    </tbody>
                </table>


                <?php if ($canEdit): ?>
                    <tr class="champ-triable">
                        <a class="btn btn-primary ajax-modal " data-event="type-formation-edition" href="<?= $this->url('type-formation/saisie', ['typeFormation' => '','groupeTypeFormation' => $groupeTypeFormation->getId()]); ?>"><i
                                    class="fas fa-plus"></i>
                            Ajout d'un nouveau type de formation</a>
                    </tr>
                <?php endif; ?>
            </div>
            </div>
        </div>
    <?php endforeach; ?>
@@ -139,14 +145,6 @@ echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
        </a>
    </tr>
<?php endif; ?>
<?php if ($canEdit): ?>
    <tr class="champ-triable">
        <a class="btn btn-primary ajax-modal " data-event="type-formation-edition" href="<?= $this->url('type-formation/saisie'); ?>"><i
                    class="fas fa-plus"></i>
            Ajout d'un nouveau type de formation</a>
    </tr>
<?php endif; ?>


<script type="text/javascript">
    $(function () {