Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $matrix = [];
- $req = $bdd->query("SELECT nom, id_theme_question_q, priorite
- FROM theme_q
- INNER JOIN theme_r ON theme_r.id_site = theme_q.id_site and id_theme_q_r = id_theme_question_q
- where theme_q.id_site in ($site_selection)
- and i2c IS NOT NULL
- group by nom, id_theme_question_q, priorite
- order by priorite");
- while ($donnees = $req->fetch())
- {
- $nom = $donnees['nom'];
- $id_theme_question_q = $donnees['id_theme_question_q'];
- $tot = 0;
- $moyenneTotal ='';
- $matrix2 = [];
- /*$reqSite = $bdd->query("SELECT *, AVG(i2c) AS i2c
- FROM chapitre_q
- INNER JOIN chapitre_r ON chapitre_r.id_site = chapitre_q.id_site and id_chapitre_q_r = id_chapitre_question_q
- where chapitre_q.id_site in ($site_selection)
- and chapitre_q.id_theme = $id_theme_question_q
- and vague = $vague_max
- and i2c IS NOT NULL
- group by chapitre_q.id_chapitre_question_q");*/
- $reqSite = $bdd->query("SELECT chapitre_q.id_chapitre_q, chapitre_q.id_site, chapitre_q.id_formulaires, chapitre_q.nom, chapitre_q.id_theme, chapitre_q.id_chapitre_question_q, chapitre_q.priorite, chapitre_q.coef_chapitre, AVG(i2c) AS i2c
- FROM chapitre_q
- INNER JOIN chapitre_r ON chapitre_r.id_site = chapitre_q.id_site and id_chapitre_q_r = id_chapitre_question_q
- where chapitre_q.id_site in ($site_selection)
- and chapitre_q.id_theme = $id_theme_question_q
- and vague = $vague_max
- and i2c IS NOT NULL
- group by chapitre_q.id_chapitre_q, chapitre_q.id_site, chapitre_q.id_formulaires, chapitre_q.nom, chapitre_q.id_theme, chapitre_q.id_chapitre_question_q, chapitre_q.priorite, chapitre_q.coef_chapitre");
- while ($donnees = $reqSite->fetch())
- {
- $resultat = [];
- $tot += 1;
- $nom_site = $donnees['nom'];
- $id_site = $donnees['id_site'];
- $i2c = $donnees['i2c'];
- $i2c = round($i2c);
- if ($i2c >= $passage_2_client) {
- $progress_bar= 'trait-vert.png';
- $width = $i2c.'%';
- } else if ($i2c < $passage_1_client && $i2c!=0) {
- $progress_bar= 'trait-rouge.png';
- $width = $i2c.'%';
- } else if ($i2c == 0){
- $progress_bar= 'trait-rouge.png';
- $width = '1%';
- } else {
- $progress_bar= 'trait-orange.png';
- $width = $i2c.'%';
- }
- $id_chapitre_question_q = $donnees['id_chapitre_question_q'];
- $resultat = [
- 'name' => $nom_site,
- 'i2c' => $i2c,
- 'progress-bar' => $progress_bar,
- 'width' => $width
- ];
- // VAGUE - 1
- $num_vague_moinsun = $vague_max -1;
- $moyenneIntMoinsUn = '';
- if ($num_vague_moinsun > 0) {
- $reqProgression = $bdd->query("SELECT AVG(i2c) AS i2c
- FROM chapitre_r
- where id_chapitre_q_r = $id_chapitre_question_q
- and chapitre_r.id_site in ($site_selection)
- and vague = $num_vague_moinsun
- ");
- while ($donnees = $reqProgression->fetch())
- {
- $moyenneIntMoinsUn = $donnees['i2c'];
- if (isset($moyenneIntMoinsUn) and $moyenneIntMoinsUn > $i2c) {$resultat['evolution'] ="fleche-moin.png";}
- if (isset($moyenneIntMoinsUn) and $moyenneIntMoinsUn < $i2c) {$resultat['evolution'] ="fleche-plus.png";}
- if (isset($moyenneIntMoinsUn) and $moyenneIntMoinsUn == $i2c) {$resultat['evolution'] ="fleche-egal.png";}
- }
- }
- $matrix2[] = $resultat;
- }
- $tot = 0;
- $moyenneTotal ='';
- $matrix3 =[];
- $reqSite = $bdd->query("SELECT nom_site, i2c, theme_r.id_site
- FROM site
- INNER JOIN theme_r ON theme_r.id_site = site.id_site
- where theme_r.id_site in ($site_selection)
- and id_theme_q_r = $id_theme_question_q
- and vague = $vague_max
- and i2c IS NOT NULL
- order by nom_site");
- while ($donnees = $reqSite->fetch())
- {
- $tot += 1;
- $nom_site = $donnees['nom_site'];
- $id_site = $donnees['id_site'];
- $i2c = $donnees['i2c'];
- $moyenneTotal += $i2c;
- }
- $moyenneTotal/$tot;
- $moyenne_couleur = round($moyenneTotal/$tot);
- $matrix3['name'] = $nom;
- if($tot == 0){
- $matrix3['background-color'] = '#808080';
- $matrix3['i2c'] = 'NC';
- } else {
- if ($moyenne_couleur >= $passage_2_client) {
- $matrix3['background-color'] = '#599200';
- } else if ($moyenne_couleur < $passage_1_client) {
- $matrix3['background-color'] = '#d1291d';
- } else {
- $matrix3['background-color'] = '#ed6e00';
- }
- $matrix3['i2c'] = $moyenne_couleur."%";
- }
- $matrix[] = [
- 'box' => $matrix3,
- 'lignes' => $matrix2
- ];
- }
- foreach ($matrix as $line) {
- // echo json_encode($line);
- echo '<div class="table-row-cat">';
- echo "<div class='chapitre' style='background-color:".$line['box']['background-color']."'>";
- echo '<div class="nom">'.$line['box']['name'].'</div>';
- echo '<div class="i2c">'.$line['box']['i2c'].'</div>';
- echo '</div>';
- echo '<table class="sous-chapitre">';
- foreach ($line['lignes'] as $site) {
- echo '<tr class="ligne">';
- echo '<td class="nom">'.$site['name'].'</td>';
- echo '<td>';
- echo '<div class="bar">';
- echo '<div class="bar-progress">';
- echo '<img src="/img/rapport/'.$site['progress-bar'].'" height="12" width="'.$site['width'].'">';
- echo '</div>';
- echo '</div>';
- echo '</td>';
- echo "<td><div> </div></td>";
- echo '<td class="cent">'.$site['i2c'].'%</td>';
- echo "<td><div> </div></td>";
- echo '<td class="">';
- if (isset($site['evolution'])) {
- echo "<img src='/img/extranet/rapport/".$site['evolution']."'>";
- }
- echo '</td>';
- echo '</tr>';
- }
- echo '</table>';
- echo '</div>';
- echo '<br><br><br>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement