1
0

locations.php 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. namespace App;
  3. use App\Constraint\HasTextConstraint;
  4. $core = Core::getInstance();
  5. $core->addBreadcrumb("/locations", __("Locations"));
  6. $nvp = ["dts_deleted" => null];
  7. $request = Request::fromRequest();
  8. $customer_id = $request->int("customer_id");
  9. if($customer_id) {
  10. $nvp["customer_id"] = $customer_id;
  11. }
  12. $location_id = $request->int("location_id");
  13. if($location_id) {
  14. $nvp["id"] = $location_id;
  15. }
  16. $name = $request->string("name");
  17. if($name) {
  18. $nvp["name"] = new HasTextConstraint($name);
  19. }
  20. $count = Location::count($nvp);
  21. $pagination = new Pagination($count);
  22. $pagination->setTerms(__("%s location"), __("%s locations"));
  23. $locations = Location::query($nvp, [
  24. "sort" => "name",
  25. "offset" => $pagination->getOffset(),
  26. "limit" => $pagination->getPageSize()
  27. ]);
  28. $core->addScript("/js/map.js");
  29. View::include("header");
  30. View::include("locations", compact("locations", "pagination", "customer_id", "location_id", "name"));
  31. View::include("footer");