gestion visible et ajout colonne telephone (fixes #15 #16)

This commit is contained in:
afornerot 2019-10-21 14:09:24 +02:00
parent 198ebd14f5
commit 7ce296fd29
3 changed files with 108 additions and 73 deletions

View File

@ -317,6 +317,9 @@ class ConfigController extends Controller
$fields["role"]["perm"]=1;
$fields["role"]["label"]="Rôles";
$fields["telephonenumber"]["perm"]=1;
$fields["telephonenumber"]["label"]="Téléphone";
}
else {
$fields=json_decode($fields, true);

View File

@ -65,71 +65,92 @@ class UserController extends Controller
$draw= $request->query->get('draw');
$order= $request->query->get('order');
$viewniveau02=$this->getParameter('viewniveau02');
$fields=$this->getDefaultDatauser();
$fgusevisible=!($fields["visible"]["perm"]==0);
// Nombre total d'enregistrement
if($this->isGranted('ROLE_ADMIN')||$access=="user")
$total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult();
elseif($this->isGranted('ROLE_MODO')) {
$usermodo=$this->get('security.token_storage')->getToken()->getUser()->getId();
$total = $em->createQueryBuilder()
->select('COUNT(user)')
->from($this->labelentity,'user')
->from("CadolesCoreBundle:UserModo",'usermodo')
->where("usermodo.niveau01 = user.niveau01")
->andWhere("usermodo.user = :userid")
->setParameter("userid", $usermodo)
->getQuery()->getSingleScalarResult();
if($access=="config") {
if($this->isGranted('ROLE_ADMIN')) {
$total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult();
}
elseif($this->isGranted('ROLE_MODO')) {
$usermodo=$this->get('security.token_storage')->getToken()->getUser()->getId();
$total = $em->createQueryBuilder()
->select('COUNT(user)')
->from($this->labelentity,'user')
->from("CadolesCoreBundle:UserModo",'usermodo')
->where("usermodo.niveau01 = user.niveau01")
->andWhere("usermodo.user = :userid")
->setParameter("userid", $usermodo)
->getQuery()->getSingleScalarResult();
}
}
else {
if($fgusevisible) {
$total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->where('user.visible=true')->getQuery()->getSingleScalarResult();
}
else {
$total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult();
}
}
elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER')) {
$niveau01=$this->get('security.token_storage')->getToken()->getUser()->getNiveau01();
$total = $em->createQueryBuilder()
->select('COUNT(user)')
->from($this->labelentity,'user')
->where("user.niveau01 = :niveau01")
->setParameter("niveau01", $niveau01)
->getQuery()->getSingleScalarResult();
}
// Nombre d'enregistrement filtré
if($search["value"]=="")
$totalf = $total;
else {
if($this->isGranted('ROLE_ADMIN')||$access=="user")
$totalf= $em->createQueryBuilder()
->select('COUNT(user)')
->from('CadolesCoreBundle:User','user')
->from('CadolesCoreBundle:Niveau01', 'niveau01')
->where('user.niveau01=niveau01.id')
->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value')
->setParameter("value", "%".$search["value"]."%")
->getQuery()
->getSingleScalarResult();
elseif($this->isGranted('ROLE_MODO'))
$totalf= $em->createQueryBuilder()
->select('COUNT(user)')
->from('CadolesCoreBundle:User','user')
->from('CadolesCoreBundle:Niveau01', 'niveau01')
->from('CadolesCoreBundle:UserModo', 'usermodo')
->where('user.niveau01=niveau01.id')
->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value')
->andwhere("usermodo.niveau01 = user.niveau01")
->andWhere("usermodo.user = :userid")
->setParameter("userid", $usermodo)
->setParameter("value", "%".$search["value"]."%")
->getQuery()
->getSingleScalarResult();
elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER'))
$totalf= $em->createQueryBuilder()
->select('COUNT(user)')
->from('CadolesCoreBundle:User','user')
->from('CadolesCoreBundle:Niveau01', 'niveau01')
->where('user.niveau01=niveau01.id')
->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value')
->andWhere("user.niveau01 = :niveau01")
->setParameter("niveau01", $niveau01)
->setParameter("value", "%".$search["value"]."%")
->getQuery()
->getSingleScalarResult();
if($access=="config") {
if($this->isGranted('ROLE_ADMIN')) {
$totalf= $em->createQueryBuilder()
->select('COUNT(user)')
->from('CadolesCoreBundle:User','user')
->from('CadolesCoreBundle:Niveau01', 'niveau01')
->where('user.niveau01=niveau01.id')
->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value')
->setParameter("value", "%".$search["value"]."%")
->getQuery()
->getSingleScalarResult();
}
elseif($this->isGranted('ROLE_MODO')) {
$totalf= $em->createQueryBuilder()
->select('COUNT(user)')
->from('CadolesCoreBundle:User','user')
->from('CadolesCoreBundle:Niveau01', 'niveau01')
->from('CadolesCoreBundle:UserModo', 'usermodo')
->where('user.niveau01=niveau01.id')
->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value')
->andwhere("usermodo.niveau01 = user.niveau01")
->andWhere("usermodo.user = :userid")
->setParameter("userid", $usermodo)
->setParameter("value", "%".$search["value"]."%")
->getQuery()
->getSingleScalarResult();
}
}
else {
if($fgusevisible) {
$totalf= $em->createQueryBuilder()
->select('COUNT(user)')
->from('CadolesCoreBundle:User','user')
->from('CadolesCoreBundle:Niveau01', 'niveau01')
->where('user.niveau01=niveau01.id')
->andWhere('user.visible=true')
->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value')
->setParameter("value", "%".$search["value"]."%")
->getQuery()
->getSingleScalarResult();
}
else {
$totalf= $em->createQueryBuilder()
->select('COUNT(user)')
->from('CadolesCoreBundle:User','user')
->from('CadolesCoreBundle:Niveau01', 'niveau01')
->where('user.niveau01=niveau01.id')
->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value')
->setParameter("value", "%".$search["value"]."%")
->getQuery()
->getSingleScalarResult();
}
}
}
// Construction du tableau de retour
@ -142,23 +163,24 @@ class UserController extends Controller
// Parcours des Enregistrement
$qb = $em->createQueryBuilder();
if($this->isGranted('ROLE_ADMIN')||$access=="user") {
if($access=="config") {
if($this->isGranted('ROLE_ADMIN')) {
$qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01');
$qb->where('user.niveau01=niveau01.id');
}
elseif($this->isGranted('ROLE_MODO')) {
$qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01')->from('CadolesCoreBundle:UserModo', 'usermodo');
$qb->where('user.niveau01=niveau01.id')
->andwhere("usermodo.niveau01 = user.niveau01")
->andWhere("usermodo.user = :userid")
->setParameter("userid", $usermodo);
}
}
else {
$qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01');
$qb->where('user.niveau01=niveau01.id');
if($fgusevisible) $qb->andWhere('user.visible=true');
}
elseif($this->isGranted('ROLE_MODO')) {
$qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01')->from('CadolesCoreBundle:UserModo', 'usermodo');
$qb->where('user.niveau01=niveau01.id')
->andwhere("usermodo.niveau01 = user.niveau01")
->andWhere("usermodo.user = :userid")
->setParameter("userid", $usermodo);
}
elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER')) {
$qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01');
$qb->where('user.niveau01=niveau01.id')
->andwhere("user.niveau01 = :niveau01")
->setParameter("niveau01", $niveau01);
}
if($search["value"]!="") {
$qb ->andWhere('user.username LIKE :value OR user.firstname LIKE :value OR user.lastname LIKE :value OR user.email LIKE :value OR user.role LIKE :value OR niveau01.label LIKE :value')
@ -184,10 +206,14 @@ class UserController extends Controller
break;
case 6 :
$qb->orderBy('user.telephonenumber',$order[0]["dir"]);
break;
case 7 :
$qb->orderBy('niveau01.label',$order[0]["dir"]);
break;
case 9 :
case 10 :
$qb->orderBy('user.role',$order[0]["dir"]);
break;
}
@ -211,10 +237,14 @@ class UserController extends Controller
break;
case 5 :
$qb->orderBy('user.telephonenumber',$order[0]["dir"]);
break;
case 6 :
$qb->orderBy('niveau01.label',$order[0]["dir"]);
break;
case 7 :
case 8 :
$qb->orderBy('user.role',$order[0]["dir"]);
break;
}
@ -245,6 +275,7 @@ class UserController extends Controller
array_push($tmp,$data->getLastname());
array_push($tmp,$data->getFirstname());
array_push($tmp,"<a href='mailto:".$data->getEmail()."'>".$data->getEmail()."</a>");
array_push($tmp,$data->getTelephonenumber());
array_push($tmp,$data->getNiveau01()->getLabel());
if($viewniveau02) array_push($tmp,($data->getNiveau02()!==null?$data->getNiveau02()->getLabel():""));
array_push($tmp,$groups);

View File

@ -32,6 +32,7 @@
<th class="{% if fields["lastname"] is defined and fields["lastname"].perm==0 %}no-visible{% endif %}">Nom</th>
<th class="{% if fields["firstname"] is defined and fields["firstname"].perm==0 %}no-visible{% endif %}">Prénom</th>
<th class="{% if fields["email"] is defined and fields["email"].perm==0 %}no-visible{% endif %}">Email</th>
<th class="{% if fields["telephonenumber"] is defined and fields["telephonenumber"].perm==0 %}no-visible{% endif %}">Téléphone</th>
<th class="{% if fields["niveau01"] is defined and fields["niveau01"].perm==0 %}no-visible{% endif %}">{{ labelniveau01 }}</th>
{% if viewniveau02 %}
<th class="no-sort {% if fields["niveau02"] is defined and fields["niveau02"].perm==0 %}no-visible{% endif %}">{{ labelniveau02 }}</th>