locations.php 844 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. Core::addBreadcrumb("/account", "Account");
  3. Core::addBreadcrumb("/account/locations", "Locations");
  4. $customer = Customer::getForAdmin();
  5. if(!$customer) throw new Exception("You do not have permission to access this page.");
  6. $page_title = "$customer->name Locations";
  7. Core::addBreadcrumb("/account/locations?customer_id=$customer->id", $page_title);
  8. $nvp = ["customer_id" => $customer->id];
  9. $id = http::value("id", "int");
  10. $name = http::value("name", "trim");
  11. if($id) $nvp["id"] = $id;
  12. if($name) $nvp["name"] = (new Constraint("CONTAINS"))->setValues($name);
  13. $locations = Location::query($nvp, ["sort" => "name", "order" => "asc"]);
  14. $filter_count = count($nvp) - 1;
  15. View::includeOnce("header", compact("page_title"));
  16. View::include("locations", compact("customer", "filter_count", "locations"));
  17. View::includeOnce("footer");
  18. ?>