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

Refonte de l'affichage de la page des type

parent 7623f707
Loading
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -7,18 +7,27 @@ use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
use UnicaenEtat\Entity\Db\EtatType;
use UnicaenEtat\Form\EtatType\EtatTypeFormAwareTrait;
use UnicaenEtat\Service\EtatCategorie\EtatCategorieServiceAwareTrait;
use UnicaenEtat\Service\EtatType\EtatTypeServiceAwareTrait;

class EtatTypeController extends AbstractActionController
{
    use EtatTypeServiceAwareTrait;
    use EtatCategorieServiceAwareTrait;
    use EtatTypeFormAwareTrait;

    public function indexAction() : ViewModel
    {
        $types = $this->getEtatTypeService()->getEtatsTypes();
        $categories = $this->getEtatCategorieService()->getEtatsCategories();
        
        $dictionnaire = [];
        foreach ($categories as $categorie) {
            $types = $this->getEtatTypeService()->getEtatsTypesByCategorie($categorie);
            $dictionnaire[$categorie->getId()] = $types;
        }
        return new ViewModel([
            'types' => $types,
            'categories' => $categories,
            'dictionnaire' => $dictionnaire,
        ]);
    }

+4 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ namespace UnicaenEtat\Controller;

use Interop\Container\ContainerInterface;
use UnicaenEtat\Form\EtatType\EtatTypeForm;
use UnicaenEtat\Service\EtatCategorie\EtatCategorieService;
use UnicaenEtat\Service\EtatType\EtatTypeService;

class EtatTypeControllerFactory {
@@ -17,8 +18,10 @@ class EtatTypeControllerFactory {
    public function __invoke(ContainerInterface $container) : EtatTypeController
    {
        /**
         * @var EtatCategorieService $etatCategorieService
         * @var EtatTypeService $etatTypeService
         */
        $etatCategorieService = $container->get(EtatCategorieService::class);
        $etatTypeService = $container->get(EtatTypeService::class);

        /**
@@ -27,6 +30,7 @@ class EtatTypeControllerFactory {
        $etatTypeForm = $container->get('FormElementManager')->get(EtatTypeForm::class);

        $controller = new EtatTypeController();
        $controller->setEtatCategorieService($etatCategorieService);
        $controller->setEtatTypeService($etatTypeService);
        $controller->setEtatTypeForm($etatTypeForm);
        return $controller;
+56 −5
Original line number Diff line number Diff line
@@ -2,9 +2,11 @@

/**
 * @see \UnicaenEtat\Controller\EtatTypeController::indexAction()
 * @var EtatType[] $types
 * @var EtatCategorie[] $categories
 * @var array[] $dictionnaire
 */

use \UnicaenEtat\Entity\Db\EtatCategorie;
use UnicaenEtat\Entity\Db\EtatType;

$this->headTitle("Types d'état")
@@ -13,12 +15,11 @@ $this->headTitle("Types d'état")
    <div class="col-md-8">
        <h1 class="page-header">
            Types d'état
            <span class="badge"><?php echo count($types); ?></span>
        </h1>

        <?php /** @see \UnicaenEtat\Controller\EtatController::ajouterAction() */ ?>
        <a href="<?php echo $this->url('unicaen-etat/etat-type/ajouter', [], [], true); ?>"
           class="btn btn-primary action ajax-modal" data-event="modification">
           class="btn btn-primary ajax-modal" data-event="modification">
            <span class="icon icon-ajouter"></span>
            Ajouter un type d'état
        </a>
@@ -26,13 +27,13 @@ $this->headTitle("Types d'état")
    <div class="col-md-4">
        <?php /** @see \UnicaenEtat\Controller\EtatCategorieController::indexAction() */ ?>
        <a href="<?php echo $this->url('unicaen-etat/etat-categorie', [], [], true); ?>"
           class="btn btn-secondary action">
           class="btn btn-secondary">
            <span class="icon icon-listing"></span>
            Accéder aux catégories
        </a>
        <br/>
        <a href="<?php echo $this->url('unicaen-etat/etat-instance', [], [], true); ?>"
           class="btn btn-secondary action">
           class="btn btn-secondary">
            <span class="icon icon-listing"></span>
            Accéder aux instances
        </a>
@@ -43,6 +44,56 @@ $this->headTitle("Types d'état")

<div class="main">

    <?php foreach ($categories as $categorie): ?>
        <h2> [<?php echo $categorie->getCode(); ?>] <?php echo $categorie->getLibelle(); ?> </h2>

        <table id="categorie_<?php echo $categorie->getCode(); ?>" class="datatable table table-condensed">
            <thead>
            <tr>
                <th class="col-md-1">Badge</th>
                <th class="col-md-3">Code</th>
                <th class="col-md-5">Libelle</th>
                <th class="col-md-1">Type</th>
                <th class="col-md-1">Ordre</th>
                <th class="col-md-1">Action</th>
            </tr>
            </thead>
            <?php foreach ($dictionnaire[$categorie->getId()] as $type) : ?>
                <tr>
                    <td>
                        <?php echo $this->etattype($type, []); ?>
                    </td>
                    <td> <?php echo $type->getCode(); ?> </td>
                    <td> <?php echo $type->getLibelle(); ?> </td>
                    <td> <?php echo $type->getOrdre(); ?> </td>
                    <td>
                        <?php if ($type->getCategorie()) : ?>
                            <?php echo $this->etatcategorie($type->getCategorie()); ?>
                        <?php else : ?>
                            Aucune
                        <?php endif; ?>
                    </td>
                    <td class="action">
                        <?php /** @see \UnicaenEtat\Controller\EtatController::modifierAction() */ ?>
                        <a href="<?php echo $this->url('unicaen-etat/etat-type/modifier', ['type' => $type->getId()], [], true); ?>"
                           class="ajax-modal action primary" data-event="modification">
                            <span class="icon icon-editer"></span>
                            Modifier
                        </a>
                        <br>
                        <?php /** @see \UnicaenEtat\Controller\EtatController::supprimerAction() */ ?>
                        <a href="<?php echo $this->url('unicaen-etat/etat-type/supprimer', ['type' => $type->getId()], [], true); ?>"
                           class="ajax-modal action danger" data-event="modification">
                            <span class="icon icon-unchecked"></span>
                            Supprimer
                        </a>
                    </td>
                </tr>
            <?php endforeach; ?>
        </table>

    <?php endforeach; ?>

    <?php if (empty($types)) : ?>
        Aucun type d'état
    <?php else : ?>