sms_broadcast.php 8.0 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-2023
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes files
  22. require_once dirname(__DIR__, 2) . "/resources/require.php";
  23. require_once "resources/check_auth.php";
  24. require_once "resources/paging.php";
  25. //check permissions
  26. if (permission_exists('call_broadcast_view')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //add multi-lingual support
  34. $language = new text;
  35. $text = $language->get();
  36. //get the http get variables and set them to php variables
  37. $order_by = $_GET["order_by"];
  38. $order = $_GET["order"];
  39. //add the search term
  40. $search = strtolower($_GET["search"]);
  41. if (strlen($search) > 0) {
  42. $sql_search = " (";
  43. $sql_search .= " lower(sms_sms_broadcast_name) like :search ";
  44. $sql_search .= " or lower(sms_broadcast_description) like :search ";
  45. $sql_search .= ") ";
  46. $parameters['search'] = '%'.$search.'%';
  47. }
  48. //get the count
  49. $sql = "select count(*) from v_sms_broadcast ";
  50. $sql .= "where domain_uuid = :domain_uuid ";
  51. if (isset($sql_search)) {
  52. $sql .= "and ".$sql_search;
  53. }
  54. $database = new database;
  55. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  56. $num_rows = $database->select($sql, $parameters, 'column');
  57. //prepare the paging
  58. $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
  59. $param = "&search=".$search;
  60. $page = $_GET['page'];
  61. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  62. list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
  63. list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
  64. $offset = $rows_per_page * $page;
  65. //get the call broadcast
  66. $sql = str_replace('count(*)','*', $sql);
  67. $sql .= order_by($order_by, $order);
  68. $sql .= limit_offset($rows_per_page, $offset);
  69. $database = new database;
  70. $result = $database->select($sql, $parameters, 'all');
  71. unset($sql, $parameters);
  72. //create token
  73. $object = new token;
  74. $token = $object->create($_SERVER['PHP_SELF']);
  75. //include the header
  76. $document['title'] = $text['title-call_broadcast'];
  77. require_once "resources/header.php";
  78. //show the content
  79. echo "<div class='action_bar' id='action_bar'>\n";
  80. echo " <div class='heading'><b>".$text['title-call_broadcast']." (".$num_rows.")</b></div>\n";
  81. echo " <div class='actions'>\n";
  82. if (permission_exists('sms_broadcast_add')) {
  83. echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'sms_broadcast_edit.php']);
  84. }
  85. if (permission_exists('sms_broadcast_add') && $result) {
  86. echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','btn_copy');"]);
  87. }
  88. if (permission_exists('sms_broadcast_delete') && $result) {
  89. echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]);
  90. }
  91. echo "<form id='form_search' class='inline' method='get'>\n";
  92. echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
  93. echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
  94. echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'sms_broadcast.php','style'=>($search == '' ? 'display: none;' : null)]);
  95. if ($paging_controls_mini != '') {
  96. echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
  97. }
  98. echo " </form>\n";
  99. echo " </div>\n";
  100. echo " <div style='clear: both;'></div>\n";
  101. echo "</div>\n";
  102. if (permission_exists('sms_broadcast_add') && $result) {
  103. echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
  104. }
  105. if (permission_exists('sms_broadcast_delete') && $result) {
  106. 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');"])]);
  107. }
  108. echo $text['title_description-call_broadcast']."\n";
  109. echo "<br /><br />\n";
  110. echo "<form id='form_list' method='post'>\n";
  111. echo "<input type='hidden' id='action' name='action' value=''>\n";
  112. echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
  113. echo "<table class='list'>\n";
  114. echo "<tr class='list-header'>\n";
  115. if (permission_exists('sms_broadcast_add') || permission_exists('sms_broadcast_delete')) {
  116. echo " <th class='checkbox'>\n";
  117. echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($result ?: "style='visibility: hidden;'").">\n";
  118. echo " </th>\n";
  119. }
  120. echo th_order_by('sms_broadcast_name', $text['label-name'], $order_by, $order);
  121. echo th_order_by('sms_broadcast_description', $text['label-description'], $order_by, $order);
  122. if (permission_exists('sms_broadcast_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  123. echo " <td class='action-button'>&nbsp;</td>\n";
  124. }
  125. echo "</tr>\n";
  126. if (is_array($result) && @sizeof($result) != 0) {
  127. $x = 0;
  128. foreach($result as $row) {
  129. if (permission_exists('sms_broadcast_edit')) {
  130. $list_row_url = "sms_broadcast_edit.php?id=".urlencode($row['sms_broadcast_uuid']);
  131. }
  132. echo "<tr class='list-row' href='".$list_row_url."'>\n";
  133. if (permission_exists('sms_broadcast_add') || permission_exists('sms_broadcast_delete')) {
  134. echo " <td class='checkbox'>\n";
  135. echo " <input type='checkbox' name='sms_broadcast[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
  136. echo " <input type='hidden' name='sms_broadcast[$x][uuid]' value='".escape($row['sms_broadcast_uuid'])."' />\n";
  137. echo " </td>\n";
  138. }
  139. echo " <td>";
  140. if (permission_exists('sms_broadcast_edit')) {
  141. echo "<a href='".$list_row_url."'>".escape($row['sms_broadcast_name'])."</a>";
  142. }
  143. else {
  144. echo escape($row['sms_broadcast_name']);
  145. }
  146. echo " </td>\n";
  147. echo " <td class='description overflow hide-xs'>".escape($row['sms_broadcast_description'])."</td>\n";
  148. if (permission_exists('sms_broadcast_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  149. echo " <td class='action-button'>";
  150. echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
  151. echo " </td>\n";
  152. }
  153. echo "</tr>\n";
  154. $x++;
  155. }
  156. }
  157. unset($result);
  158. echo "</table>\n";
  159. echo "<br />\n";
  160. echo "<div align='center'>".$paging_controls."</div>\n";
  161. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  162. echo "</form>\n";
  163. //include the footer
  164. require_once "resources/footer.php";
  165. ?>