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

Formation ajout du menu administration > etats

parent 519d65bd
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
-- TABLE -----------------------------------------------------------------------------------------
-- ---------------------------------------------------------------------------------------------------------------------


-- TABLE DES ROLES -----------------------------------------------------------------------------------------------------

CREATE TABLE UNICAEN_UTILISATEUR_ROLE (
+29 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Formation\Controller\AdministrationController;
use Formation\Controller\AdministrationControllerFactory;
use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
use UnicaenEtat\Provider\Privilege\EtatPrivileges;
use UnicaenIndicateur\Provider\Privilege\IndicateurPrivileges;
use UnicaenParametre\Provider\Privilege\ParametrecategoriePrivileges;
use UnicaenPrivilege\Guard\PrivilegeController;
@@ -53,6 +54,15 @@ return [
                        DocumenttemplatePrivileges::DOCUMENTTEMPLATE_INDEX,
                    ],
                ],
                [
                    'controller' => AdministrationController::class,
                    'action' => [
                        'etat',
                    ],
                    'privileges' => [
                        EtatPrivileges::ETAT_INDEX,
                    ],
                ],
            ],
        ],
    ],
@@ -99,6 +109,14 @@ return [
                                'resource' => PrivilegeController::getResourceId(IndexController::class, 'index'),
                                'icon' => 'fas fa-angle-right',
                            ],
                            'etat' => [
                                'order' => 2100,
                                'label' => 'États',
                                'route' => 'formation/administration/etat',
//                                'resource' => PrivilegeController::getResourceId(EtatPrivileges::ETAT_INDEX),
                                'resource' => PrivilegeController::getResourceId(AdministrationController::class, 'etat'),
                                'icon' => 'fas fa-angle-right',
                            ],
                        ],
                    ],
                ],
