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"]["perm"]=1;
$fields["role"]["label"]="Rôles"; $fields["role"]["label"]="Rôles";
$fields["telephonenumber"]["perm"]=1;
$fields["telephonenumber"]["label"]="Téléphone";
} }
else { else {
$fields=json_decode($fields, true); $fields=json_decode($fields, true);

View File

@ -65,10 +65,14 @@ class UserController extends Controller
$draw= $request->query->get('draw'); $draw= $request->query->get('draw');
$order= $request->query->get('order'); $order= $request->query->get('order');
$viewniveau02=$this->getParameter('viewniveau02'); $viewniveau02=$this->getParameter('viewniveau02');
$fields=$this->getDefaultDatauser();
$fgusevisible=!($fields["visible"]["perm"]==0);
// Nombre total d'enregistrement // Nombre total d'enregistrement
if($this->isGranted('ROLE_ADMIN')||$access=="user") if($access=="config") {
if($this->isGranted('ROLE_ADMIN')) {
$total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult(); $total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult();
}
elseif($this->isGranted('ROLE_MODO')) { elseif($this->isGranted('ROLE_MODO')) {
$usermodo=$this->get('security.token_storage')->getToken()->getUser()->getId(); $usermodo=$this->get('security.token_storage')->getToken()->getUser()->getId();
$total = $em->createQueryBuilder() $total = $em->createQueryBuilder()
@ -80,21 +84,22 @@ class UserController extends Controller
->setParameter("userid", $usermodo) ->setParameter("userid", $usermodo)
->getQuery()->getSingleScalarResult(); ->getQuery()->getSingleScalarResult();
} }
elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER')) { }
$niveau01=$this->get('security.token_storage')->getToken()->getUser()->getNiveau01(); else {
$total = $em->createQueryBuilder() if($fgusevisible) {
->select('COUNT(user)') $total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->where('user.visible=true')->getQuery()->getSingleScalarResult();
->from($this->labelentity,'user') }
->where("user.niveau01 = :niveau01") else {
->setParameter("niveau01", $niveau01) $total = $em->createQueryBuilder()->select('COUNT(user)')->from($this->labelentity,'user')->getQuery()->getSingleScalarResult();
->getQuery()->getSingleScalarResult(); }
} }
// Nombre d'enregistrement filtré // Nombre d'enregistrement filtré
if($search["value"]=="") if($search["value"]=="")
$totalf = $total; $totalf = $total;
else { else {
if($this->isGranted('ROLE_ADMIN')||$access=="user") if($access=="config") {
if($this->isGranted('ROLE_ADMIN')) {
$totalf= $em->createQueryBuilder() $totalf= $em->createQueryBuilder()
->select('COUNT(user)') ->select('COUNT(user)')
->from('CadolesCoreBundle:User','user') ->from('CadolesCoreBundle:User','user')
@ -104,7 +109,8 @@ class UserController extends Controller
->setParameter("value", "%".$search["value"]."%") ->setParameter("value", "%".$search["value"]."%")
->getQuery() ->getQuery()
->getSingleScalarResult(); ->getSingleScalarResult();
elseif($this->isGranted('ROLE_MODO')) }
elseif($this->isGranted('ROLE_MODO')) {
$totalf= $em->createQueryBuilder() $totalf= $em->createQueryBuilder()
->select('COUNT(user)') ->select('COUNT(user)')
->from('CadolesCoreBundle:User','user') ->from('CadolesCoreBundle:User','user')
@ -118,19 +124,34 @@ class UserController extends Controller
->setParameter("value", "%".$search["value"]."%") ->setParameter("value", "%".$search["value"]."%")
->getQuery() ->getQuery()
->getSingleScalarResult(); ->getSingleScalarResult();
elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER')) }
}
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() $totalf= $em->createQueryBuilder()
->select('COUNT(user)') ->select('COUNT(user)')
->from('CadolesCoreBundle:User','user') ->from('CadolesCoreBundle:User','user')
->from('CadolesCoreBundle:Niveau01', 'niveau01') ->from('CadolesCoreBundle:Niveau01', 'niveau01')
->where('user.niveau01=niveau01.id') ->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.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"]."%") ->setParameter("value", "%".$search["value"]."%")
->getQuery() ->getQuery()
->getSingleScalarResult(); ->getSingleScalarResult();
} }
}
}
// Construction du tableau de retour // Construction du tableau de retour
$output = array( $output = array(
@ -142,7 +163,8 @@ class UserController extends Controller
// Parcours des Enregistrement // Parcours des Enregistrement
$qb = $em->createQueryBuilder(); $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->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01');
$qb->where('user.niveau01=niveau01.id'); $qb->where('user.niveau01=niveau01.id');
} }
@ -153,11 +175,11 @@ class UserController extends Controller
->andWhere("usermodo.user = :userid") ->andWhere("usermodo.user = :userid")
->setParameter("userid", $usermodo); ->setParameter("userid", $usermodo);
} }
elseif($this->isGranted('ROLE_ANIM')||$this->isGranted('ROLE_USER')) { }
else {
$qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01'); $qb->select('user')->from($this->labelentity,'user')->from('CadolesCoreBundle:Niveau01','niveau01');
$qb->where('user.niveau01=niveau01.id') $qb->where('user.niveau01=niveau01.id');
->andwhere("user.niveau01 = :niveau01") if($fgusevisible) $qb->andWhere('user.visible=true');
->setParameter("niveau01", $niveau01);
} }
if($search["value"]!="") { if($search["value"]!="") {
@ -184,10 +206,14 @@ class UserController extends Controller
break; break;
case 6 : case 6 :
$qb->orderBy('user.telephonenumber',$order[0]["dir"]);
break;
case 7 :
$qb->orderBy('niveau01.label',$order[0]["dir"]); $qb->orderBy('niveau01.label',$order[0]["dir"]);
break; break;
case 9 : case 10 :
$qb->orderBy('user.role',$order[0]["dir"]); $qb->orderBy('user.role',$order[0]["dir"]);
break; break;
} }
@ -211,10 +237,14 @@ class UserController extends Controller
break; break;
case 5 : case 5 :
$qb->orderBy('user.telephonenumber',$order[0]["dir"]);
break;
case 6 :
$qb->orderBy('niveau01.label',$order[0]["dir"]); $qb->orderBy('niveau01.label',$order[0]["dir"]);
break; break;
case 7 : case 8 :
$qb->orderBy('user.role',$order[0]["dir"]); $qb->orderBy('user.role',$order[0]["dir"]);
break; break;
} }
@ -245,6 +275,7 @@ class UserController extends Controller
array_push($tmp,$data->getLastname()); array_push($tmp,$data->getLastname());
array_push($tmp,$data->getFirstname()); array_push($tmp,$data->getFirstname());
array_push($tmp,"<a href='mailto:".$data->getEmail()."'>".$data->getEmail()."</a>"); array_push($tmp,"<a href='mailto:".$data->getEmail()."'>".$data->getEmail()."</a>");
array_push($tmp,$data->getTelephonenumber());
array_push($tmp,$data->getNiveau01()->getLabel()); array_push($tmp,$data->getNiveau01()->getLabel());
if($viewniveau02) array_push($tmp,($data->getNiveau02()!==null?$data->getNiveau02()->getLabel():"")); if($viewniveau02) array_push($tmp,($data->getNiveau02()!==null?$data->getNiveau02()->getLabel():""));
array_push($tmp,$groups); 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["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["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["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> <th class="{% if fields["niveau01"] is defined and fields["niveau01"].perm==0 %}no-visible{% endif %}">{{ labelniveau01 }}</th>
{% if viewniveau02 %} {% if viewniveau02 %}
<th class="no-sort {% if fields["niveau02"] is defined and fields["niveau02"].perm==0 %}no-visible{% endif %}">{{ labelniveau02 }}</th> <th class="no-sort {% if fields["niveau02"] is defined and fields["niveau02"].perm==0 %}no-visible{% endif %}">{{ labelniveau02 }}</th>