templates.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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-2010
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. include "root.php";
  22. require_once "includes/config.php";
  23. require_once "includes/checkauth.php";
  24. if (!ifgroup("superadmin")) {
  25. echo "access denied";
  26. exit;
  27. }
  28. require_once "includes/header.php";
  29. require_once "includes/paging.php";
  30. $orderby = $_GET["orderby"];
  31. $order = $_GET["order"];
  32. echo "<div align='center'>";
  33. echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
  34. echo "<tr class='border'>\n";
  35. echo " <td align=\"center\">\n";
  36. echo " <br>";
  37. echo "<table width='100%' border='0'><tr>\n";
  38. echo "<td width='50%' align='left' nowrap><b>Template List</b></td>\n";
  39. echo "<td width='50%' align='right'>\n";
  40. echo " <input type='button' class='btn' value='Restore Default' onclick=\"document.location.href='template_restore_default.php';\" />";
  41. echo "</td>\n";
  42. echo "<td width='35' nowrap></td>\n";
  43. echo "</tr></table>";
  44. $sql = "";
  45. $sql .= "select * from v_templates ";
  46. $sql .= "where domain_uuid = '$domain_uuid' ";
  47. if (strlen($orderby)> 0) { $sql .= "order by $orderby $order "; }
  48. $prepstatement = $db->prepare(check_sql($sql));
  49. $prepstatement->execute();
  50. $result = $prepstatement->fetchAll();
  51. $numrows = count($result);
  52. unset ($prepstatement, $result, $sql);
  53. $rowsperpage = 10;
  54. $param = "";
  55. $page = $_GET['page'];
  56. if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
  57. list($pagingcontrols, $rowsperpage, $var3) = paging($numrows, $param, $rowsperpage);
  58. $offset = $rowsperpage * $page;
  59. $sql = "";
  60. $sql .= "select * from v_templates ";
  61. $sql .= "where domain_uuid = '$domain_uuid' ";
  62. if (strlen($orderby)> 0) { $sql .= "order by $orderby $order "; }
  63. $sql .= " limit $rowsperpage offset $offset ";
  64. $prepstatement = $db->prepare(check_sql($sql));
  65. $prepstatement->execute();
  66. $result = $prepstatement->fetchAll();
  67. $resultcount = count($result);
  68. unset ($prepstatement, $sql);
  69. $c = 0;
  70. $rowstyle["0"] = "rowstyle0";
  71. $rowstyle["1"] = "rowstyle1";
  72. echo "<div align='center'>\n";
  73. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  74. echo "<tr>\n";
  75. echo thorderby('templatename', 'Name', $orderby, $order);
  76. echo thorderby('templatedesc', 'Description', $orderby, $order);
  77. echo "<td align='right' width='42'>\n";
  78. echo " <a href='templates_edit.php' alt='add'>$v_link_label_add</a>\n";
  79. //echo " <input type='button' class='btn' name='' alt='add' onclick=\"window.location='templates_edit.php'\" value='+'>\n";
  80. echo "</td>\n";
  81. echo "<tr>\n";
  82. if ($resultcount == 0) { //no results
  83. }
  84. else { //received results
  85. foreach($result as $row) {
  86. //print_r( $row );
  87. echo "<tr >\n";
  88. echo " <td valign='top' class='".$rowstyle[$c]."'>".$row[templatename]."&nbsp;</td>\n";
  89. echo " <td valign='top' class='".$rowstyle[$c]."'>".$row[templatedesc]."&nbsp;</td>\n";
  90. echo " <td valign='top' align='right'>\n";
  91. echo " <a href='templates_edit.php?id=".$row[templateid]."' alt='edit'>$v_link_label_edit</a>\n";
  92. echo " <a href='templates_delete.php?id=".$row[templateid]."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
  93. //echo " <input type='button' class='btn' name='' alt='edit' onclick=\"window.location='templates_edit.php?id=".$row[template_id]."'\" value='e'>\n";
  94. //echo " <input type='button' class='btn' name='' alt='delete' onclick=\"if (confirm('Are you sure you want to delete this?')) { window.location='templates_delete.php?id=".$row[template_id]."' }\" value='x'>\n";
  95. echo " </td>\n";
  96. echo "</tr>\n";
  97. if ($c==0) { $c=1; } else { $c=0; }
  98. } //end foreach
  99. unset($sql, $result, $rowcount);
  100. } //end if results
  101. echo "<tr>\n";
  102. echo "<td colspan='3' align='left'>\n";
  103. echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
  104. echo " <tr>\n";
  105. echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
  106. echo " <td width='33.3%' align='center' nowrap>$pagingcontrols</td>\n";
  107. echo " <td width='33.3%' align='right'>\n";
  108. echo " <a href='templates_edit.php' alt='add'>$v_link_label_add</a>\n";
  109. //echo " <input type='button' class='btn' name='' alt='add' onclick=\"window.location='templates_edit.php'\" value='+'>\n";
  110. echo " </td>\n";
  111. echo " </tr>\n";
  112. echo " </table>\n";
  113. echo "</td>\n";
  114. echo "</tr>\n";
  115. echo "</table>";
  116. echo "</div>";
  117. echo "<br><br>";
  118. echo "<br><br>";
  119. echo "</td>";
  120. echo "</tr>";
  121. echo "</table>";
  122. echo "</div>";
  123. echo "<br><br>";
  124. require_once "includes/footer.php";
  125. unset ($resultcount);
  126. unset ($result);
  127. unset ($key);
  128. unset ($val);
  129. unset ($c);
  130. ?>