users.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. if (permission_exists('contact_view')) {
  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. //get the http values and set them as php variables
  34. $order_by = $_GET["order_by"];
  35. $order = $_GET["order"];
  36. //show the content
  37. echo "<div align='center'>";
  38. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  39. echo "<tr class='border'>\n";
  40. echo " <td align=\"center\">\n";
  41. echo " <br>";
  42. echo "<table width='100%' border='0'><tr>\n";
  43. echo "<td width='50%' nowrap='nowrap' align='left'><b>Contact List</b></td>\n";
  44. echo "<td width='50%' align='right'>&nbsp;</td>\n";
  45. echo "</tr></table>\n";
  46. $sql = "";
  47. $sql .= "select * from v_users ";
  48. $sql .= "where domain_uuid = '$domain_uuid' ";
  49. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  50. $prep_statement = $db->prepare(check_sql($sql));
  51. $prep_statement->execute();
  52. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  53. $num_rows = count($result);
  54. unset ($prep_statement, $result, $sql);
  55. $rows_per_page = 150;
  56. $param = "";
  57. $page = $_GET['page'];
  58. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  59. list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
  60. $offset = $rows_per_page * $page;
  61. $sql = "";
  62. $sql .= "select * from v_users ";
  63. if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
  64. $sql .= "where domain_uuid = '$domain_uuid' ";
  65. $sql .= "limit $rows_per_page offset $offset ";
  66. $prep_statement = $db->prepare(check_sql($sql));
  67. $prep_statement->execute();
  68. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  69. $result_count = count($result);
  70. unset ($prep_statement, $sql);
  71. $c = 0;
  72. $row_style["0"] = "row_style0";
  73. $row_style["1"] = "row_style1";
  74. echo "<div align='center'>\n";
  75. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  76. echo "<tr>\n";
  77. echo th_order_by('username', 'Username', $order_by, $order);
  78. echo th_order_by('user_type', 'Type', $order_by, $order);
  79. echo th_order_by('user_category', 'Category', $order_by, $order);
  80. echo th_order_by('user_first_name', 'First Name', $order_by, $order);
  81. echo th_order_by('user_last_name', 'Last Name', $order_by, $order);
  82. echo th_order_by('user_company_name', 'Organization', $order_by, $order);
  83. echo th_order_by('user_phone_1', 'Phone', $order_by, $order);
  84. echo "<td align='right' width='42'>\n";
  85. if (permission_exists('contact_add')) {
  86. echo " <a href='user_edit.php' alt='add'>$v_link_label_add</a>\n";
  87. }
  88. echo "</td>\n";
  89. echo "<tr>\n";
  90. if ($result_count > 0) {
  91. foreach($result as $row) {
  92. echo "<tr >\n";
  93. if (strlen($row[username]) == 0) {
  94. echo " <td valign='top' class='".$row_style[$c]."'>contact&nbsp;</td>\n";
  95. }
  96. else {
  97. echo " <td valign='top' class='".$row_style[$c]."'>".$row['username']."&nbsp;</td>\n";
  98. }
  99. echo " <td valign='top' class='".$row_style[$c]."'>".$row['user_type']."&nbsp;</td>\n";
  100. echo " <td valign='top' class='".$row_style[$c]."'>".$row['user_category']."&nbsp;</td>\n";
  101. echo " <td valign='top' class='".$row_style[$c]."'>".$row['user_first_name']."&nbsp;</td>\n";
  102. echo " <td valign='top' class='".$row_style[$c]."'>".$row['user_last_name']."&nbsp;</td>\n";
  103. echo " <td valign='top' class='".$row_style[$c]."'>".$row['user_company_name']."&nbsp;</td>\n";
  104. echo " <td valign='top' class='".$row_style[$c]."'>".$row['user_phone_1']."&nbsp;</td>\n";
  105. echo " <td valign='top' align='right'>\n";
  106. if (permission_exists('contact_edit')) {
  107. echo " <a href='user_edit.php?id=".$row['user_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
  108. }
  109. if (permission_exists('contact_delete')) {
  110. echo " <a href='user_delete.php?id=".$row['user_uuid']."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
  111. }
  112. echo " </td>\n";
  113. echo "</tr>\n";
  114. if ($c==0) { $c=1; } else { $c=0; }
  115. } //end foreach
  116. unset($sql, $result);
  117. } //end if results
  118. echo "<tr>\n";
  119. echo "<td colspan='8' align='left'>\n";
  120. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  121. echo " <tr>\n";
  122. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  123. echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  124. echo " <td width='33.3%' align='right'>\n";
  125. if (permission_exists('contact_add')) {
  126. echo " <a href='user_edit.php' alt='add'>$v_link_label_add</a>\n";
  127. }
  128. echo " </td>\n";
  129. echo " </tr>\n";
  130. echo " </table>\n";
  131. echo "</td>\n";
  132. echo "</tr>\n";
  133. echo "</table>";
  134. echo "</div>";
  135. echo "<br><br>";
  136. echo "<br><br>";
  137. echo "</td>";
  138. echo "</tr>";
  139. echo "</table>";
  140. echo "</div>";
  141. echo "<br><br>";
  142. //show the footer
  143. require_once "resources/footer.php";
  144. ?>