Sabbertran

Untitled

Nov 15th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. <?php
  2. $numbers = array();
  3.  
  4. $con=mysqli_connect("localhost","udontgetmyname","justgetrandom","asdf");
  5.  
  6. //Check the connection
  7. if (mysqli_connect_errno()) {
  8. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  9. }
  10.  
  11. //Closing numbers
  12. $sql="SELECT * FROM greq_tickets WHERE status = '2' OR status = '3'";
  13.  
  14. $result = mysqli_query($con, $sql);
  15.  
  16. while($row = mysqli_fetch_assoc($result)) {
  17. $name = $row['status_extra'];
  18. if (array_key_exists($name, $numbers)) {
  19. $numbers[$name] = $numbers[$name] + 1;
  20. } else {
  21. $numbers[$name] = 1;
  22. }
  23. }
  24.  
  25. arsort($numbers);
  26.  
  27. echo "<div style='display:inline-block;vertical-align:text-top;margin-right:50px;'>";
  28. echo "<b><u>Ticket closing numbers:</u></b>";
  29. echo "<br>";
  30.  
  31. echo "<table>";
  32. foreach ($numbers as $key => $value) {
  33. echo "<tr>";
  34. echo "<td style='padding-right:20px;'>" . $key . "</td>";
  35. echo "<td>" . $value . "</td>";
  36. echo "</tr>";
  37. }
  38. echo "</table>";
  39. echo "</div>";
  40.  
  41. unset($numbers);
  42.  
  43. //Writing numbers
  44. $sql="SELECT * FROM greq_tickets";
  45.  
  46. $result = mysqli_query($con, $sql);
  47.  
  48. while($row = mysqli_fetch_assoc($result)) {
  49. $name = $row['author'];
  50. if (array_key_exists($name, $numbers)) {
  51. $numbers[$name] = $numbers[$name] + 1;
  52. } else {
  53. $numbers[$name] = 1;
  54. }
  55. }
  56.  
  57. arsort($numbers);
  58.  
  59. echo "<div style='display:inline-block;vertical-align:text-top;margin-right:50px;'>";
  60. echo "<b><u>Ticket writing numbers:</u></b>";
  61. echo "<br>";
  62.  
  63. echo "<table>";
  64. foreach ($numbers as $key => $value) {
  65. echo "<tr>";
  66. echo "<td style='padding-right:20px;'>" . $key . "</td>";
  67. echo "<td>" . $value . "</td>";
  68. echo "</tr>";
  69. }
  70. echo "</table>";
  71. echo "</div>";
  72.  
  73. unset($numbers);
  74.  
  75. //Close time
  76. date_default_timezone_set('Europe/Berlin');
  77. $sql="SELECT * FROM greq_tickets WHERE (status = '2' OR status = '3') AND close_date IS NOT NULL";
  78.  
  79. $result = mysqli_query($con, $sql);
  80.  
  81. echo "<div style='display:inline-block;vertical-align:text-top;margin-right:50px;'>";
  82. echo "<b><u>Close time:</u></b>";
  83. echo "<br>";
  84.  
  85. echo "<table>";
  86.  
  87. $total = 0;
  88. $amount = 0;
  89. while ($row = mysqli_fetch_assoc($result)) {
  90. $id = $row['id'];
  91. $staff = $row['status_extra'];
  92.  
  93. $start = DateTime::createFromFormat('d-m-Y-H-i-s', $row['date']);
  94. $startString = $start->format('d-m-Y H:i:s');
  95. $end = DateTime::createFromFormat('d-m-Y-H-i-s', $row['close_date']);
  96. $endString = $end->format('d-m-Y H:i:s');
  97.  
  98. $diff = date("H:i:s", (strtotime($endString) - strtotime($startString)));
  99. $amount = $amount + 1;
  100. $total = $total + (strtotime($endString) - strtotime($startString));
  101.  
  102. echo "<tr>";
  103. echo "<td style='padding-right:20px;'>#" . $id . " (" . $staff . ")" . "</td>";
  104. echo "<td>" . sprintf("%02d", (substr($diff, 0, 2) - 1)) . substr($diff, 2) . "</td>";
  105. echo "</tr>";
  106. }
  107. $average = date("H:i:s", ($total / $amount));
  108.  
  109. echo "<tr>";
  110. echo "<td style='padding-right:20px;'>" . "Average:" . "</td>";
  111. echo "<td>" . sprintf("%02d", (substr($average, 0, 2) - 1)) . substr($average, 2) . "</td>";
  112. echo "</tr>";
  113.  
  114. echo "</table>";
  115. echo "</div>";
  116. ?>
Advertisement
Add Comment
Please, Sign In to add comment