@@ -164,6 +182,17 @@ return [
                                    ],
                                ],
                            ],
                            'etat' => [
                                'type' => Segment::class,
                                'options' => [
                                    /** @see AdministrationController::etatAction() */
                                    'route' => '/etat',
                                    'defaults' => [
                                        'controller' => AdministrationController::class,
                                        'action' => 'etat',
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
+19 −0
Original line number Diff line number Diff line
@@ -2,8 +2,12 @@

namespace Formation\Controller;

use Formation\Provider\Etat\DemandeExterneEtats;
use Formation\Provider\Etat\InscriptionEtats;
use Formation\Provider\Etat\SessionEtats;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
use UnicaenEtat\Service\EtatType\EtatTypeServiceAwareTrait;
use UnicaenIndicateur\Service\Indicateur\IndicateurServiceAwareTrait;
use UnicaenIndicateur\Service\TableauDeBord\TableauDeBordServiceAwareTrait;
use UnicaenParametre\Service\Categorie\CategorieServiceAwareTrait;
@@ -15,6 +19,7 @@ use UnicaenUtilisateur\Service\Role\RoleServiceAwareTrait;
class AdministrationController extends AbstractActionController
{
    use CategorieServiceAwareTrait;
    use EtatTypeServiceAwareTrait;
    use IndicateurServiceAwareTrait;
    use ParametreServiceAwareTrait;
    use PrivilegeServiceAwareTrait;
@@ -77,4 +82,18 @@ class AdministrationController extends AbstractActionController
        $vm->setTemplate('unicaen-renderer/template/index');
        return $vm;
    }

    public function etatAction() : ViewModel
    {
        $types = [
            $this->getEtatTypeService()->getEtatTypeByCode(SessionEtats::TYPE),
            $this->getEtatTypeService()->getEtatTypeByCode(InscriptionEtats::TYPE),
            $this->getEtatTypeService()->getEtatTypeByCode(DemandeExterneEtats::TYPE),
        ];

        $vm = new ViewModel([
            'etatTypes' => $types,
        ]);
        return $vm;
    }
}
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ namespace Formation\Controller;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenEtat\Service\EtatType\EtatTypeService;
use UnicaenIndicateur\Service\Indicateur\IndicateurService;
use UnicaenIndicateur\Service\TableauDeBord\TableauDeBordService;
use UnicaenParametre\Service\Categorie\CategorieService;
@@ -25,6 +26,7 @@ class AdministrationControllerFactory {
    {
        /**
         * @var CategorieService $categorieService
         * @var EtatTypeService $etatTypeService
         * @var IndicateurService $indicateurService
         * @var ParametreService $parametreService
         * @var PrivilegeService $privilegeService
@@ -33,6 +35,7 @@ class AdministrationControllerFactory {
         * @var TemplateService $templateService
         */
        $categorieService = $container->get(CategorieService::class);
        $etatTypeService = $container->get(EtatTypeService::class);
        $indicateurService = $container->get(IndicateurService::class);
        $parametreService = $container->get(ParametreService::class);
        $privilegeService = $container->get(PrivilegeService::class);
@@ -42,6 +45,7 @@ class AdministrationControllerFactory {

        $controller = new AdministrationController();
        $controller->setCategorieService($categorieService);
        $controller->setEtatTypeService($etatTypeService);
        $controller->setIndicateurService($indicateurService);
        $controller->setParametreService($parametreService);
        $controller->setPrivilegeService($privilegeService);
+137 −0
Original line number Diff line number Diff line
<?php

/**
 * @see \UnicaenEtat\Controller\EtatTypeController::indexAction()
 * @var EtatType[] $etatTypes
 */

use UnicaenEtat\Entity\Db\EtatType;

$etats = [];
foreach ($etatTypes as $type) {
    $etats_ = $type->getEtats();
    $etats = array_merge($etats, $etats_);
}
?>
<h1 class="page-header">
    Index des types d'état
</h1>

<div class="main">

    <h2>
        Etat Type
        <span class="badge"><?php echo count($etatTypes); ?></span>
    </h2>
    <?php /** @see \UnicaenEtat\Controller\EtatTypeController::ajouterAction() */ ?>
    <a href="<?php echo $this->url('unicaen-etat/etat-type/ajouter', [], [], true); ?>"
       class="btn btn-primary action ajax-modal" data-event="modification">
        <span class="icon icon-ajouter"></span>
        Ajouter un type d'état
    </a>

    <br/>

    <table id="etat-type" class="datatable table table-condensed">
        <thead>
        <tr>
            <th>Badge</th>
            <th>Code</th>
            <th>Libelle</th>
            <th style="width: 8rem;">Action</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($etatTypes as $etatType) : ?>
            <tr class="<?php if ($etatType->estHistorise()) echo "historise"; ?>">
                <td> <?php echo $this->etattype($etatType); ?> </td>
                <td> <?php echo $etatType->getCode(); ?> </td>
                <td> <?php echo $etatType->getLibelle(); ?> </td>
                <td>
                    <?php /** @see \UnicaenEtat\Controller\EtatTypeController::modifierAction() */ ?>
                    <a href="<?php echo $this->url('unicaen-etat/etat-type/modifier', ['etat-type' => $etatType->getId()], [], true); ?>"
                       class="ajax-modal" data-event="modification">
                        <span class="icon icon-editer"></span></a>
                    <?php if ($etatType->estNonHistorise()) : ?>
                        <?php /** @see \UnicaenEtat\Controller\EtatTypeController::historiserAction() */ ?>
                        <a href="<?php echo $this->url('unicaen-etat/etat-type/historiser', ['etat-type' => $etatType->getId()], [], true); ?>">
                            <span class="icon icon-historiser"></span></a>
                    <?php else: ?>
                        <?php /** @see \UnicaenEtat\Controller\EtatTypeController::restaurerAction() */ ?>
                        <a href="<?php echo $this->url('unicaen-etat/etat-type/restaurer', ['etat-type' => $etatType->getId()], [], true); ?>">
                            <span class="icon icon-restaurer"></span></a>
                    <?php endif; ?>
                    <?php /** @see \UnicaenEtat\Controller\EtatTypeController::supprimerAction() */ ?>
                    <a href="<?php echo $this->url('unicaen-etat/etat-type/supprimer', ['etat-type' => $etatType->getId()], [], true); ?>"
                       class="ajax-modal" data-event="modification">
                        <span class="icon icon-retirer"></span></a>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>

    <h2>
        États
        <span class="badge"><?php echo count($etats); ?></span>
    </h2>
    <?php /** @see \UnicaenEtat\Controller\EtatController::ajouterAction() */ ?>
    <a href="<?php echo $this->url('unicaen-etat/etat/ajouter', [], [], true); ?>"
       class="btn btn-primary action ajax-modal" data-event="modification">
        <span class="icon icon-ajouter"></span>
        Ajouter un d'état
    </a>

    <table id="etat" class="datatable table table-condensed">
        <thead>
        <tr>
            <th>Badge</th>
            <th>Code</th>
            <th>Libelle</th>
            <th>Ordre</th>
            <th>Type</th>
            <th style="width: 8rem;">Action</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($etats as $etat) : ?>
            <tr class="<?php if ($etat->estHistorise()) echo "historise"; ?>">
                <td> <?php echo $this->etatbadge($etat); ?>  </td>
                <td> <?php echo $etat->getCode(); ?> </td>
                <td> <?php echo $etat->getLibelle(); ?> </td>
                <td> <?php echo $etat->getOrdre(); ?> </td>
                <td> <?php echo $this->etattype($etat->getType()); ?>  </td>
                <td>
                    <?php /** @see \UnicaenEtat\Controller\EtatController::modifierAction() */ ?>
                    <a href="<?php echo $this->url('unicaen-etat/etat/modifier', ['etat' => $etat->getId()], [], true); ?>"
                       class="ajax-modal" data-event="modification">
                        <span class="icon icon-editer"></span></a>
                    <?php if ($etat->estNonHistorise()) : ?>
                        <?php /** @see \UnicaenEtat\Controller\EtatController::historiserAction() */ ?>
                        <a href="<?php echo $this->url('unicaen-etat/etat/historiser', ['etat' => $etat->getId()], [], true); ?>">
                            <span class="icon icon-historiser"></span></a>
                    <?php else: ?>
                        <?php /** @see \UnicaenEtat\Controller\EtatController::restaurerAction() */ ?>
                        <a href="<?php echo $this->url('unicaen-etat/etat/restaurer', ['etat' => $etat->getId()], [], true); ?>">
                            <span class="icon icon-restaurer"></span></a>
                    <?php endif; ?>
                    <?php /** @see \UnicaenEtat\Controller\EtatController::supprimerAction() */ ?>
                    <a href="<?php echo $this->url('unicaen-etat/etat/supprimer', ['etat' => $etat->getId()], [], true); ?>"
                       class="ajax-modal" data-event="modification">
                        <span class="icon icon-retirer"></span></a>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>

</div>

<script>
    $(function() {
        $("body").on("modification", function (event) {
            event.div.modal('hide');
            window.location.reload();
        });
    });
</script>
 No newline at end of file
Loading