Fork of FusionPBX but with LDAP kinda working
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
7.2 KiB

2 years ago
  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 <markjcrane@fusionpbx.com>
  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 <markjcrane@fusionpbx.com>
  20. */
  21. include "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (permission_exists('fax_active_view')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. if (!permission_exists('fax_active_all') && $show == 'all') {
  32. echo "access denied";
  33. exit;
  34. }
  35. //add multi-lingual support
  36. $language = new text;
  37. $text = $language->get();
  38. //get submitted values
  39. $fax_uuid = $_REQUEST["id"];
  40. $show = $_REQUEST["show"];
  41. //include theme config for button images
  42. include_once("themes/".$_SESSION['domain']['template']['name']."/config.php");
  43. //construct query
  44. $sql = "select ";
  45. $sql .= "t1.fax_task_uuid as uuid, ";
  46. $sql .= "t1.fax_uuid as fax_uuid, ";
  47. $sql .= "t3.domain_name, ";
  48. $sql .= "t3.domain_uuid, ";
  49. $sql .= "t1.task_next_time as next_time, ";
  50. $sql .= "t1.task_interrupted as interrupted, ";
  51. $sql .= "t1.task_status as status, ";
  52. $sql .= "t1.task_uri as uri, ";
  53. $sql .= "t1.task_dial_string as dial_string, ";
  54. $sql .= "t1.task_dtmf as dtmf, ";
  55. $sql .= "t1.task_fax_file as fax_file, ";
  56. $sql .= "t1.task_wav_file as wav_file, ";
  57. $sql .= "t1.task_reply_address as reply_address, ";
  58. $sql .= "t1.task_no_answer_counter as no_answer_counter, ";
  59. $sql .= "t1.task_no_answer_retry_counter as no_answer_retry_counter, ";
  60. $sql .= "t1.task_retry_counter as retry_counter, ";
  61. $sql .= "t2.fax_send_greeting as greeting, ";
  62. $sql .= "t2.fax_name as fax_server_name ";
  63. $sql .= "from v_fax_tasks t1 ";
  64. $sql .= "inner join v_fax t2 on t2.fax_uuid = t1.fax_uuid ";
  65. $sql .= "inner join v_domains t3 on t2.domain_uuid = t3.domain_uuid ";
  66. $sql .= "where true ";
  67. if ($show !== 'all'){
  68. $sql .= "and t3.domain_name = :domain_name ";
  69. $parameters['domain_name'] = $_SESSION['domain_name'];
  70. }
  71. else if (is_uuid($fax_uuid)) {
  72. if (!permission_exists('fax_active_all')) {
  73. $sql .= "and t3.domain_name = :domain_name ";
  74. $parameters['domain_name'] = $_SESSION['domain_name'];
  75. }
  76. $sql .= "and t1.fax_uuid = :fax_uuid ";
  77. $parameters['fax_uuid'] = $fax_uuid;
  78. }
  79. $sql .= "order by domain_name, fax_server_name, next_time ";
  80. $database = new database;
  81. $result = $database->select($sql, $parameters, 'all');
  82. $message = $database->message;
  83. unset($sql, $parameters);
  84. if (is_array($result) && @sizeof($result) != 0) {
  85. //define js function call var
  86. $onhover_pause_refresh = " onmouseover='refresh_stop();' onmouseout='refresh_start();'";
  87. //show buttons
  88. echo "<table cellpadding='0' cellspacing='0' border='0' align='right'>";
  89. echo " <tr>";
  90. echo " <td valign='middle' nowrap='nowrap' style='padding-right: 15px' id='refresh_state'>";
  91. echo " <img src='resources/images/refresh_active.gif' style='width: 16px; height: 16px; border: none; margin-top: 3px; cursor: pointer;' onclick='refresh_stop();' alt=\"".$text['label-refresh_pause']."\" title=\"".$text['label-refresh_pause']."\">";
  92. echo " </td>";
  93. echo " <td valign='top' nowrap='nowrap'>";
  94. if (permission_exists('fax_active_all')) {
  95. if ($show == "all") {
  96. echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"document.location='fax_active.php';\" value='".$text['button-back']."' ".$onhover_pause_refresh.">\n";
  97. }
  98. else {
  99. echo " <input type='button' class='btn' name='' alt='".$text['button-show_all']."' onclick=\"document.location='fax_active.php?show=all';\" value='".$text['button-show_all']."' ".$onhover_pause_refresh.">\n";
  100. }
  101. }
  102. echo " </td>";
  103. echo " </tr>";
  104. echo "</table>";
  105. // show title
  106. echo "<b>".$text['fax-active_title']."</b>";
  107. echo "<br><br>\n";
  108. echo $text['fax-active_description']."\n";
  109. echo "<br><br>\n";
  110. //set the alternating color for each row
  111. $c = 0;
  112. $row_style["0"] = "row_style0";
  113. $row_style["1"] = "row_style1";
  114. //show the results
  115. echo "<div id='cmd_reponse'></div>\n";
  116. //show headers
  117. echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  118. echo "<tr>\n";
  119. echo "<th>".$text['fax-active_title_fax_server']."</th>\n";
  120. echo "<th>".$text['fax-active_title_enabled']."</th>\n";
  121. echo "<th>".$text['fax-active_title_status']."</th>\n";
  122. echo "<th>".$text['fax-active_title_next_time']."</th>\n";
  123. echo "<th>".$text['fax-active_title_files']."</th>\n";
  124. echo "<th>".$text['fax-active_title_uri']."</th>\n";
  125. echo "<td class='list_control_icon'></td>\n";
  126. echo "</tr>\n";
  127. foreach ($result as &$row) {
  128. $fax_uri = $row['uri'];
  129. $domain_name = $row['domain_name'];
  130. $task_enabled = ($row['interrupted'] == 'true') ? 'Disable': 'Enable';
  131. $task_status = $text['fax-active_status_wait'];
  132. $task_next_time = $row['next_time'];
  133. if ($row['status'] > 0) {
  134. if ($row['status'] <= 3) {
  135. $task_status = $text['fax-active_status_execute'];
  136. }
  137. else if($row['status'] == 10){
  138. $task_status = $text['fax-active_status_success'];
  139. }
  140. else{
  141. $task_status = $text['fax-active_status_fail'];
  142. }
  143. }
  144. $fax_server = $row['fax_server_name'];
  145. if ($show == 'all') {
  146. $fax_server .= '@'.$domain_name;
  147. }
  148. $task_files = '';
  149. if (!empty($row['fax_file'])) {
  150. $task_files .= '&nbsp;'.basename($row['fax_file']);
  151. }
  152. if (!empty($row['wav_file'])) {
  153. $task_files .= '<br/>&nbsp;'.basename($row['wav_file']);
  154. }
  155. else if (!empty($row['greeting'])) {
  156. $task_files .= '<br/>&nbsp;'.basename($row['greeting']);
  157. }
  158. //replace gateway uuid with name
  159. if (sizeof($_SESSION['gateways']) > 0) {
  160. foreach ($_SESSION['gateways'] as $gateway_uuid => $gateway_name) {
  161. $fax_uri = str_replace($gateway_uuid, $gateway_name, $fax_uri);
  162. }
  163. }
  164. echo "<tr>\n";
  165. echo "<td valign='top' class='".$row_style[$c]."'>".$fax_server."&nbsp;</td>\n";
  166. echo "<td valign='top' class='".$row_style[$c]."'>".$task_enabled."&nbsp;</td>\n";
  167. echo "<td valign='top' class='".$row_style[$c]."'>".$task_status."&nbsp;</td>\n";
  168. echo "<td valign='top' class='".$row_style[$c]."'>".$task_next_time."&nbsp;</td>\n";
  169. echo "<td valign='top' class='".$row_style[$c]."'>".$task_files."&nbsp;</td>\n";
  170. echo "<td valign='top' class='".$row_style[$c]."'>".$fax_uri."&nbsp;</td>\n";
  171. echo "<td class='list_control_icons' style='width: 25px; text-align: left;'><a href='javascript:void(0);' alt='".$text['label-hangup']."' onclick=\"hangup(escape('".$row['uuid']."'));\">".$v_link_label_delete."</a></td>\n";
  172. echo "</tr>\n";
  173. $c = ($c) ? 0 : 1;
  174. }
  175. echo "</td>\n";
  176. echo "</tr>\n";
  177. echo "</table>\n";
  178. }
  179. ?>