school_bells.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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-2025
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. Igor Olhovskiy <[email protected]>
  21. */
  22. //includes files
  23. require_once dirname(__DIR__, 2) . "/resources/require.php";
  24. require_once "resources/pdo.php";
  25. require_once "resources/check_auth.php";
  26. if (permission_exists('school_bell_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. require_once "resources/header.php";
  37. $document['title'] = $text['title-school_bells'];
  38. require_once "resources/paging.php";
  39. //get variables used to control the order
  40. $order_by = $_GET["order_by"];
  41. $order = $_GET["order"];
  42. //prepare to page the results
  43. $sql = "SELECT count(school_bell_uuid) AS num_rows FROM v_school_bells";
  44. $sql .= " WHERE domain_uuid = :domain_uuid";
  45. $prep_statement = $db->prepare($sql);
  46. $prep_statement->bindValue('domain_uuid', $domain_uuid);
  47. if ($prep_statement) {
  48. $prep_statement->execute();
  49. $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
  50. $num_rows = ($row['num_rows'] > 0) ? $row['num_rows'] : '0';
  51. }
  52. //prepare to page the results
  53. $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
  54. $param = "";
  55. $page = $_GET['page'];
  56. if (strlen($page) == 0) {
  57. $page = 0;
  58. $_GET['page'] = 0;
  59. }
  60. list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
  61. $offset = $rows_per_page * $page;
  62. //get the list
  63. if ($num_rows > 0) {
  64. $sql = "SELECT * FROM v_school_bells";
  65. $sql .= " WHERE domain_uuid = :domain_uuid";
  66. if (strlen($order_by)> 0) {
  67. $sql .= " ORDER BY $order_by $order";
  68. }
  69. $sql .= " LIMIT $rows_per_page OFFSET $offset";
  70. $prep_statement = $db->prepare(check_sql($sql));
  71. $prep_statement->bindValue('domain_uuid', $domain_uuid);
  72. $prep_statement->execute();
  73. $result = $prep_statement->fetchAll();
  74. $result_count = count($result);
  75. unset ($prep_statement, $sql);
  76. }
  77. //show the content
  78. echo "<table width='100%' cellpadding='0' cellspacing='0 border='0'>\n";
  79. echo " <tr>\n";
  80. echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['header-school_bells']." (".$num_rows.")</b></td>\n";
  81. echo " <td width='50%' align='right'>&nbsp;</td>\n";
  82. echo " </tr>\n";
  83. echo " <tr>\n";
  84. echo " <td align='left' colspan='2'>\n";
  85. echo " ".$text['description-school_bells']."<br /><br />\n";
  86. echo " </td>\n";
  87. echo " </tr>\n";
  88. echo "</table>\n";
  89. $c = 0;
  90. $row_style["0"] = "row_style0";
  91. $row_style["1"] = "row_style1";
  92. echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  93. echo "<tr>\n";
  94. echo th_order_by('school_bell_name', $text['label-school_bell_name'], $order_by, $order);
  95. echo th_order_by('school_bell_leg_a_data', $text['label-school_bell_leg_a_data'], $order_by, $order);
  96. echo th_order_by('school_bell_leg_b_data', $text['label-school_bell_leg_b_data'], $order_by, $order);
  97. echo "<th>".$text['label-school_bell_schedule_time']."</th>\n";
  98. echo th_order_by('school_bell_enabled', $text['label-school_bell_enabled'], $order_by, $order);
  99. echo th_order_by('school_bell_description', $text['label-school_bell_description'], $order_by, $order);
  100. echo "<td class='list_control_icons'>";
  101. if (permission_exists('school_bell_add')) {
  102. echo "<a href='school_bell_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
  103. }
  104. echo "</td>\n";
  105. echo "</tr>\n";
  106. if ($result_count > 0) {
  107. foreach($result as $row) {
  108. $row = array_map('escape', $row);
  109. $tr_link = (permission_exists('school_bell_edit')) ? "href='school_bell_edit.php?id=".$row['school_bell_uuid']."'" : null;
  110. echo "<tr ".$tr_link.">\n";
  111. echo " <td valign='top' class='".$row_style[$c]."'>".$row['school_bell_name']."&nbsp;</td>\n";
  112. echo " <td valign='top' class='".$row_style[$c]."'>".$row['school_bell_leg_a_data']."&nbsp;</td>\n";
  113. echo " <td valign='top' class='".$row_style[$c]."'>".$row['school_bell_leg_b_data']."&nbsp;</td>\n";
  114. $school_bell_schedule_time = ($row['school_bell_min'] == -1) ? '* ': $row['school_bell_min'] . " ";
  115. $school_bell_schedule_time .= ($row['school_bell_hour'] == -1) ? '* ': $row['school_bell_hour'] . " ";
  116. $school_bell_schedule_time .= ($row['school_bell_dom'] == -1) ? '* ': $row['school_bell_dom'] . " ";
  117. $school_bell_schedule_time .= ($row['school_bell_mon'] == -1) ? '* ': $row['school_bell_mon'] . " ";
  118. $school_bell_schedule_time .= ($row['school_bell_dow'] == -1) ? '* ': $row['school_bell_dow'] . " ";
  119. echo " <td valign='top' class='".$row_style[$c]."'>".$school_bell_schedule_time."&nbsp;</td>\n";
  120. echo " <td valign='top' class='".$row_style[$c]."'>".$row['school_bell_enabled']."&nbsp;</td>\n";
  121. echo " <td valign='top' class='".$row_style[$c]."'>".$row['school_bell_description']."&nbsp;</td>\n";
  122. echo " <td class='list_control_icons'>";
  123. if (permission_exists('school_bell_edit')) {
  124. echo "<a href='school_bell_edit.php?id=".$row['school_bell_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
  125. }
  126. if (permission_exists('school_bell_delete')) {
  127. echo "<a href='school_bell_delete.php?id=".$row['school_bell_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
  128. }
  129. echo " </td>\n";
  130. echo "</tr>\n";
  131. $c = 1 - $c; // Switch 1/0/1/0...
  132. } //end foreach
  133. unset($sql, $result, $row_count);
  134. } //end if results
  135. echo "<tr>\n";
  136. echo "<td colspan='10' align='left'>\n";
  137. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  138. echo " <tr>\n";
  139. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  140. echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
  141. echo " <td class='list_control_icons'>";
  142. if (permission_exists('school_bell_add')) {
  143. echo "<a href='school_bell_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
  144. }
  145. echo " </td>\n";
  146. echo " </tr>\n";
  147. echo " </table>\n";
  148. echo "</td>\n";
  149. echo "</tr>\n";
  150. echo "</table>";
  151. echo "<br /><br />";
  152. //include the footer
  153. require_once "resources/footer.php";
  154. ?>