Bonjour,
Je débute sur Symfony, je cherche à modifier la couleur d'un champ d'un tableau en fonction de sa valeur en base, exemple :
http://www.noelshack.com/2016-10-1457345416-capture.png
Dans l'image ci-dessus, il y a un champ avec comme valeur pour la colonne "enabled" à "0".
J'arrive à afficher toutes les valeurs que je désire en fonction de ma recherche, exemple :
http://www.noelshack.com/2016-10-1457345524-capture.png
Pour les personnes portant le prénom de "Nicolas", j'affiche les utilisateurs avec un "enabled" à 0 ou 1 :
La vue :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 public function findActiveUsersByOrganizationQuery($pos, $absent = null, $sourceId = false, $lead = false, $appointment = false, $keywords = null, $sort = array(), $enabled = false) { if (!is_array($pos)) { $pos = array($pos); } $sort = $this->checkSort($sort); $qb = $this->createQueryBuilder('u') ->where('u.organization IN(:pos)') ->leftJoin('u.organization', 'p') ->setParameter('pos', $pos); /* SELECT * FROM User u LEFT JOIN u.organization p WHERE u.organization IN(:pos) */ if ($sourceId === false) { } elseif (is_null($sourceId)) { $qb->leftJoin('u.assignedSources', 's') ->andWhere('s.id IS NULL'); } else { $qb->leftJoin('u.assignedSources', 's') ->andWhere('s.id = :source') ->setParameter('source', $sourceId); } if ($appointment) { $qb->andWhere('u.availableForAppointment = :appointment') ->setParameter('appointment', true); } if ($lead) { $qb->andWhere('u.availableForLead = :lead') ->setParameter('lead', true); } if (!is_null($absent)) { $qb->andWhere('u.absent = :absent') ->setParameter('absent', $absent); } if (!is_null($keywords)) { $qb = $this->addKeywordsSubquery($qb, $keywords); } if ($enabled) { $qb->andWhere('u.enabled = :enabled') ->setParameter('enabled', $enabled); } $qb->orderBy($sort['sortColumn'], $sort['sortOrder']); return $qb; } public function findActiveUsersByOrganization($pos, $absent = null, $sourceId = false, $lead = false, $appointment = false, $keywords = null, $sort = array(), $enabled = false) { return $this->findActiveUsersByOrganizationQuery($pos, $absent, $sourceId, $lead, $appointment, $keywords, $sort, $enabled)->getQuery()->getResult(); }
Je désire afficher les utilisateur ayant un champ "enabled" à "0" en rouge, pourriez-vous m'indiquer une piste à suivre s'il vous plaît ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 {% if route is not defined %} {% set route = null %} {% endif %} <table> <tr> {% include 'CarvivoCrmBundle:Common:_sortColumn.html.twig' with {'route' : route, 'column' : 'nom', 'label': 'Identité'|trans} %} {% include 'CarvivoCrmBundle:Common:_sortColumn.html.twig' with {'route' : route, 'column' : 'pos', 'label': 'Point de vente'|trans} %} <th>{{ 'Sources'|trans }}</th> <th class="center">{{ 'Leads en cours'|trans }}</th> <th>{{ 'Liens vers les stats'|trans }}</th> </tr> {% for user in users %} <tr class="{% if loop.index%2 == 0 %}even{% else %}odd{% endif %}"> <td>{{ user.name }} {{ user.enabled }}</td> <td>{{ user.organization.name }}</td> <td>{{ user.stringSources }}</td> <td class="center">{{ nbLeads(user) }}</td> <td class="actions nowrap"> {% include 'CarvivoCrmBundle:Common:_picto.html.twig' with {'class': 'icon-pie ajax-box', 'link': path('operator_statistics_pos', {'pos': user.organization.id }), 'text': 'Voir les stats'|trans } %} </td> </tr> {% else %} <tr><td class="no-data" colspan="{{ 8 + ('pos' in tds) }}">{{ 'Pas de résultat'|trans }}</td></tr> {% endfor %} </table>
Merci
Partager