|
|
@@ -8,6 +8,12 @@ Core::addBreadcrumb("/account/locations", "Locations");
|
|
|
$customer = Customer::getForAdmin();
|
|
|
if(!$customer) throw new Exception("You do not have permission to access this page.");
|
|
|
|
|
|
+$sorts = [
|
|
|
+ "name" => "Name",
|
|
|
+ "last-added" => "Last Added",
|
|
|
+ "internal-id" => "Internal ID",
|
|
|
+];
|
|
|
+
|
|
|
$page_title = "$customer->name Locations";
|
|
|
|
|
|
Core::addBreadcrumb("/account/locations?customer_id=$customer->id", $page_title);
|
|
|
@@ -24,7 +30,7 @@ if($name) $nvp["name"] = (new Constraint("CONTAINS"))->setValues(db::escape($nam
|
|
|
|
|
|
$sort = http::value("sort");
|
|
|
switch($sort) {
|
|
|
- case "last_added":
|
|
|
+ case "last-added":
|
|
|
$query_sort = "id";
|
|
|
$order = "desc";
|
|
|
break;
|
|
|
@@ -34,13 +40,18 @@ switch($sort) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
$locations = Location::query($nvp, ["sort" => $query_sort, "order" => $order]);
|
|
|
|
|
|
+if($sort == "internal-id") {
|
|
|
+ usort($locations, function($a, $b) {
|
|
|
+ return strnatcasecmp($a->internal_id, $b->internal_id);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
$filter_count = count($nvp) - 1;
|
|
|
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
-View::include("locations", compact("customer", "filter_count", "locations"));
|
|
|
+View::include("locations", compact("customer", "filter_count", "sorts", "sort", "locations"));
|
|
|
View::includeOnce("footer");
|
|
|
|
|
|
?>
|