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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| <?php
session_start();
include ("config.php");
include ("session.php");
include ("lib_sundis.php");
echo "<table id=stats_tab border=1 cellpadding=5 style='width:100%;margin-left:auto;margin-right:auto;border-collapse:collapse;'>";
echo "<thead>";
echo "<tr>";
echo "<th>Enseignes</th>";
//////////////////////////////////// affiche les utilisateur ayant un etat =1 et acces > 2 ////////////////////////////////////
$res_com = mysqli_query($bdd, 'SELECT * FROM utilisateurs WHERE etat = 1 AND acces > 2');
while ($don_com = mysqli_fetch_array($res_com))
echo "<th>".nom_commercial($don_com['id_utilisateur'])."</th>";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo "<th>TOTAL</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
$res_enseigne = mysqli_query($bdd, 'SELECT * FROM enseignes ORDER BY intitule'); // affiche les enseignes genre les noms et c'est eux qu'il faut filtrer
while ($don_enseigne = mysqli_fetch_array($res_enseigne)){
echo "<tr>";
echo "<td>".$don_enseigne['intitule']."</td>";
$res_com = mysqli_query($bdd, 'SELECT * FROM utilisateurs WHERE etat = 1 AND acces > 2');
$total = 0;
while ($don_com = mysqli_fetch_array($res_com)){
$res = mysqli_query($bdd, 'SELECT * FROM rapports, clients, enseignes WHERE rapports.id_client = clients.id_client AND clients.id_enseigne = enseignes.id_enseigne AND clients.id_enseigne = "'.$don_enseigne['id_enseigne'].'" AND rapports.id_utilisateur = "'.$don_com['id_utilisateur'].'" AND type != 4');
echo "<td style='text-align:center;'>".mysqli_num_rows($res)."</td>"; // affiche les rapports des clients sur les lignes
$total = $total + mysqli_num_rows($res); // ici il fait la somme pour recupérer le total
}
$somme=$total;
echo "<td style='text-align:center;'>$somme</td>"; // ici il affiche le total
//echo "<td style='text-align:center;'>$total</td>";
echo "</tr>";
echo "<tr style='background-color:lightgrey;'>";
//////////////////////////////////// Visite client avec RDV //////////////////////////////////////////////////////////////////
echo "<td>Visite client avec RDV</td>";
$res_com = mysqli_query($bdd, 'SELECT * FROM utilisateurs WHERE etat = 1 AND acces > 2');
$total = 0;
while ($don_com = mysqli_fetch_array($res_com)){
$res = mysqli_query($bdd, 'SELECT * FROM rapports, clients, enseignes WHERE rapports.id_client = clients.id_client AND clients.id_enseigne = enseignes.id_enseigne AND clients.id_enseigne = "'.$don_enseigne['id_enseigne'].'" AND rapports.id_utilisateur = "'.$don_com['id_utilisateur'].'" AND type = 6');
echo "<td style='text-align:center;'>".mysqli_num_rows($res)."</td>";
$total = $total + mysqli_num_rows($res);
}
echo "<td style='text-align:center;'>$total</td>";
echo "</tr>";
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo "<tr style='background-color:lightgrey;'>";
//////////////////////// Visite client sans RDV ////////////////////////////////////////////////////////////////////////
echo "<td>Visite client sans RDV</td>";
$res_com = mysqli_query($bdd, 'SELECT * FROM utilisateurs WHERE etat = 1 AND acces > 2');
$total = 0;
while ($don_com = mysqli_fetch_array($res_com)){
$res = mysqli_query($bdd, 'SELECT * FROM rapports, clients, enseignes WHERE rapports.id_client = clients.id_client AND clients.id_enseigne = enseignes.id_enseigne AND clients.id_enseigne = "'.$don_enseigne['id_enseigne'].'" AND rapports.id_utilisateur = "'.$don_com['id_utilisateur'].'" AND type = 7');
echo "<td style='text-align:center;'>".mysqli_num_rows($res)."</td>";
$total = $total + mysqli_num_rows($res);
}
echo "<td style='text-align:center;'>$total</td>";
echo "</tr>";
echo "<tr style='background-color:lightgrey;'>";
//////////////////////////////////////////////////////////////////////////////////////////
/////////////////// Visite sans contact //////////////////////////////////////////////////////
echo "<td>Visite sans contact</td>";
$res_com = mysqli_query($bdd, 'SELECT * FROM utilisateurs WHERE etat = 1 AND acces > 2');
$total = 0;
while ($don_com = mysqli_fetch_array($res_com)){
$res = mysqli_query($bdd, 'SELECT * FROM rapports, clients, enseignes WHERE rapports.id_client = clients.id_client AND clients.id_enseigne = enseignes.id_enseigne AND clients.id_enseigne = "'.$don_enseigne['id_enseigne'].'" AND rapports.id_utilisateur = "'.$don_com['id_utilisateur'].'" AND rapports.id_contact = 0');
echo "<td style='text-align:center;'>".mysqli_num_rows($res)."</td>";
$total = $total + mysqli_num_rows($res);
}
echo "<td style='text-align:center;'>$total</td>";
//////////////////////////////////////////////////////////////////////////////////////////
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?> |
Partager