v_fifo_agents.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Copyright (C) 2010
  17. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. require_once "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (if_group("admin") || if_group("superadmin")) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. require_once "resources/header.php";
  32. require_once "resources/paging.php";
  33. //$time_start = microtime(true);
  34. //sleep for a while
  35. //usleep(1000000);
  36. $order_by = $_GET["order_by"];
  37. $order = $_GET["order"];
  38. echo "<div align='center'>";
  39. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  40. echo "<tr class='border'>\n";
  41. echo " <td align=\"center\">\n";
  42. echo " <br>";
  43. echo "<table width='100%' border='0'>\n";
  44. echo "<tr>\n";
  45. echo "<td width='50%' nowrap='nowrap' align='left'><b>Active Agents</b></td>\n";
  46. echo "<td width='50%' align='right'>&nbsp;</td>\n";
  47. echo "</tr>\n";
  48. echo "<tr>\n";
  49. echo "<td colspan='2' align='left'>\n";
  50. echo "Shows the agents that are currently logged into the queues.<br /><br />\n";
  51. echo "</td>\n";
  52. echo "</tr>\n";
  53. echo "</tr></table>\n";
  54. //set the default order by and order asc, desc
  55. if (strlen($order_by) == 0) {
  56. $order_by = 'fifo_name';
  57. $order = 'asc';
  58. }
  59. //run the sql queries
  60. $sql = "";
  61. $sql .= " select * from v_fifo_agents ";
  62. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  63. //$sql .= " limit $rows_per_page offset $offset ";
  64. $prep_statement = $db->prepare(check_sql($sql));
  65. $prep_statement->execute();
  66. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  67. $result_count = count($result);
  68. unset ($prep_statement, $sql);
  69. $c = 0;
  70. $row_style["0"] = "row_style0";
  71. $row_style["1"] = "row_style1";
  72. echo "<div align='center'>\n";
  73. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  74. echo "<tr>\n";
  75. echo th_order_by('fifo_name', 'Queue Name', $order_by, $order);
  76. echo th_order_by('agent_username', 'Username', $order_by, $order);
  77. echo th_order_by('agent_priority', 'Agent Priority', $order_by, $order);
  78. echo th_order_by('agent_status', 'Status', $order_by, $order);
  79. echo th_order_by('agent_last_call', 'Last Call', $order_by, $order);
  80. echo th_order_by('agent_last_uuid', 'Last UUID', $order_by, $order);
  81. echo th_order_by('agent_contact_number', 'Contact Number', $order_by, $order);
  82. echo "<td align='right' width='42'>\n";
  83. echo " <a href='v_fifo_agents_edit.php' alt='add'>$v_link_label_add</a>\n";
  84. //echo " <input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agents_edit.php'\" value='+'>\n";
  85. echo "</td>\n";
  86. echo "<tr>\n";
  87. if ($result_count == 0) { //no results
  88. }
  89. else { //received results
  90. foreach($result as $row) {
  91. //set the php variables
  92. $agent_last_call = $row[agent_last_call];
  93. $agent_status = $row[agent_status];
  94. //format the last call time
  95. if ($agent_last_call == 0) {
  96. $agent_last_call_desc = '';
  97. }
  98. else {
  99. $agent_last_call_desc = date("g:i:s a j M Y",$agent_last_call);
  100. }
  101. //get the agent status session array
  102. //unset($_SESSION["array_agent_status"]);
  103. if (!is_array($_SESSION["array_agent_status"])) {
  104. $sql = "SELECT var_name, var_value FROM v_vars ";
  105. $sql .= "where domain_uuid = '$domain_uuid' ";
  106. $sql .= "and var_cat = 'Queues Agent Status' ";
  107. $prep_statement = $db->prepare(check_sql($sql));
  108. $prep_statement->execute();
  109. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  110. foreach($result as $field) {
  111. $_SESSION["array_agent_status"][$field[var_value]] = $field[var_name];
  112. }
  113. }
  114. //get the agent description
  115. $agent_status_desc = $_SESSION["array_agent_status"][$agent_status];
  116. echo "<tr >\n";
  117. echo " <td valign='top' class='".$row_style[$c]."'>".$row[fifo_name]."</td>\n";
  118. echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_username]."</td>\n";
  119. echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_priority]."</td>\n";
  120. echo " <td valign='top' class='".$row_style[$c]."'>".$agent_status_desc."</td>\n";
  121. echo " <td valign='top' class='".$row_style[$c]."'>".$agent_last_call_desc."&nbsp;</td>\n";
  122. echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_last_uuid]."&nbsp;</td>\n";
  123. echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_contact_number]."</td>\n";
  124. echo " <td valign='top' align='right'>\n";
  125. echo " <a href='v_fifo_agents_edit.php?id=".$row[fifo_agent_id]."' alt='edit'>$v_link_label_edit</a>\n";
  126. echo " <a href='v_fifo_agents_delete.php?id=".$row[fifo_agent_id]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
  127. //echo " <input type='button' class='btn' name='' alt='edit' onclick=\"window.location='v_fifo_agents_edit.php?id=".$row[fifo_agent_id]."'\" value='e'>\n";
  128. //echo " <input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='v_fifo_agents_delete.php?id=".$row[fifo_agent_id]."' }\" value='x'>\n";
  129. echo " </td>\n";
  130. echo "</tr>\n";
  131. if ($c==0) { $c=1; } else { $c=0; }
  132. } //end foreach
  133. unset($sql, $result, $row_count);
  134. } //end if results
  135. echo "<tr>\n";
  136. echo "<td colspan='8' align='left'>\n";
  137. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  138. echo " <tr>\n";
  139. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  140. //echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  141. echo " <td width='33.3%' align='right'>\n";
  142. echo " <a href='v_fifo_agents_edit.php' alt='add'>$v_link_label_add</a>\n";
  143. //echo " <input type='button' class='btn' name='' alt='add' onclick=\"window.location='v_fifo_agents_edit.php'\" value='+'>\n";
  144. echo " </td>\n";
  145. echo " </tr>\n";
  146. echo " </table>\n";
  147. echo "</td>\n";
  148. echo "</tr>\n";
  149. echo "</table>";
  150. echo "</div>";
  151. echo "<br><br>";
  152. echo "<br><br>";
  153. //sleep(1);
  154. //$time_end = microtime(true);
  155. //$time = $time_end - $time_start;
  156. //if ($time < 2) {
  157. // echo "use cache ";
  158. //}
  159. //else {
  160. // echo "expired the cache ";
  161. //}
  162. //echo "load time $time seconds\n";
  163. echo "</td>";
  164. echo "</tr>";
  165. echo "</table>";
  166. echo "</div>";
  167. echo "<br><br>";
  168. require_once "resources/footer.php";
  169. unset ($result_count);
  170. unset ($result);
  171. unset ($key);
  172. unset ($val);
  173. unset ($c);
  174. ?>