groups.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
  3. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
  4. if (isset($_POST["create"])) {
  5. $fname = $_POST["newgroup"];
  6. if ($fname) {
  7. $new['group_name'] = $fname;
  8. $new_id=insert_record($db_link, "Group_list", $new);
  9. header("location: editgroup.php?id=$new_id");
  10. exit;
  11. }
  12. header("Location: " . $_SERVER["REQUEST_URI"]);
  13. exit;
  14. }
  15. if (isset($_POST["remove"])) {
  16. $fgid = $_POST["fid"];
  17. foreach ($fgid as $key => $val) {
  18. if (!empty($val)) { delete_record($db_link, "Group_list", "id=" . $val * 1); }
  19. }
  20. header("Location: " . $_SERVER["REQUEST_URI"]);
  21. exit;
  22. }
  23. unset($_POST);
  24. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
  25. print_filters_submenu($page_url);
  26. ?>
  27. <div id="cont">
  28. <form name="def" action="groups.php" method="post">
  29. <table class="data">
  30. <tr align="center">
  31. <td><input type="checkbox" onClick="checkAll(this.checked);"></td>
  32. <td><b>Id</b></td>
  33. <td width=200><b>Название</b></td>
  34. <td width=200><b>Комментарий</b></td>
  35. </tr>
  36. <?php
  37. $groups = get_records_sql($db_link,'SELECT * FROM Group_list ORDER BY id');
  38. foreach ($groups as $row) {
  39. print "<tr align=center>\n";
  40. print "<td class=\"data\" style='padding:0'><input type=checkbox name=fid[] value=".$row["id"]."></td>\n";
  41. print "<td class=\"data\" ><input type=\"hidden\" name=\"".$row["id"]."\" value=".$row["id"].">".$row["id"]."</td>\n";
  42. print "<td class=\"data\"><a href=editgroup.php?id=".$row["id"].">" . $row["group_name"] . "</a></td>\n";
  43. print "<td class=\"data\">" . $row["comment"] . "</td>\n";
  44. }
  45. ?>
  46. </table>
  47. <table class="data">
  48. <tr align=left>
  49. <td>Название <input type=text name=newgroup value="Unknown"></td>
  50. <td><input type="submit" name="create" value="Добавить"></td>
  51. <td align="right"><input type="submit" onclick="return confirm('Удалить?')" name="remove" value="Удалить"></td>
  52. </tr>
  53. </table>
  54. </form>
  55. <?php
  56. require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php");
  57. ?>