1
0

customers.php 846 B

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