1
0
Эх сурвалжийг харах

Add Country field to Customer form

Alan Lam 8 жил өмнө
parent
commit
4fbb5eb749

+ 2 - 0
controllers/customer_add.php

@@ -7,6 +7,7 @@ Core::addBreadcrumb("/account/customers", "Customers");
 Core::addBreadcrumb("/account/customers/add", $page_title);
 
 $customer = new Customer;
+$customer->country = DEFAULT_COUNTRY;
 $customer->email_after_test = 1;
 $customer->email_locations_after_test = 1;
 
@@ -23,6 +24,7 @@ if($submit) {
 		$customer->city = http::value("city", "trim");
 		$customer->county = http::value("county", "trim");
 		$customer->postal_code = http::value("postal_code", "trim");
+		$customer->country = http::value("country", "trim");
 		$customer->email = http::value("email", "email");
 		$customer->phone = http::value("phone", "trim");
 		$customer->email_after_test = http::value("email_after_test", "int");

+ 1 - 0
controllers/customer_edit.php

@@ -23,6 +23,7 @@ if($submit) {
 		$customer->city = http::value("city", "trim");
 		$customer->county = http::value("county", "trim");
 		$customer->postal_code = http::value("postal_code", "trim");
+		$customer->country = http::value("country", "trim");
 		$customer->email = http::value("email", "email");
 		$customer->phone = http::value("phone", "trim");
 		$customer->email_after_test = http::value("email_after_test", "int");

+ 1 - 1
engine/customer.php

@@ -4,7 +4,7 @@ class Customer extends Model {
 
 	protected static $table = "customer";
 	protected static $id_field = "id";
-	protected static $fillable_fields = ["name", "address_1", "address_2", "city", "county", "postal_code", "email", "phone", "email_after_test", "email_locations_after_test"];
+	protected static $fillable_fields = ["name", "address_1", "address_2", "city", "county", "postal_code", "country", "email", "phone", "email_after_test", "email_locations_after_test"];
 
 	// Static methods
 	public static function getForAdmin() {

+ 8 - 0
views/customer_form.php

@@ -38,6 +38,14 @@
 				<input class="form-control" type="text" name="postal_code" id="postal-code" placeholder="Enter postal code" value="<?=htmlspecialchars($customer->postal_code)?>" />
 			</div>
 		</div>
+		<div class="row mb-1">
+			<label class="col-sm-4 col-form-label" for="country">Country</label>
+			<div class="col-sm">
+				<select class="form-control" name="country" id="country">
+				<?=Form::renderCountryOptions($customer->country)?>
+				</select>
+			</div>
+		</div>
 		<div class="row mb-1">
 			<label class="col-sm-4 col-form-label"for="email">Email Address</label>
 			<div class="col-sm">