school_bells.php 6.6 KB

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