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

Aide de vue pour les AgentApplication, AgentCompetence, AgentFormation

parent c69b31d4
Loading
Loading
Loading
Loading
+6
Changes for module/Application/config/merged/agent.config.php: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@ use Application\Provider\Privilege\AgentPrivileges;
use Application\Service\Agent\AgentService;
use Application\Service\Agent\AgentServiceFactory;
use Application\View\Helper\AgentAffectationViewHelper;
use Application\View\Helper\AgentApplicationViewHelper;
use Application\View\Helper\AgentCompetenceViewHelper;
use Application\View\Helper\AgentFormationViewHelper;
use Application\View\Helper\AgentGradeViewHelper;
use Application\View\Helper\AgentStatutViewHelper;
use Application\View\Helper\AgentViewHelper;
@@ -604,6 +607,9 @@ return [
        'invokables' => [
            'agent' => AgentViewHelper::class,
            'agentAffectation' => AgentAffectationViewHelper::class,
            'agentApplication' => AgentApplicationViewHelper::class,
            'agentCompetence' => AgentCompetenceViewHelper::class,
            'agentFormation' => AgentFormationViewHelper::class,
            'agentStatut' => AgentStatutViewHelper::class,
            'agentGrade' => AgentGradeViewHelper::class,
        ],
+27
Changes for module/Application/src/Application/View/Helper/AgentApplicationViewHelper.php: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper;


use Application\Entity\Db\Agent;
use Zend\View\Helper\AbstractHelper;
use Zend\View\Helper\Partial;
use Zend\View\Renderer\PhpRenderer;
use Zend\View\Resolver\TemplatePathStack;

class AgentApplicationViewHelper extends AbstractHelper
{
    /**
     * @param Agent $agent
     * @param array $options
     * @return string|Partial
     */
    public function __invoke($agent, $options = [])
    {
        /** @var PhpRenderer $view */
        $view = $this->getView();
        $view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]]));

        return $view->partial('agent-application', ['agent' => $agent, 'options' => $options]);
    }
}
+26
Changes for module/Application/src/Application/View/Helper/AgentCompetenceViewHelper.php: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper;

use Application\Entity\Db\Agent;
use Zend\View\Helper\AbstractHelper;
use Zend\View\Helper\Partial;
use Zend\View\Renderer\PhpRenderer;
use Zend\View\Resolver\TemplatePathStack;

class AgentCompetenceViewHelper extends AbstractHelper
{
    /**
     * @param Agent $agent
     * @param array $options
     * @return string|Partial
     */
    public function __invoke($agent, $options = [])
    {
        /** @var PhpRenderer $view */
        $view = $this->getView();
        $view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]]));

        return $view->partial('agent-competence', ['agent' => $agent, 'options' => $options]);
    }
}
+26
Changes for module/Application/src/Application/View/Helper/AgentFormationViewHelper.php: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper;

use Application\Entity\Db\Agent;
use Zend\View\Helper\AbstractHelper;
use Zend\View\Helper\Partial;
use Zend\View\Renderer\PhpRenderer;
use Zend\View\Resolver\TemplatePathStack;

class AgentFormationViewHelper extends AbstractHelper
{
    /**
     * @param Agent $agent
     * @param array $options
     * @return string|Partial
     */
    public function __invoke($agent, $options = [])
    {
        /** @var PhpRenderer $view */
        $view = $this->getView();
        $view->resolver()->attach(new TemplatePathStack(['script_paths' => [__DIR__ . "/partial"]]));

        return $view->partial('agent-formation', ['agent' => $agent, 'options' => $options]);
    }
}
+203
Changes for module/Application/src/Application/View/Helper/partial/agent-application.phtml: 203 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

use Application\Entity\Db\Agent;
use Application\Entity\Db\AgentApplication;

/**
 * @var Agent $agent
 * @var array $options
 */

