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.

235 lines
11 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-2020
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <markjcrane@fusionpbx.com>
  20. */
  21. //includes
  22. require_once "root.php";
  23. require_once "resources/require.php";
  24. require_once "resources/check_auth.php";
  25. require_once "resources/paging.php";
  26. //check permissions
  27. if (permission_exists('fax_log_view')) {
  28. //access granted
  29. }
  30. else {
  31. echo "access denied";
  32. exit;
  33. }
  34. //add multi-lingual support
  35. $language = new text;
  36. $text = $language->get();
  37. //get the fax_uuid
  38. $fax_uuid = $_REQUEST["id"];
  39. //get variables used to control the order
  40. $order_by = $_GET["order_by"];
  41. $order = $_GET["order"];
  42. //get the http post data
  43. if (is_array($_POST['fax_logs'])) {
  44. $action = $_POST['action'];
  45. $fax_logs = $_POST['fax_logs'];
  46. }
  47. //process the http post data by action
  48. if ($action != '' && is_array($fax_logs) && @sizeof($fax_logs) != 0) {
  49. switch ($action) {
  50. case 'delete':
  51. if (permission_exists('fax_log_delete')) {
  52. $obj = new fax;
  53. $obj->fax_uuid = $fax_uuid;
  54. $obj->delete_logs($fax_logs);
  55. }
  56. break;
  57. }
  58. header('Location: fax_logs.php?id='.urlencode($fax_uuid));
  59. exit;
  60. }
  61. //add the search string
  62. $search = strtolower($_GET["search"]);
  63. if (strlen($search) > 0) {
  64. $sql_search = " and (";
  65. $sql_search .= " lower(fax_result_text) like :search ";
  66. $sql_search .= " or lower(fax_file) like :search ";
  67. $sql_search .= " or lower(fax_local_station_id) like :search ";
  68. $sql_search .= " or fax_date::text like :search ";
  69. $sql_search .= ") ";
  70. $parameters['search'] = '%'.$search.'%';
  71. }
  72. //prepare to page the results
  73. $sql = "select count(fax_log_uuid) from v_fax_logs ";
  74. $sql .= "where domain_uuid = :domain_uuid ";
  75. $sql .= "and fax_uuid = :fax_uuid ";
  76. $sql .= $sql_search;
  77. $parameters['domain_uuid'] = $domain_uuid;
  78. $parameters['fax_uuid'] = $fax_uuid;
  79. $database = new database;
  80. $num_rows = $database->select($sql, $parameters, 'column');
  81. //prepare to page the results
  82. $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
  83. $param = "&id=".$fax_uuid."&order_by=".$order_by."&order=".$order."&search=".$search;
  84. if (isset($_GET['page'])) {
  85. $page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
  86. list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
  87. list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
  88. $offset = $rows_per_page * $page;
  89. }
  90. //get the list
  91. $sql = str_replace('count(fax_log_uuid)', '*', $sql);
  92. $sql .= order_by($order_by, $order, 'fax_epoch', 'desc');
  93. $sql .= limit_offset($rows_per_page, $offset);
  94. $database = new database;
  95. $fax_logs = $database->select($sql, $parameters, 'all');
  96. unset($sql, $parameters);
  97. //create token
  98. $object = new token;
  99. $token = $object->create($_SERVER['PHP_SELF']);
  100. //include the header
  101. $document['title'] = $text['title-fax_logs'];
  102. require_once "resources/header.php";
  103. //show the content
  104. echo "<div class='action_bar' id='action_bar'>\n";
  105. echo " <div class='heading'><b>".$text['title-fax_logs']." (".$num_rows.")</b></div>\n";
  106. echo " <div class='actions'>\n";
  107. echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'fax.php']);
  108. if (permission_exists('fax_log_delete') && $fax_logs) {
  109. echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>'margin-left: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
  110. }
  111. echo button::create(['type'=>'button','label'=>$text['button-refresh'],'icon'=>$_SESSION['theme']['button_icon_refresh'],'style'=>'margin-left: 15px;','onclick'=>'document.location.reload(true);']);
  112. echo "<form id='form_search' class='inline' method='get'>\n";
  113. echo "<input type='hidden' name='id' value='".escape($fax_uuid)."'>";
  114. echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
  115. echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
  116. echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'fax_logs.php?id='.$fax_uuid,'style'=>($search == '' ? 'display: none;' : null)]);
  117. if ($paging_controls_mini != '') {
  118. echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
  119. }
  120. echo " </form>\n";
  121. echo " </div>\n";
  122. echo " <div style='clear: both;'></div>\n";
  123. echo "</div>\n";
  124. if (permission_exists('fax_log_delete') && $fax_logs) {
  125. echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
  126. }
  127. echo $text['description-fax_log']."\n";
  128. echo "<br /><br />\n";
  129. echo "<form id='form_list' method='post'>\n";
  130. echo "<input type='hidden' id='action' name='action' value=''>\n";
  131. echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
  132. echo "<table class='list'>\n";
  133. echo "<tr class='list-header'>\n";
  134. if (permission_exists('fax_log_delete')) {
  135. echo " <th class='checkbox'>\n";
  136. echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($fax_logs ?: "style='visibility: hidden;'").">\n";
  137. echo " </th>\n";
  138. }
  139. echo th_order_by('fax_epoch', $text['label-fax_date'], $order_by, $order, null, null, "&id=".$fax_uuid);
  140. echo th_order_by('fax_success', $text['label-fax_success'], $order_by, $order, null, null, "&id=".$fax_uuid);
  141. echo th_order_by('fax_result_code', $text['label-fax_result_code'], $order_by, $order, null, null, "&id=".$fax_uuid);
  142. echo th_order_by('fax_result_text', $text['label-fax_result_text'], $order_by, $order, null, null, "&id=".$fax_uuid);
  143. echo th_order_by('fax_file', $text['label-fax_file'], $order_by, $order, null, null, "&id=".$fax_uuid);
  144. echo th_order_by('fax_ecm_used', $text['label-fax_ecm_used'], $order_by, $order, null, null, "&id=".$fax_uuid);
  145. echo th_order_by('fax_local_station_id', $text['label-fax_local_station_id'], $order_by, $order, null, null, "&id=".$fax_uuid);
  146. //echo th_order_by('fax_document_transferred_pages', $text['label-fax_document_transferred_pages'], $order_by, $order);
  147. //echo th_order_by('fax_document_total_pages', $text['label-fax_document_total_pages'], $order_by, $order);
  148. //echo th_order_by('fax_image_resolution', $text['label-fax_image_resolution'], $order_by, $order);
  149. //echo th_order_by('fax_image_size', $text['label-fax_image_size'], $order_by, $order);
  150. echo th_order_by('fax_bad_rows', $text['label-fax_bad_rows'], $order_by, $order, null, null, "&id=".$fax_uuid);
  151. echo th_order_by('fax_transfer_rate', $text['label-fax_transfer_rate'], $order_by, $order, null, null, "&id=".$fax_uuid);
  152. echo th_order_by('fax_retry_attempts', $text['label-fax_retry_attempts'], $order_by, $order, null, null, "&id=".$fax_uuid);
  153. //echo th_order_by('fax_retry_limit', $text['label-fax_retry_limit'], $order_by, $order);
  154. //echo th_order_by('fax_retry_sleep', $text['label-fax_retry_sleep'], $order_by, $order);
  155. echo th_order_by('fax_uri', $text['label-fax_destination'], $order_by, $order, null, null, "&id=".$fax_uuid);
  156. //echo th_order_by('fax_epoch', $text['label-fax_epoch'], $order_by, $order);
  157. if ($_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  158. echo " <td class='action-button'>&nbsp;</td>\n";
  159. }
  160. echo "</tr>\n";
  161. if (is_array($fax_logs) && @sizeof($fax_logs) != 0) {
  162. $x = 0;
  163. foreach ($fax_logs as $row) {
  164. $list_row_url = "fax_log_view.php?id=".urlencode($row['fax_log_uuid'])."&fax_uuid=".$fax_uuid;
  165. echo "<tr class='list-row' href='".$list_row_url."'>\n";
  166. if (permission_exists('fax_log_delete')) {
  167. echo " <td class='checkbox'>\n";
  168. echo " <input type='checkbox' name='fax_logs[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
  169. echo " <input type='hidden' name='fax_logs[$x][uuid]' value='".escape($row['fax_log_uuid'])."' />\n";
  170. echo " </td>\n";
  171. }
  172. echo " <td><a href='".$list_row_url."'>".($_SESSION['domain']['time_format']['text'] == '12h' ? date("j M Y g:i:sa", $row['fax_epoch']) : date("j M Y H:i:s", $row['fax_epoch']))."</a>&nbsp;</td>\n";
  173. echo " <td>".$row['fax_success']."&nbsp;</td>\n";
  174. echo " <td>".$row['fax_result_code']."&nbsp;</td>\n";
  175. echo " <td>".$row['fax_result_text']."&nbsp;</td>\n";
  176. echo " <td>".basename($row['fax_file'])."&nbsp;</td>\n";
  177. echo " <td>".$row['fax_ecm_used']."&nbsp;</td>\n";
  178. echo " <td>".$row['fax_local_station_id']."&nbsp;</td>\n";
  179. //echo " <td>".$row['fax_document_transferred_pages']."&nbsp;</td>\n";
  180. //echo " <td>".$row['fax_document_total_pages']."&nbsp;</td>\n";
  181. //echo " <td>".$row['fax_image_resolution']."&nbsp;</td>\n";
  182. //echo " <td>".$row['fax_image_size']."&nbsp;</td>\n";
  183. echo " <td>".$row['fax_bad_rows']."&nbsp;</td>\n";
  184. echo " <td>".$row['fax_transfer_rate']."&nbsp;</td>\n";
  185. echo " <td>".$row['fax_retry_attempts']."&nbsp;</td>\n";
  186. //echo " <td>".$row['fax_retry_limit']."&nbsp;</td>\n";
  187. //echo " <td>".$row['fax_retry_sleep']."&nbsp;</td>\n";
  188. echo " <td>".basename($row['fax_uri'])."&nbsp;</td>\n";
  189. //echo " <td>".$row['fax_epoch']."&nbsp;</td>\n";
  190. if ($_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  191. echo " <td class='action-button'>\n";
  192. echo button::create(['type'=>'button','title'=>$text['button-view'],'icon'=>$_SESSION['theme']['button_icon_view'],'link'=>$list_row_url]);
  193. echo " </td>\n";
  194. }
  195. echo "</tr>\n";
  196. $x++;
  197. }
  198. }
  199. unset($fax_logs);
  200. echo "</table>\n";
  201. echo "<br />\n";
  202. echo "<div align='center'>".$paging_controls."</div>\n";
  203. echo "<input type='hidden' name='id' value='".escape($fax_uuid)."'>\n";
  204. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  205. echo "</form>\n";
  206. //include the footer
  207. require_once "resources/footer.php";
  208. ?>