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

Permier test de filtrage

parent 52b36a5b
Loading
Loading
Loading
Loading
+15 −2
Changes for src/UnicaenIndicateur/Controller/IndicateurController.php: 15 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -4,8 +4,8 @@ namespace UnicaenIndicateur\Controller;

use DateTime;
use Laminas\Http\Response;
use UnicaenIndicateur\Entity\Db\Categorie;
use UnicaenIndicateur\Entity\Db\Indicateur;
use UnicaenIndicateur\Entity\Db\Categorie;
use UnicaenIndicateur\Form\Indicateur\IndicateurFormAwareTrait;
use UnicaenIndicateur\Service\Abonnement\AbonnementServiceAwareTrait;
use UnicaenIndicateur\Service\Indicateur\IndicateurServiceAwareTrait;
@@ -63,8 +63,21 @@ class IndicateurController extends AbstractActionController {
        $indicateur = $this->getIndicateurService()->getRequestedIndicateur($this);
        $mails = $this->getMailService()->getMailsByMotClef($indicateur->generateTag());

        $userStructurePerimetre = [12,5];
        $userRolePerimetre = [1,15];

        $userPerimetre = null;
        switch ($indicateur->getPerimetre()) {
            case Indicateur::PERIMETRE_STRUCTURE:
                $userPerimetre = $userStructurePerimetre;
                break;
            case Indicateur::PERIMETRE_ROLE:
                $userPerimetre = $userRolePerimetre;
                break;
        }

        $exists = $this->getIndicateurService()->verifierExistanceMaterializedView($indicateur->getViewId());
        if ($exists === true) $result = $this->getIndicateurService()->getIndicateurData($indicateur);
        if ($exists === true) $result = $this->getIndicateurService()->getIndicateurData($indicateur, $userPerimetre);

        return new ViewModel([
            'indicateur' => $indicateur,
+17 −1
Changes for src/UnicaenIndicateur/Entity/Db/Indicateur.php: 17 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ namespace UnicaenIndicateur\Entity\Db;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use UnicaenIndicateur\Entity\Db\Categorie;

class Indicateur {

@@ -14,6 +13,10 @@ class Indicateur {
    const ENTITY_LIBRE = 'Libre';
    const ENTITY_ADAPTATIF = 'Adaptatif';

    const PERIMETRE_AUCUN = 'aucun';
    const PERIMETRE_STRUCTURE = 'structure';
    const PERIMETRE_ROLE = 'role';

    private ?int $id = null;
    private ?string $code = null;
    private ?string $titre = null;
@@ -29,6 +32,8 @@ class Indicateur {
    private Collection $tableaux;
    private ?int $nbElements = null;

    private ?string $perimetre = null;

    public function __construct()
    {
        $this->abonnements = new ArrayCollection();
@@ -142,6 +147,17 @@ class Indicateur {
        $this->nbElements = $nbElements;
    }

    public function getPerimetre(): ?string
    {
        return $this->perimetre;
    }

    public function setPerimetre(?string $perimetre): void
    {
        $this->perimetre = $perimetre;
    }


    /** Abonnements **************************************************************** */

    /**
+1 −0
Changes for src/UnicaenIndicateur/Entity/Db/Mapping/UnicaenIndicateur.Entity.Db.Indicateur.dcm.xml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
        <field name="viewId"            type="string" length="255"      column="view_id"                nullable="true"/>
        <field name="entity"            type="string" length="255"      column="entity"                nullable="true"/>
        <field name="namespace"         type="string" length="1024"     column="namespace"             nullable="true"/>
        <field name="perimetre"         type="string" length="256"      column="perimetre"             nullable="false"/>
        <field name="nbElements"        type="integer"                  column="nb_elements"             nullable="true"/>


+26 −3
Changes for src/UnicaenIndicateur/Form/Indicateur/IndicateurForm.php: 26 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ class IndicateurForm extends Form {
            'type' => Text::class,
            'name' => 'libelle',
            'options' => [
                'label' => "Libelle* :",
                'label' => "Libelle<span class='icon icon-obligatoire' title='champ obligatoire'></span>  :",
                'label_options' => [ 'disable_html_escape' => true, ],
            ],
            'attributes' => [
                'id' => 'libelle',
@@ -91,7 +92,8 @@ class IndicateurForm extends Form {
            'type' => Text::class,
            'name' => 'view_id',
            'options' => [
                'label' => "Identifiant de la vue* :",
                'label' => "Identifiant de la vue<span class='icon icon-obligatoire' title='champ obligatoire'></span>  :",
                'label_options' => [ 'disable_html_escape' => true, ],
            ],
            'attributes' => [
                'id' => 'libelle',
@@ -102,7 +104,8 @@ class IndicateurForm extends Form {
            'type' => Select::class,
            'name' => 'entity',
            'options' => [
                'label' => "Entity associé* :",
                'label' => "Entity associé<span class='icon icon-obligatoire' title='champ obligatoire'></span>  :",
                'label_options' => [ 'disable_html_escape' => true, ],
                'empty_option' => "Sélectionner une entité ...",
                'value_options' => [
                   Indicateur::ENTITY_LIBRE       => 'Libre',
@@ -116,6 +119,25 @@ class IndicateurForm extends Form {
                'class'             => 'bootstrap-selectpicker show-tick',
            ],
        ]);
        // perimetre
        $this->add([
            'type' => Select::class,
            'name' => 'perimetre',
            'options' => [
                'label' => "Périmètre associé <span class='icon icon-obligatoire' title='champ obligatoire'></span>  :",
                'label_options' => [ 'disable_html_escape' => true, ],
                'empty_option' => "Sélection d'un périmtre",
                'value_options' => [
                    Indicateur::PERIMETRE_AUCUN => "Non soumis à un périmètre",
                    Indicateur::PERIMETRE_ROLE => "Liés aux rôles (requiert une colonne perimetre_role_id)",
                    Indicateur::PERIMETRE_STRUCTURE => "Liés aux structures (requiert une colonne perimetre_structure_id)",
                ],
            ],
            'attributes' => [
                'id' => 'perimetre',
                'class' => 'bootstrap-selectpicker show-tick',
            ],
        ]);
        // requete
        $this->add([
            'name' => 'requete',
@@ -174,6 +196,7 @@ class IndicateurForm extends Form {
            'namespace'             => [ 'required' => false,  ],
            'view_id'               => [ 'required' => true,  ],
            'entity'                => [ 'required' => true,  ],
            'perimetre'             => [ 'required' => true,  ],
            'requete'               => [ 'required' => true,  ],
        ]));
    }
+3 −0
Changes for src/UnicaenIndicateur/Form/Indicateur/IndicateurHydrator.php: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ class IndicateurHydrator implements HydratorInterface {
            'namespace' => $object->getNamespace(),
            'view_id' => $object->getViewId(),
            'entity' => $object->getEntity(),
            'perimetre' => $object->getPerimetre(),
            'requete' => $object->getRequete(),
        ];
        return $data;
@@ -30,6 +31,7 @@ class IndicateurHydrator implements HydratorInterface {
        $code = (isset($data['code']) AND trim($data['code']) !== '')?trim($data['code']):null;
        $categorie = (isset($data['categorie']) && $data['categorie'] !== '')?$this->getCategorieService()->getCategorie($data['categorie']):null;
        $namespace = (isset($data['namespace']) AND trim($data['namespace']) !== '')?trim($data['namespace']):null;
        $perimetre = (isset($data['perimetre']) AND trim($data['perimetre']) !== '')?trim($data['perimetre']):null;

        /** @var Indicateur $object */
        $object->setCode($code);
@@ -37,6 +39,7 @@ class IndicateurHydrator implements HydratorInterface {
        $object->setDescription($data['description']);
        $object->setCategorie($categorie);
        $object->setNamespace($namespace);
        $object->setPerimetre($perimetre);
        $object->setViewId($data['view_id']);
        $object->setEntity($data['entity']);
        $object->setRequete($data['requete']);
Loading