|
|
@@ -1,21 +1,37 @@
|
|
|
-<?php
|
|
|
+<?php /** @noinspection PhpUnhandledExceptionInspection */
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
+use App\Constraint\HasTextConstraint;
|
|
|
+
|
|
|
$core = Core::getInstance();
|
|
|
$core->addBreadcrumb("/customers", __("Customers"));
|
|
|
|
|
|
-$count = Customer::count();
|
|
|
+$nvp = [];
|
|
|
+
|
|
|
+$request = Request::fromRequest();
|
|
|
+
|
|
|
+$customer_id = $request->int("customer_id");
|
|
|
+if($customer_id) {
|
|
|
+ $nvp["id"] = $customer_id;
|
|
|
+}
|
|
|
+
|
|
|
+$name = $request->string("name");
|
|
|
+if($name) {
|
|
|
+ $nvp["name"] = new HasTextConstraint($name);
|
|
|
+}
|
|
|
+
|
|
|
+$count = Customer::count($nvp);
|
|
|
|
|
|
$pagination = new Pagination($count);
|
|
|
$pagination->setTerms(__("%s customer"), __("%s customers"));
|
|
|
|
|
|
-$customers = Customer::query([], [
|
|
|
+$customers = Customer::query($nvp, [
|
|
|
"sort" => "name",
|
|
|
"offset" => $pagination->getOffset(),
|
|
|
"limit" => $pagination->getPageSize()
|
|
|
]);
|
|
|
|
|
|
View::include("header");
|
|
|
-View::include("customers", compact("customers", "pagination"));
|
|
|
+View::include("customers", compact("customers", "pagination", "customer_id", "name"));
|
|
|
View::include("footer");
|