users.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. if(Core::$user->level == User::LEVEL_SUPERADMIN) {
  3. $page_title = "Users";
  4. }
  5. else {
  6. $page_title = "Testers";
  7. }
  8. Core::addBreadcrumb("/account", "Account");
  9. Core::addBreadcrumb("/account/users", $page_title);
  10. $id = http::value("id", "int");
  11. $first_name = http::value("first_name", "trim");
  12. $last_name = http::value("last_name", "trim");
  13. $email = http::value("email", "trim");
  14. $level = http::value("level", "int");
  15. $customer_id = http::value("customer_id", "int");
  16. $location_id = http::value("location_id", "int");
  17. $nvp = [];
  18. if($id !== false) $nvp["id"] = $id;
  19. if(strlen($first_name) > 0) $nvp["first_name"] = ((new Constraint("CONTAINS"))->setValues($first_name));
  20. if(strlen($last_name) > 0) $nvp["last_name"] = ((new Constraint("CONTAINS"))->setValues($last_name));
  21. if(strlen($email) > 0) $nvp["email"] = $email;
  22. if($level !== false) $nvp["level"] = $level;
  23. $filter_count = "";
  24. if($nvp) $filter_count = count(array_keys($nvp));
  25. if(empty($nvp)) {
  26. $nvp["level"] = (new Constraint("NOT_EQUALS"))->setValues(User::LEVEL_REGISTERED);
  27. }
  28. $users = User::query($nvp);
  29. $pagination_object = Util::getPaginationObject($users);
  30. Core::$page = $pagination_object->page;
  31. Core::$page_count = $pagination_object->pageCount;
  32. $users = array_slice($users, $pagination_object->offset, $pagination_object->pageSize);
  33. View::includeOnce("header", compact("page_title"));
  34. View::include("users", compact("users", "pagination_object", "filter_count", "id", "first_name", "last_name", "email", "level", "customer_id", "location_id"));
  35. View::includeOnce("modal_page_jump");
  36. View::includeOnce("footer");
  37. ?>