PageRenderTime 23ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/activity.php

https://gitlab.com/kaimou_m/Extia
PHP | 172 lines | 169 code | 1 blank | 2 comment | 19 complexity | d48954349d653ca169da8e2e93f13ec3 MD5 | raw file
  1. <html>
  2. <?php require_once('headrecur.php'); ?>
  3. <body>
  4. <title>Extia - Activité du site</title>
  5. <?php session_start();
  6. if (!isset($_SESSION['login'])) {
  7. header("Location: ../index.php");
  8. }
  9. $req = $bdd->query('select * from utilisateur where login="'.$_SESSION['login'].'"');
  10. $req->setFetchMode(PDO::FETCH_OBJ);
  11. $result = $req->fetch();
  12. if ($result->role == 4)
  13. header("location: ../index.php");?>
  14. <?php require_once('headerrecur.php'); ?>
  15. <div class="container-fluid" style="font-family: 'gotham';">
  16. <div class="row">
  17. <div class="container-fluid" style="margin-top: 25px; text-align: center;">
  18. <div class="col-md-4 col-md-offset-4">
  19. <p class="lead" style="font-family: 'gotham';"><img width="40" height="40" src="../img/croissance.png"> Activité du site en temps réel</p>
  20. </div>
  21. </div>
  22. <div class="container acti" style="margin-top: 0; padding-top: 0;">
  23. <div class="col-md-12">
  24. <div class="row" style="margin: 0; padding: 0;">
  25. <p><h3 style="color: #ff6908;"><i class="fa fa-download"></i> Exporter des données</h3></p>
  26. <div class="col-md-12" style="box-shadow: 0 0 1px 1px grey">
  27. <p><h5 style="color: #222;">Les données seront exportées sous forme de fichier excel.</h5></p>
  28. <div class="col-md-6" style="margin-top: 25px; margin-bottom: 25px;">
  29. <p><h5 style="color: #ff6908;"><i class="fa fa-file-excel-o"></i> Données utilisateurs (Liste des Inscriptions)</h5></p>
  30. <br>
  31. <table class="table table-striped table-hover ">
  32. <tr class="warning">
  33. <td><a href="../apps/cible_exporte.php" style="margin: 5px; color:inherit;"><i class="fa fa-file"></i> Données utilisateurs..</a></td>
  34. </tr>
  35. </table>
  36. <p><h5 style="color: #ff6908;"><i class="fa fa-file-excel-o"></i> Données événements (Liste des notes et commentaires)</h5></p>
  37. <br>
  38. <table class="table table-striped table-hover ">
  39. <tr class="defaut">
  40. <th>Titre</th>
  41. <th>Lien</th>
  42. </tr>
  43. <?php
  44. $req = $bdd->query('select * from evenement');
  45. $date = date('Y-m-d');
  46. $hour = date('H:i');
  47. while ($result = $req->fetch()) {
  48. if ($result['date_evenement'] < $date || ($result['date_evenement'] == $date && $result['date_evenement'] < $hour)) {
  49. echo '<tr class="warning">
  50. <td>'. $result['titre'] .'</td>
  51. <td><form style="margin: 0; padding: 0;" method="post" action="../apps/cible_exporte2.php">
  52. <input type="hidden" name="idevent" value="'. $result['id'] .'">
  53. <button type="submit" style="margin: 0; padding: 0; background-color: inherit; border: none;">
  54. <i class="fa fa-download"></i>
  55. </button>
  56. </form></td>
  57. </tr>';
  58. }
  59. }
  60. ?>
  61. </table>
  62. </div>
  63. <div class="col-md-6" style="margin-top: 25px; margin-bottom: 25px;">
  64. <p><h5 style="color: #ff6908;"><i class="fa fa-medium"></i> Moyenne des événement terminés</h5></p>
  65. <br>
  66. <table class="table table-striped table-hover">
  67. <tr>
  68. <td>Titre</td>
  69. <td>Note sur 5</td>
  70. </tr>
  71. <?php
  72. $req = $bdd->prepare('select * from evenement');
  73. $date = date('Y-m-d');
  74. $hour = date('H:i');
  75. $namelist = array();
  76. $idlist = array();
  77. $notelist = array();
  78. //echo '<tr class="warning"><td><i class="fa fa-database"></i> ' . $note['note'] . '</td><td>/5 </td></tr>';
  79. //$note = $bdd->prepare('select * from commentaire where id_evenement ="' . $result['id'] .'"');
  80. $req->execute();
  81. while ($result = $req->fetch()) {
  82. if ($result['date_evenement'] < $date || ($result['date_evenement'] == $date && $result['date_evenement'] < $hour)) {
  83. $namelist[] = $result['titre'];
  84. $idlist[] = $result['id'];
  85. }
  86. }
  87. $req->closeCursor();
  88. $i = 0;
  89. while (isset($idlist[$i])) {
  90. $sql = $bdd->query('select AVG(note) from commentaire where id_evenement ="' . $idlist[$i] .'"');
  91. $note = $sql->fetch();
  92. $notelist[] = $note['AVG(note)'];
  93. ++$i;
  94. }
  95. $i = 0;
  96. while (isset($idlist[$i])) {
  97. if ($notelist[$i] == 0.00)
  98. $note = "Pas de Note";
  99. else
  100. $note = number_format($notelist[$i], 2);
  101. echo '<tr class="warning"><td><i class="fa fa-database"></i> ' . utf8_encode($namelist[$i]) . '</td><td>'. $note .'</td></tr>';
  102. ++$i;
  103. }
  104. ?>
  105. </table>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. <div class="col-md-12">
  111. <p><h3 style="color: #ff6908;"><i class="fa fa-pie-chart"></i> Dernières activités</h3></p>
  112. <div class="col-md-12" style="box-shadow: 0 0 1px 1px grey; padding-bottom: 30px;">
  113. <p><h5 style="color: #222;">Dernières notes, commentaires et inscriptions (<small>les 25 derniers</small>).</h5></p>
  114. <div class="col-md-6">
  115. <table class="table table-striped table-hover ">
  116. <thead>
  117. <tr>
  118. <th>Agence</th>
  119. <th>Date</th>
  120. <th>Nom</th>
  121. </tr>
  122. </thead>
  123. <tbody>
  124. <?php
  125. $req = $bdd->query('SELECT * from utilisateur ORDER BY date_creation DESC LIMIT 25');
  126. while ($result = $req->fetch()) {
  127. $datee = new DateTime($result['date_creation']);
  128. echo '<tr class="defaut">
  129. <td>'. $result['agence'] .'</td>
  130. <td>'. $datee->format('d/m/Y') .'</td>
  131. <td>'. $result['nom'] . '</td>
  132. </tr>';
  133. }
  134. ?>
  135. </tbody>
  136. </table>
  137. </div>
  138. <div class="col-md-6">
  139. <table class="table table-striped table-hover ">
  140. <thead>
  141. <tr>
  142. <th>Date</th>
  143. <th>Evenement</th>
  144. <th>Note sur 5</th>
  145. </tr>
  146. </thead>
  147. <tbody>
  148. <?php
  149. $req = $bdd->query('SELECT * from commentaire ORDER BY date_creation DESC LIMIT 25');
  150. while ($result = $req->fetch()) {
  151. $sql = $bdd->query('SELECT titre from evenement WHERE id="'. $result['id_evenement'] .'"');
  152. $res = $sql->fetch();
  153. $datee = new DateTime($result['date_creation']);
  154. echo '<tr class="defaut">
  155. <td>'. $datee->format('d/m/Y') . '</td>
  156. <td>'. $res['titre'] .'</td>
  157. <td>'. $result['note'] .'</td>
  158. </tr>';
  159. }
  160. ?>
  161. </tbody>
  162. </table>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <?php require_once('footerrecur.php'); ?>
  170. </body>
  171. </html>