hunt_groups.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. include "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. //check permissions
  25. if (permission_exists('hunt_group_view')) {
  26. //access granted
  27. }
  28. else {
  29. echo "access denied";
  30. exit;
  31. }
  32. //add multi-lingual support
  33. $language = new text;
  34. $text = $language->get();
  35. require_once "resources/header.php";
  36. $page["title"] = $text['title-hunt_groups'];
  37. require_once "resources/paging.php";
  38. $order_by = $_GET["order_by"];
  39. $order = $_GET["order"];
  40. echo "<div align='center'>";
  41. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  42. echo "<tr class='border'>\n";
  43. echo " <td align=\"center\">\n";
  44. echo " <br />";
  45. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  46. echo "<tr>\n";
  47. echo " <td align='left'><p><span class='vexpl'><span class='red'><strong>".$text['header-hunt_groups']."<br />\n";
  48. echo " </strong></span>".$text['description-hunt_groups']."</span></p></td>\n";
  49. echo "</tr>\n";
  50. echo "</table>\n";
  51. echo "<br />\n";
  52. //get the number of rows in v_hunt_groups
  53. $sql = "select count(*) as num_rows from v_hunt_groups ";
  54. $sql .= "where domain_uuid = '$domain_uuid' ";
  55. $prep_statement = $db->prepare(check_sql($sql));
  56. if ($prep_statement) {
  57. $prep_statement->execute();
  58. $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
  59. if ($row['num_rows'] > 0) {
  60. $num_rows = $row['num_rows'];
  61. }
  62. else {
  63. $num_rows = '0';
  64. }
  65. }
  66. unset($prep_statement, $result);
  67. //prepare to page the results
  68. $rows_per_page = 150;
  69. $param = "";
  70. $page = $_GET['page'];
  71. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  72. list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
  73. $offset = $rows_per_page * $page;
  74. //get the hunt group list
  75. $sql = "select * from v_hunt_groups ";
  76. $sql .= "where domain_uuid = '$domain_uuid' ";
  77. if (strlen($order_by)> 0) {
  78. $sql .= "order by $order_by $order ";
  79. }
  80. else {
  81. $sql .= "order by hunt_group_extension asc ";
  82. }
  83. $sql .= " limit $rows_per_page offset $offset ";
  84. $prep_statement = $db->prepare(check_sql($sql));
  85. $prep_statement->execute();
  86. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  87. $result_count = count($result);
  88. unset ($prep_statement, $sql);
  89. $c = 0;
  90. $row_style["0"] = "row_style0";
  91. $row_style["1"] = "row_style1";
  92. echo "<div align='center'>\n";
  93. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  94. echo "<tr>\n";
  95. echo th_order_by('hunt_group_extension', $text['label-extension'], $order_by, $order);
  96. echo th_order_by('hunt_group_name', $text['label-name'], $order_by, $order);
  97. echo th_order_by('hunt_group_name', $text['label-enabled'], $order_by, $order);
  98. echo th_order_by('hunt_group_description', $text['label-description'], $order_by, $order);
  99. echo "<td align='right' width='42'>\n";
  100. if (permission_exists('hunt_group_add')) {
  101. echo " <a href='hunt_group_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
  102. }
  103. echo "</td>\n";
  104. echo "<tr>\n";
  105. if ($result_count > 0) {
  106. foreach($result as $row) {
  107. echo "<tr >\n";
  108. echo " <td valign='top' class='".$row_style[$c]."'>".$row['hunt_group_extension']."</td>\n";
  109. echo " <td valign='top' class='".$row_style[$c]."'>".$row['hunt_group_name']."</td>\n";
  110. echo " <td valign='top' class='".$row_style[$c]."'>";
  111. if ($row['hunt_group_enabled'] == "true") {
  112. echo $text['option-true'];
  113. }
  114. else if ($row['hunt_group_enabled'] == "false") {
  115. echo $text['option-false'];
  116. }
  117. echo "</td>\n";
  118. echo " <td valign='top' class='row_stylebg' width='40%'>".$row['hunt_group_description']."&nbsp;</td>\n";
  119. echo " <td valign='top' align='right'>\n";
  120. if (permission_exists('hunt_group_edit')) {
  121. echo " <a href='hunt_group_edit.php?id=".$row['hunt_group_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
  122. }
  123. if (permission_exists('hunt_group_delete')) {
  124. echo " <a href='hunt_group_delete.php?id=".$row['hunt_group_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
  125. }
  126. echo " </td>\n";
  127. echo "</tr>\n";
  128. if ($c==0) { $c=1; } else { $c=0; }
  129. } //end foreach
  130. unset($sql, $result, $row_count);
  131. } //end if results
  132. echo "<tr>\n";
  133. echo "<td colspan='5'>\n";
  134. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  135. echo " <tr>\n";
  136. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  137. echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  138. echo " <td width='33.3%' align='right'>\n";
  139. if (permission_exists('hunt_group_add')) {
  140. echo " <a href='hunt_group_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
  141. }
  142. echo " </td>\n";
  143. echo " </tr>\n";
  144. echo " </table>\n";
  145. echo "</td>\n";
  146. echo "</tr>\n";
  147. if ($v_path_show) {
  148. echo "<tr>\n";
  149. echo "<td align='left' colspan='4'>\n";
  150. echo "<br />\n";
  151. echo $_SESSION['switch']['scripts']['dir']."\n";
  152. echo "</td>\n";
  153. echo "</tr>\n";
  154. }
  155. echo "</table>";
  156. echo "</div>";
  157. echo "<br><br>";
  158. echo "<br><br>";
  159. echo "</td>";
  160. echo "</tr>";
  161. echo "</table>";
  162. echo "</div>";
  163. echo "<br><br>";
  164. require_once "resources/footer.php";
  165. unset ($result_count);
  166. unset ($result);
  167. unset ($key);
  168. unset ($val);
  169. unset ($c);
  170. ?>