locations.php 1019 B

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