fix(morelevel): ajout de niveau03 et niveau04
All checks were successful
Cadoles/nineskeletor/pipeline/head This commit looks good

This commit is contained in:
2022-09-27 11:52:49 +02:00
parent 89cb0433c0
commit d1431bcce4
46 changed files with 7163 additions and 3839 deletions

View File

@ -200,7 +200,9 @@ class GroupController extends AbstractController
}
// Controler les permissions
$this->cansubmit($access, $em);
if (!$this->cansubmit($access, $request)) {
throw $this->createAccessDeniedException('Permission denied');
}
// Création du formulaire
$form = $this->createForm(Form::class, $data, [
@ -363,6 +365,8 @@ class GroupController extends AbstractController
$usermodo = null;
$niveau01 = null;
$niveau02 = null;
$niveau03 = null;
$niveau04 = null;
// Nombre total d'enregistrement
$qb = $em->getManager()->createQueryBuilder();
@ -389,6 +393,8 @@ class GroupController extends AbstractController
case 'user':
$niveau01 = $this->getUser()->getNiveau01();
$niveau02 = $this->getUser()->getNiveau02();
$niveau03 = $this->getUser()->getNiveau03();
$niveau04 = $this->getUser()->getNiveau04();
$qb->select('COUNT(user)')
->from('App:User', 'user')
@ -396,13 +402,21 @@ class GroupController extends AbstractController
->setParameter('groupid', $id);
switch ($request->getSession()->get('scopeannu')) {
case 'SAME_NIVEAU01':
case 1:
$qb->andWhere('user.niveau01 = :niveau01')->setParameter('niveau01', $niveau01);
break;
case 'SAME_NIVEAU02':
case 2:
$qb->andWhere('user.niveau02 = :niveau02')->setParameter('niveau02', $niveau02);
break;
case 3:
$qb->andWhere('user.niveau03 = :niveau03')->setParameter('niveau02', $niveau03);
break;
case 4:
$qb->andWhere('user.niveau04 = :niveau04')->setParameter('niveau04', $niveau04);
break;
}
break;
}
@ -452,13 +466,21 @@ class GroupController extends AbstractController
->setParameter('groupid', $id);
switch ($request->getSession()->get('scopeannu')) {
case 'SAME_NIVEAU01':
case 1:
$qb->andWhere('user.niveau01 = :niveau01')->setParameter('niveau01', $niveau01);
break;
case 'SAME_NIVEAU02':
case 2:
$qb->andWhere('user.niveau02 = :niveau02')->setParameter('niveau02', $niveau02);
break;
case 3:
$qb->andWhere('user.niveau03 = :niveau03')->setParameter('niveau02', $niveau03);
break;
case 4:
$qb->andWhere('user.niveau04 = :niveau04')->setParameter('niveau04', $niveau04);
break;
}
$totalf = $qb->getQuery()->getSingleScalarResult();
@ -494,13 +516,21 @@ class GroupController extends AbstractController
case 'user':
$qb->where($qb->expr()->not($qb->expr()->exists($sub->getDQL())));
switch ($request->getSession()->get('scopeannu')) {
case 'SAME_NIVEAU01':
case 1:
$qb->andWhere('user.niveau01 = :niveau01')->setParameter('niveau01', $niveau01);
break;
case 'SAME_NIVEAU02':
case 2:
$qb->andWhere('user.niveau02 = :niveau02')->setParameter('niveau02', $niveau02);
break;
case 3:
$qb->andWhere('user.niveau03 = :niveau03')->setParameter('niveau02', $niveau03);
break;
case 4:
$qb->andWhere('user.niveau04 = :niveau04')->setParameter('niveau04', $niveau04);
break;
}
break;
}
@ -805,12 +835,14 @@ class GroupController extends AbstractController
return $this->redirectToRoute(str_replace('_admin_', '_'.$access.'_', $this->route));
}
private function cansubmit($access, $em)
private function cansubmit($access, $request)
{
switch ($access) {
case 'admin': return true;
break;
case 'user': return true;
case 'modo': return false;
break;
case 'user': return $request->getSession()->get('submitgroup');
break;
}
throw $this->createAccessDeniedException('Permission denied');