$canVoir        = (isset($options['droits']) AND isset($options['droits']['afficher']))     ? $options['droits']['afficher']    : false;
$canAjouter     = (isset($options['droits']) AND isset($options['droits']['ajouter']))      ? $options['droits']['ajouter']     : false;
$canModifier    = (isset($options['droits']) AND isset($options['droits']['modifier']))     ? $options['droits']['modifier']    : false;
$canHistoriser  = (isset($options['droits']) AND isset($options['droits']['historiser']))   ? $options['droits']['historiser']  : false;
$canDetruire    = (isset($options['droits']) AND isset($options['droits']['detruire']))     ? $options['droits']['detruire']    : false;
$canValider     = (isset($options['droits']) AND isset($options['droits']['valider']))      ? $options['droits']['valider']     : false;


?>

<div class="row">
    <div class="col-md-8" style="border-bottom: 1px solid #31708f">
        <h3> <span class="icon application"></span> Applications maîtrisées </h3>
    </div>
    <div class="pull-right">
        <br/>
        <?php if ($canAjouter) : ?>
            <a
                <?php /** @see \Application\Controller\AgentController::ajouterAgentApplicationAction() */?>
                href="<?php echo $this->url('agent/ajouter-agent-application', ['agent' => $agent->getId()], [], true); ?>"
                class="ajax-modal btn btn-primary action"
                data-event="modification"
            >
                <span class="icon ajouter" title="Ajouter une application maîtrisée par l'agent"></span>
                Ajouter une application
            </a>
        <?php endif; ?>
    </div>
</div>
<br/>
<?php
$noGroupe = "ZZZ";
$dictionnaire = [];
foreach ($agent->getApplications(true) as $agentApplication) {
    $application = $agentApplication->getApplication();
    $groupe = $application->getGroupe();
    $libelle = ($groupe)?$groupe->getLibelle():$noGroupe;
    $dictionnaire[$libelle][] = $agentApplication;
}
ksort($dictionnaire);
?>

