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

Ajout de l'extraction des fiches de postes au niveaux de la structure

parent 9dac29a0
Loading
Loading
Loading
Loading
+27 −0
Changes for module/Application/config/merged/structure.config.php: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ return [
                    'controller' => StructureController::class,
                    'action' => [
                        'index',
                        'extraction-listing-fiche-poste',
                    ],
                    'privileges' => StructurePrivileges::STRUCTURE_INDEX,
                ],
@@ -292,6 +293,32 @@ return [
                        ],
                        'may_terminate' => true,
                    ],

                    /** Extraction  */
                    'extraction' => [
                        'type'  => Literal::class,
                        'options' => [
                            'route'    => '/extraction',
                            'defaults' => [
                                'controller' => StructureController::class,
                            ],
                        ],
                        'may_terminate' => false,
                        'child_routes' => [
                            'listing-fiche-poste' => [
                                'type'  => Segment::class,
                                'options' => [
                                    'route'    => '/listing-fiche-poste/:structure',
                                    'defaults' => [
                                        'controller' => StructureController::class,
                                        'action'     => 'extraction-listing-fiche-poste',
                                    ],
                                ],
                                'may_terminate' => true,
                                'child_routes' => [],
                            ],
                        ],
                    ],
                ],
            ],
        ],
+39 −0
Changes for module/Application/src/Application/Controller/StructureController.php: 39 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ use Application\Service\Poste\PosteServiceAwareTrait;
use Application\Service\Structure\StructureServiceAwareTrait;
use Application\Service\StructureAgentForce\StructureAgentForceServiceAwareTrait;
use UnicaenApp\Form\Element\SearchAndSelect;
use UnicaenApp\View\Model\CsvModel;
use UnicaenUtilisateur\Entity\Db\User;
use UnicaenUtilisateur\Service\Role\RoleServiceAwareTrait;
use UnicaenUtilisateur\Service\User\UserServiceAwareTrait;
@@ -434,6 +435,44 @@ class StructureController extends AbstractActionController {
        return $vm;
    }

    /** EXTRACTIONS ***************************************************************************************************/

    /**
     * Extraction du listing des agents et des fiches de poste associées
     */
    public function extractionListingFichePosteAction()
    {
        $structure = $this->getStructureService()->getRequestedStructure($this);
        $structures = $this->getStructureService()->getStructuresFilles($structure);
        $agents = $this->getAgentService()->getAgentsByStructures($structures);

        $filename = "strcuture" . ".csv";
        $header = ["Agent", "Fiche metier principale", "Complement"];

        $result = [];
        foreach ($agents as $agent) {
            $denomination = $agent->getDenomination();
            $fiche = "";
            $complement = "";

            $ficheposte = $agent->getFichePosteActif();
            if ($ficheposte !== null) {
                $fiche = $ficheposte->getLibelleMetierPrincipal();
                $complement = $ficheposte->getLibelle();
            }

            $result[] = [$denomination, $fiche, $complement];
        }

        $CSV = new CsvModel();
        $CSV->setDelimiter(';');
        $CSV->setEnclosure('"');
        $CSV->setHeader($header);
        $CSV->setData($result);
        $CSV->setFilename($filename);
        return $CSV;

    }
    /** AUTRE FONCTIONS */

//    public function grapheAction() {
+2 −4
Changes for module/Application/view/application/structure/afficher.phtml: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -107,8 +107,7 @@ $canAfficherStructure = $this->isAllowed($structure, StructurePrivileges::STRU

                <li role="extraction">
                    <a href="#extraction" aria-controls="extraction" role="tab" data-toggle="tabz" >
                        Extractions  <br/>
                        <span class="todo">TODO</span>
                        Extractions  <br/> &nbsp;
                    </a>
                </li>
            </ul>
@@ -179,8 +178,7 @@ $canAfficherStructure = $this->isAllowed($structure, StructurePrivileges::STRU

                <!-- Extraction ------------------------------------------------------------------------------------->
                <div id="extraction" class="tab-pane " role="tabpanel">

                    À venir
                    <?php echo $this->partial('partial/extraction', ['structure' => $structure]); ?>
                </div>
            </div>
        </div>
+17 −0
Changes for module/Application/view/application/structure/partial/extraction.phtml: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

use Application\Entity\Db\Structure;

/**
 * @var Structure $structure
 */

?>

<h2>Listing des fiches de postes</h2>

<a href="<?php echo $this->url('structure/extraction/listing-fiche-poste', ['structure' => $structure->getId()], [], true); ?>"
   class="btn btn-primary action"
>
    <span class="icon csv"></span> Extraire au format CSV
</a>