Skip to content
Snippets Groups Projects
Commit d10cea53 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Revoquer remonter SI

parent 6c2b6c71
Branches
Tags 1.0.3
No related merge requests found
......@@ -35,6 +35,8 @@ return [
'ajouter',
'modifier',
'supprimer',
'historiser',
'restaurer',
],
'privilege' => [
AgentPrivileges::getResourceId(AgentPrivileges::AGENT_MODIFIER),
......@@ -99,6 +101,28 @@ return [
],
],
],
'historiser' => [
'type' => Segment::class,
'options' => [
'route' => '/historiser/:agent-validateur',
'defaults' => [
/** @see ValidateurController::historiserAction() */
'controller' => ValidateurController::class,
'action' => 'historiser',
],
],
],
'restaurer' => [
'type' => Segment::class,
'options' => [
'route' => '/restaurer/:agent-validateur',
'defaults' => [
/** @see ValidateurController::restaurerAction() */
'controller' => ValidateurController::class,
'action' => 'restaurer',
],
],
],
],
],
],
......
......@@ -63,7 +63,7 @@ class AgentController extends AbstractActionController
$agentAffectations = $this->getAgentAffectationService()->getAgentAffectationsByAgent($agent);
$agentGrades = $this->getAgentGradeService()->getAgentGradesByAgent($agent);
$agentStatuts = $this->getAgentStatutService()->getAgentStatutsByAgent($agent);
$validateurs = $this->getAgentValidateurService()->getAgentsValidateursByAgent($agent);
$validateurs = $this->getAgentValidateurService()->getAgentsValidateursByAgent($agent, true);
$formations = $this->getInscriptionService()->getInscriptionsByAgent($agent);
$inscriptions = $this->getInscriptionService()->getInscriptionsByAgent($agent);
......
......@@ -6,6 +6,7 @@ use Agent\Entity\Db\AgentValidateur;
use Agent\Form\Validateur\ValidateurFormAwareTrait;
use Agent\Service\Agent\AgentServiceAwareTrait;
use Agent\Service\AgentValidateur\AgentValidateurServiceAwareTrait;
use Laminas\Http\Response;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\ViewModel;
......@@ -100,4 +101,23 @@ class ValidateurController extends AbstractActionController
return $vm;
}
public function historiserAction(): Response
{
$validateur = $this->getAgentValidateurService()->getRequestedAgentValidateur($this);
$this->getAgentValidateurService()->historise($validateur);
$retour = $this->params()->fromQuery('retour');
if ($retour) return $this->redirect()->toUrl($retour);
return $this->redirect()->toRoute('agent/afficher', ["agent" => $validateur->getAgent()->getId()], [], true);
}
public function restaurerAction(): Response
{
$validateur = $this->getAgentValidateurService()->getRequestedAgentValidateur($this);
$this->getAgentValidateurService()->restore($validateur);
$retour = $this->params()->fromQuery('retour');
if ($retour) return $this->redirect()->toUrl($retour);
return $this->redirect()->toRoute('agent/afficher', ["agent" => $validateur->getAgent()->getId()], [], true);
}
}
\ No newline at end of file
......@@ -67,7 +67,7 @@ class AgentValidateurService
return $qb;
}
public function getAgentValidateur(?int $id) : ?AgentValidateur
public function getAgentValidateur(?string $id) : ?AgentValidateur
{
$qb = $this->createQueryBuilder()
->andWhere('AgentValidateur.id = :id')->setParameter('id', $id);
......@@ -103,6 +103,7 @@ class AgentValidateurService
$qb = $this->createQueryBuilder()
->andWhere('AgentValidateur.agent = :agent')->setParameter('agent', $agent)
->andWhere('agent.deleted_on IS NULL')
->andWhere('AgentValidateur.deletedOn IS NULL')
->orderBy('AgentValidateur.' . $champ, $ordre);
if ($histo === false) $qb = $qb->andWhere('AgentValidateur.histoDestruction IS NULL');
......@@ -115,6 +116,7 @@ class AgentValidateurService
{
$qb = $this->createQueryBuilder()
->andWhere('AgentValidateur.validateur = :validateur')->setParameter('validateur', $validateur)
->andWhere('AgentValidateur.deletedOn IS NULL')
->orderBy('AgentValidateur.' . $champ, $ordre);
if ($histo === false) $qb = $qb->andWhere('AgentValidateur.histoDestruction IS NULL');
......@@ -213,6 +215,7 @@ class AgentValidateurService
$qb = $this->getObjectManager()->getRepository(AgentValidateur::class)->createQueryBuilder('avalidateur')
->join('avalidateur.validateur', 'agent')
->join('agent.utilisateur', 'utilisateur')
->andWhere('avalidateur.deletedOn IS NULL')
->orderBy('agent.nomUsuel, agent.prenom', 'ASC')
;
$result = $qb->getQuery()->getResult();
......@@ -239,6 +242,7 @@ class AgentValidateurService
->andWhere('avalidateur.histoDestruction IS NULL')
->andWhere('avalidateur.dateDebut <= :now')
->andWhere('avalidateur.dateFin IS NULL OR avalidateur.dateFin >= :now')
->andWhere('avalidateur.deletedOn IS NULL')
->setParameter('user', $user)
->setParameter('now', new DateTime())
;
......@@ -252,6 +256,7 @@ class AgentValidateurService
->andWhere('avalidateur.histoDestruction IS NULL')
->andWhere('avalidateur.dateDebut <= :now')
->andWhere('avalidateur.dateFin IS NULL OR avalidateur.dateFin >= :now')
->andWhere('avalidateur.deletedOn IS NULL')
->setParameter('now', new DateTime())
->andWhere('avalidateur.agent = :agent')->setParameter('agent', $agent)
->andWhere('avalidateur.validateur = :validateur')->setParameter('validateur', $validateur)
......
......@@ -55,7 +55,7 @@ $canModifier = $this->isAllowed(AgentPrivileges::getResourceId(AgentPrivileges::
?>
<?php if ($structure) : ?>
<?php echo $structure->getLibelleLong(); ?>
<?php if ($niveau2 AND $niveau2 !== $structure) : ?>
<?php if ($niveau2 and $niveau2 !== $structure) : ?>
<br/> Rattaché&middot;e à <?php echo $niveau2->getLibelleLong(); ?>
<?php endif; ?>
<?php endif; ?>
......@@ -137,10 +137,13 @@ $canModifier = $this->isAllowed(AgentPrivileges::getResourceId(AgentPrivileges::
<?php else: ?>
<ul>
<?php foreach ($validateurs as $validateur) : ?>
<?php if (!$validateur->estHistorise() or $canModifier) : ?>
<li
title="Sur la période du <?php echo $validateur->getDateDebut()->format('d/m/Y'); ?> au <?php echo $validateur->getDateFin() ? $validateur->getDateFin()->format('d/m/y') : " ---"; ?>">
<?php echo $validateur->getValidateur()->getDenomination(); ?> <span class="badge"> <?php echo $validateur->getSourceId(); ?> </span>
<?php if ($validateur->getSourceId() === 'MES FORMATIONS' AND $canModifier) : ?>
<span class="<?php if ($validateur->estHistorise()) echo "historise"; ?>"><?php echo $validateur->getValidateur()->getDenomination(); ?></span>
<span
class="badge"> <?php echo $validateur->getSourceId(); ?> </span>
<?php if ($validateur->getSourceId() === 'MES FORMATIONS' and $canModifier) : ?>
<?php /** @see \Agent\Controller\ValidateurController::modifierAction() */ ?>
<a href="<?php echo $this->url('agent/validateur/modifier', ['agent-validateur' => $validateur->getId()], [], true); ?>"
class="ajax-modal action primary" data-event="modification">
......@@ -153,9 +156,24 @@ $canModifier = $this->isAllowed(AgentPrivileges::getResourceId(AgentPrivileges::
<span class="icon icon-unchecked"></span>
Supprimer
</a>
<?php else : ?>
<?php if ($validateur->estHistorise()) : ?>
<?php /** @see \Agent\Controller\ValidateurController::restaurerAction() */ ?>
<a href="<?php echo $this->url('agent/validateur/restaurer', ['agent-validateur' => $validateur->getId()], [], true); ?>"
class="action warning" >
<span class="icon icon-restaurer"></span>
Ré-établir
</a>
<?php else : ?>
<a href="<?php echo $this->url('agent/validateur/historiser', ['agent-validateur' => $validateur->getId()], [], true); ?>"
class="action warning">
<span class="icon icon-historiser"></span>
Révoquer
</a>
<?php endif; ?>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
......@@ -171,13 +189,15 @@ $canModifier = $this->isAllowed(AgentPrivileges::getResourceId(AgentPrivileges::
</a>
</li>
<li class="nav-item">
<a href="#inscriptions-internes" class="nav-link" aria-controls="inscriptions-internes" role="tab" data-toggle="tabz">
<a href="#inscriptions-internes" class="nav-link" aria-controls="inscriptions-internes" role="tab"
data-toggle="tabz">
Inscriptions en cours <br>
Plan de formation
</a>
</li>
<li class="nav-item">
<a href="#inscriptions-externes" class="nav-link" aria-controls="inscriptions-externes" role="tab" data-toggle="tabz">
<a href="#inscriptions-externes" class="nav-link" aria-controls="inscriptions-externes" role="tab"
data-toggle="tabz">
Inscriptions en cours <br>
Stage externe
</a>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment