瀏覽代碼

Added internal ID filter.

Alan Lam 8 年之前
父節點
當前提交
41ed811cf3
共有 3 個文件被更改,包括 31 次插入 和 10 次删除
  1. 3 1
      controllers/locations.php
  2. 7 0
      views/location_list.php
  3. 21 9
      views/locations.php

+ 3 - 1
controllers/locations.php

@@ -14,10 +14,12 @@ Core::addBreadcrumb("/account/locations?customer_id=$customer->id", $page_title)
 $nvp = ["customer_id" => $customer->id];
 
 $id = http::value("id", "int");
+$internal_id = http::value("internal_id", "trim");
 $name = http::value("name", "trim");
 
 if($id) $nvp["id"] = $id;
-if($name) $nvp["name"] = (new Constraint("CONTAINS"))->setValues($name);
+if($internal_id) $nvp["internal_id"] = db::escape($internal_id);
+if($name) $nvp["name"] = (new Constraint("CONTAINS"))->setValues(db::escape($name));
 
 $locations = Location::query($nvp, ["sort" => "name", "order" => "asc"]);
 

+ 7 - 0
views/location_list.php

@@ -16,6 +16,13 @@
 			</td>
 			<td>
 				<a href="/account/locations/<?=$location->id?>"><?=htmlspecialchars($location->name)?></a><br />
+				<?php
+				if($location->internal_id) {
+					?>
+					<small class="text-info">Internal ID: <?=htmlspecialchars($location->internal_id)?></small><br />
+					<?php
+				}
+				?>
 				<small><?=htmlspecialchars($location->getDisplayAddress(["address_1", "address_2", "city", "postal_code"]))?></small>
 			</td>
 			<td class="text-right align-middle">

+ 21 - 9
views/locations.php

@@ -30,16 +30,28 @@
 			<div class="card-body">
 				<form method="get">
 					<input type="hidden" name="customer_id" value="<?=http::value("customer_id", "int")?>" />
-					<div class="row mb-1">
-						<label class="col-sm-4 col-form-label" for="id">ID</label>
-						<div class="col-sm">
-							<input class="form-control" type="number" name="id" id="id" placeholder="Enter ID" value="<?=htmlspecialchars(http::value("id", "int"))?>" />
+					<div class="row mb-3">
+						<div class="col-lg-6">
+							<div class="row mb-1">
+								<label class="col-sm-4 col-form-label" for="id">ID</label>
+								<div class="col-sm">
+									<input class="form-control" type="number" name="id" id="id" placeholder="Enter ID" value="<?=htmlspecialchars(http::value("id", "int"))?>" />
+								</div>
+							</div>
+							<div class="row mb-1">
+								<label class="col-sm-4 col-form-label" for="name">Name</label>
+								<div class="col-sm">
+									<input class="form-control" type="text" name="name" id="name" placeholder="Enter name" value="<?=htmlspecialchars(http::value("name"))?>" />
+								</div>
+							</div>
 						</div>
-					</div>
-					<div class="row mb-1">
-						<label class="col-sm-4 col-form-label" for="name">Name</label>
-						<div class="col-sm">
-							<input class="form-control" type="text" name="name" id="name" placeholder="Enter name" value="<?=htmlspecialchars(http::value("name"))?>" />
+						<div class="col-lg-6">
+							<div class="row mb-1">
+								<label class="col-sm-4 col-form-label" for="internal-id">Internal ID</label>
+								<div class="col-sm">
+									<input class="form-control" type="number" name="internal_id" id="internal-id" placeholder="Enter internal ID" value="<?=htmlspecialchars(http::value("internal_id", "trim"))?>" />
+								</div>
+							</div>
 						</div>
 					</div>
 					<button class="btn btn-primary mt-3" type="submit">Submit</button>