v_fifo_agent.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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("agent") || 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. $order_by = $_GET["order_by"];
  34. $order = $_GET["order"];
  35. echo "<div align='center'>";
  36. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  37. echo "<tr class='border'>\n";
  38. echo " <td align=\"center\">\n";
  39. echo " <br>";
  40. echo "<table width='100%' border='0'>\n";
  41. echo "<tr>\n";
  42. echo "<td width='50%' nowrap='nowrap' align='left'><b>Active Agents</b></td>\n";
  43. echo "<td width='50%' align='right'>&nbsp;</td>\n";
  44. echo "</tr>\n";
  45. echo "<tr>\n";
  46. echo "<td align='left'>\n";
  47. echo "Shows the agents that are currently logged into the queues.<br /><br />\n";
  48. echo "</td>\n";
  49. echo "<td>\n";
  50. echo " <a href='".PROJECT_PATH."/app/fifo_agents/v_fifo_agent_login.php'>login</a>";
  51. echo " <a href='".PROJECT_PATH."/app/fifo_agents/v_fifo_agent_logout.php'>logout</a>";
  52. echo "</td>\n";
  53. echo "</tr>\n";
  54. echo "</tr></table>\n";
  55. $sql = "";
  56. $sql .= " select * from v_fifo_agents ";
  57. $sql .= " where agent_username = '".$_SESSION["username"]."' ";
  58. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  59. $prep_statement = $db->prepare(check_sql($sql));
  60. $prep_statement->execute();
  61. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  62. $num_rows = count($result);
  63. unset ($prep_statement, $result, $sql);
  64. $rows_per_page = 10;
  65. $param = "";
  66. $page = $_GET['page'];
  67. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  68. list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
  69. $offset = $rows_per_page * $page;
  70. $sql = "";
  71. $sql .= " select * from v_fifo_agents ";
  72. $sql .= " where agent_username = '".$_SESSION["username"]."' ";
  73. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  74. //$sql .= " limit $rows_per_page offset $offset ";
  75. $prep_statement = $db->prepare(check_sql($sql));
  76. $prep_statement->execute();
  77. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  78. $result_count = count($result);
  79. unset ($prep_statement, $sql);
  80. $c = 0;
  81. $row_style["0"] = "row_style0";
  82. $row_style["1"] = "row_style1";
  83. echo "<div align='center'>\n";
  84. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  85. echo "<tr>\n";
  86. echo th_order_by('fifo_name', 'Queue Name', $order_by, $order);
  87. echo th_order_by('agent_username', 'Username', $order_by, $order);
  88. echo th_order_by('agent_priority', 'Agent Priority', $order_by, $order);
  89. echo th_order_by('agent_status', 'Status', $order_by, $order);
  90. echo th_order_by('agent_last_call', 'Last Call', $order_by, $order);
  91. echo th_order_by('agent_contact_number', 'Contact Number', $order_by, $order);
  92. echo "<td align='right' width='42'>\n";
  93. //echo " <a href='v_fifo_agents_edit.php' alt='add'>$v_link_label_add</a>\n";
  94. echo "</td>\n";
  95. echo "<tr>\n";
  96. if ($result_count == 0) { //no results
  97. }
  98. else { //received results
  99. foreach($result as $row) {
  100. //set the php variables
  101. $agent_last_call = $row[agent_last_call];
  102. date_default_timezone_set('America/Boise');
  103. //format the last call time
  104. $agent_last_call_desc = date("g:i:s a j M Y",$agent_last_call);
  105. //get the agent status description
  106. $x=1;
  107. $agent_status_desc = '';
  108. foreach($_SESSION["array_agent_status"] as $value) {
  109. if ($row[agent_status] == $x) {
  110. $agent_status_desc = $value;
  111. }
  112. $x++;
  113. }
  114. echo "<tr >\n";
  115. echo " <td valign='top' class='".$row_style[$c]."'>".$row[fifo_name]."</td>\n";
  116. echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_username]."</td>\n";
  117. echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_priority]."</td>\n";
  118. echo " <td valign='top' class='".$row_style[$c]."'>".$agent_status_desc."</td>\n";
  119. echo " <td valign='top' class='".$row_style[$c]."'>".$agent_last_call_desc."</td>\n";
  120. echo " <td valign='top' class='".$row_style[$c]."'>".$row[agent_contact_number]."</td>\n";
  121. echo " <td valign='top' align='right'>\n";
  122. echo " <a href='v_fifo_agent_edit.php?id=".$row[fifo_agent_id]."' alt='edit'>$v_link_label_edit</a>\n";
  123. //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";
  124. echo " </td>\n";
  125. echo "</tr>\n";
  126. if ($c==0) { $c=1; } else { $c=0; }
  127. } //end foreach
  128. unset($sql, $result, $row_count);
  129. } //end if results
  130. echo "<tr>\n";
  131. echo "<td colspan='7' align='left'>\n";
  132. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  133. echo " <tr>\n";
  134. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  135. echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  136. echo " <td width='33.3%' align='right'>\n";
  137. //echo " <a href='v_fifo_agents_edit.php' alt='add'>$v_link_label_add</a>\n";
  138. echo " </td>\n";
  139. echo " </tr>\n";
  140. echo " </table>\n";
  141. echo "</td>\n";
  142. echo "</tr>\n";
  143. echo "</table>";
  144. echo "</div>";
  145. echo "<br><br>";
  146. echo "<br><br>";
  147. echo "</td>";
  148. echo "</tr>";
  149. echo "</table>";
  150. echo "</div>";
  151. echo "<br><br>";
  152. require_once "resources/footer.php";
  153. unset ($result_count);
  154. unset ($result);
  155. unset ($key);
  156. unset ($val);
  157. unset ($c);
  158. ?>