|
|
@@ -1,23 +1,42 @@
|
|
|
-<?php
|
|
|
+<?php /** @noinspection PhpUnhandledExceptionInspection */
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
+use App\Constraint\HasTextConstraint;
|
|
|
+
|
|
|
$core = Core::getInstance();
|
|
|
$core->addBreadcrumb("/locations", __("Locations"));
|
|
|
|
|
|
-$user = $core->getUser();
|
|
|
+$nvp = ["dts_deleted" => null];
|
|
|
+
|
|
|
+$request = Request::fromRequest();
|
|
|
+
|
|
|
+$customer_id = $request->int("customer_id");
|
|
|
+if($customer_id) {
|
|
|
+ $nvp["customer_id"] = $customer_id;
|
|
|
+}
|
|
|
+
|
|
|
+$location_id = $request->int("location_id");
|
|
|
+if($location_id) {
|
|
|
+ $nvp["id"] = $location_id;
|
|
|
+}
|
|
|
+
|
|
|
+$name = $request->string("name");
|
|
|
+if($name) {
|
|
|
+ $nvp["name"] = new HasTextConstraint($name);
|
|
|
+}
|
|
|
|
|
|
-$count = Location::count(["dts_deleted" => null]);
|
|
|
+$count = Location::count($nvp);
|
|
|
|
|
|
$pagination = new Pagination($count);
|
|
|
$pagination->setTerms(__("%s location"), __("%s locations"));
|
|
|
|
|
|
-$locations = Location::query([], [
|
|
|
+$locations = Location::query($nvp, [
|
|
|
"sort" => "name",
|
|
|
"offset" => $pagination->getOffset(),
|
|
|
"limit" => $pagination->getPageSize()
|
|
|
]);
|
|
|
|
|
|
View::include("header");
|
|
|
-View::include("locations", compact("locations", "pagination"));
|
|
|
+View::include("locations", compact("locations", "pagination", "customer_id", "location_id", "name"));
|
|
|
View::include("footer");
|