Account and permission manager and security log viewer. https://netsyms.biz/apps/managepanel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

getmanagetable.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. require __DIR__ . '/../required.php';
  6. dieifnotloggedin();
  7. header("Content-Type: application/json");
  8. $out = [];
  9. $out['draw'] = intval($VARS['draw']);
  10. $out['recordsTotal'] = $database->count('managers');
  11. $filter = false;
  12. // sort
  13. $order = null;
  14. $sortby = "DESC";
  15. if ($VARS['order'][0]['dir'] == 'asc') {
  16. $sortby = "ASC";
  17. }
  18. switch ($VARS['order'][0]['column']) {
  19. case 2:
  20. $order = ["managername" => $sortby];
  21. break;
  22. case 3:
  23. $order = ["employeename" => $sortby];
  24. break;
  25. }
  26. // search
  27. if (!empty($VARS['search']['value'])) {
  28. $filter = true;
  29. $wherenolimit = [
  30. "OR" => [
  31. "manager.username[~]" => $VARS['search']['value'],
  32. "employee.username[~]" => $VARS['search']['value'],
  33. "manager.realname[~]" => $VARS['search']['value'],
  34. "employee.realname[~]" => $VARS['search']['value']
  35. ]
  36. ];
  37. $where = $wherenolimit;
  38. $where["LIMIT"] = [$VARS['start'], $VARS['length']];
  39. } else {
  40. $where = ["LIMIT" => [$VARS['start'], $VARS['length']]];
  41. }
  42. if (!is_null($order)) {
  43. $where["ORDER"] = $order;
  44. }
  45. $managers = $database->select('managers', [
  46. "[>]accounts (manager)" => ['managerid' => 'uid'],
  47. "[>]accounts (employee)" => ['employeeid' => 'uid']
  48. ], [
  49. 'managerid',
  50. 'employeeid',
  51. 'manager.username (manageruser)',
  52. 'employee.username (employeeuser)',
  53. 'manager.realname (managername)',
  54. 'employee.realname (employeename)',
  55. ], $where);
  56. $out['status'] = "OK";
  57. if ($filter) {
  58. $recordsFiltered = $database->count('managers', [
  59. "[>]accounts (manager)" => ['managerid' => 'uid'],
  60. "[>]accounts (employee)" => ['employeeid' => 'uid']
  61. ], 'managerid', $wherenolimit);
  62. } else {
  63. $recordsFiltered = $out['recordsTotal'];
  64. }
  65. $out['recordsFiltered'] = $recordsFiltered;
  66. for ($i = 0; $i < count($managers); $i++) {
  67. $managers[$i]["delbtn"] = '<a class="btn btn-danger btn-xs" href="app.php?page=delmanager&mid=' . $managers[$i]['managerid'] . '&eid=' . $managers[$i]['employeeid'] . '"><i class="fa fa-trash"></i> ' . $Strings->get("delete", false) . '</a>';
  68. }
  69. $out['managers'] = $managers;
  70. echo json_encode($out);