<div class="row">
    <div class="col-md-1"></div>
    <div class="col-md-10">
        <?php if ($canModifier) : ?>
            <div class="form-group">
                <div class="checkbox">
                    <label>
                        <input type="checkbox" id="applications-historisees"> Afficher les applications historisées
                    </label>
                </div>
            </div>
        <?php endif; ?>
        <table class="parcours-de-formation" id="applications">
            <tbody>
            <?php foreach ($dictionnaire as $key => $liste) : ?>
                <?php usort($liste, function(AgentApplication $a, AgentApplication $b) {return $a->getApplication()->getLibelle() > $b->getApplication()->getLibelle();}); ?>
                <?php
                $allHisto = true;
                foreach ($liste as $agentApplication) {
                    if ($agentApplication->estNonHistorise()) {
                        $allHisto = false;
                        break;
                    }
                }
                ?>
                <tr>
                    <?php if ($key !== $noGroupe) : ?>
                        <?php $groupe = $liste[0]->getApplication()->getGroupe(); ?>
                        <th colspan="4" style="background: <?php echo $groupe->getCouleur(); ?>;" <?php if ($allHisto) echo 'class="historise"'; ?>>
                            <?php echo $groupe->getLibelle(); ?>
                        </th>
                    <?php else :?>
                        <th colspan="4" style="background: gray;" <?php if ($allHisto) echo 'class="historise"'; ?>> Sans groupe ...</th>
                    <?php endif; ?>
                </tr>
                <?php foreach ($liste as $agentApplication) : ?>
                    <tr <?php if ($agentApplication->estHistorise()) echo 'class="historise"'; ?>>
                        <td> <?php echo $agentApplication->getApplication()->getLibelle(); ?> </td>
                        <td> <?php echo $agentApplication->getAnnee(); ?> <?php echo $agentApplication->getType(); ?> </td>
                        <td>
                            <?php if ($agentApplication->getValidation()) : ?>
                            <?php $validation = $agentApplication->getValidation(); ?>
                            <?php if ($validation->getValeur() === null) : ?>
                                <span
                                    style="color:darkgreen;"
                                    title=" Par <?php echo $validation->getHistoModificateur()->getDisplayName(); ?> le <?php echo $validation->getHistoModification()->format("d/m/Y"); ?>">
                                <span class="icon ok"></span>
                                Validée
                            </span>
                            <?php else: ?>
                            <span
                                style="color:darkred;"
                                title=" Par <?php echo $validation->getHistoModificateur()->getDisplayName(); ?> le <?php echo $validation->getHistoModification()->format("d/m/Y"); ?>">
                                <span class="icon ko"></span>
                            Refusée
                        <?php endif; ?>
                                <?php else : ?>
                                    Aucune validation
                                <?php endif; ?>
                        </td>
                        <td>
                            <?php if ($canVoir) : ?>
                                <a
                                    <?php /** @see \Application\Controller\AgentController::afficherAgentApplicationAction() */?>
                                    href="<?php echo $this->url('agent/afficher-agent-application', ['agent-application' => $agentApplication->getId()], [], true); ?>"
                                    class="ajax-modal"
                                >
                                    <span class="icon voir" title="Afficher une application maîtriser par l'agent"></span></a>
                            <?php endif; ?>
                            <?php if ($canModifier) : ?>
                                <a
                                    <?php /** @see \Application\Controller\AgentController::modifierAgentApplicationAction() */?>
                                    href="<?php echo $this->url('agent/modifier-agent-application', ['agent-application' => $agentApplication->getId()], [], true); ?>"
                                    class="ajax-modal"
                                    data-event="modification"
                                >
                                    <span class="icon editer" title="Modifier une application maîtriser par l'agent"></span></a>
                            <?php endif; ?>
                            <?php if ($canHistoriser) : ?>
                                <?php if ($agentApplication->estNonHistorise()) : ?>
                                    <a
                                        <?php /** @see \Application\Controller\AgentController::historiserAgentApplicationAction() */?>
                                        href="<?php echo $this->url('agent/historiser-agent-application', ['agent-application' => $agentApplication->getId()], ['query' => ['retour' => $retour]], true); ?>"
                                    >
                                        <span class="icon historiser" title="Historiser une application maîtriser par l'agent"></span></a>
                                <?php else: ?>
                                    <a
                                        <?php /** @see \Application\Controller\AgentController::restaurerAgentApplicationAction() */?>
                                        href="<?php echo $this->url('agent/restaurer-agent-application', ['agent-application' => $agentApplication->getId()], ['query' => ['retour' => $retour]], true); ?>"
                                    >
                                        <span class="icon restaurer" title="Restaurer une application maîtriser par l'agent"></span></a>
                                <?php endif; ?>
                            <?php endif; ?>
                            <?php if ($canDetruire) : ?>
                                <a
                                    <?php /** @see \Application\Controller\AgentController::detruireAgentApplicationAction() */?>
                                    href="<?php echo $this->url('agent/detruire-agent-application', ['agent-application' => $agentApplication->getId()], [], true); ?>"
                                    class="ajax-modal"
                                    data-event="modification"
                                >
                                    <span class="icon detruire" title="Supprimer définitivement une application maîtriser par l'agent"></span>
                                </a>
                            <?php endif; ?>
                            <?php if ($canValider) : ?>
                                <?php if ($agentApplication->getValidation() === null) : ?>
                                    <a
                                        <?php /** @see \Application\Controller\AgentController::validerElementAction() */ ?>
                                        href="<?php echo $this->url('agent/valider-element', ['type' => "AgentApplication", 'id' => $agentApplication->getId()], [], true); ?>"
                                        class="ajax-modal"
                                        data-event="modification"
                                    >
                                        <span class="icon validation-do" title="Valider l'application"></span></a>
                                <?php else: ?>
                                    <a
                                        <?php /** @see \Application\Controller\AgentController::revoquerElementAction() */ ?>
                                        href="<?php echo $this->url('agent/revoquer-element', ['validation' => $agentApplication->getValidation()->getId()], ['query' => ['retour' => $retour]], true); ?>"
                                    >
                                        <span class="icon validation-undo" title="Dévalider l'application"></span></a>
                                <?php endif; ?>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>

<script>

    function toogleApplicationsHistorisees() {
        let checked = $('input#applications-historisees').prop('checked');
        if (checked === true) {
            $('table#applications  th.historise').show();
            $('table#applications  tr.historise').show();
        } else {
            $('table#applications  th.historise').hide();
            $('table#applications  tr.historise').hide();
        }
    }

    $(document).ready(function() {
        toogleApplicationsHistorisees();
    });

    $('input#applications-historisees').change(function() {
        toogleApplicationsHistorisees();
    });

</script>
 No newline at end of file
Loading