Jelajahi Sumber

Pre-populate fields when adding location from customer

Alan Lam 2 tahun lalu
induk
melakukan
662e3e4465
1 mengubah file dengan 13 tambahan dan 1 penghapusan
  1. 13 1
      controllers/location_form.php

+ 13 - 1
controllers/location_form.php

@@ -24,6 +24,8 @@ if(isset($id)) {
 	$core->addBreadcrumb($customer->getUrl(), $customer->name);
 	$core->addBreadcrumb($location->getUrl(), $location->name);
 
+	$address = $location->getAddress();
+
 	$title = __("Update Location");
 }
 else {
@@ -33,7 +35,17 @@ else {
 	if($customer_id) {
 		$customer = Customer::require($customer_id);
 		$location->customer_id = $customer_id;
+		$location->name = $customer->name;
+		$location->phone = $customer->phone;
+		$location->fax = $customer->fax;
+		$location->email = $customer->email;
+
 		$core->addBreadcrumb($customer->getUrl(), $customer->name);
+
+		$address = $customer->getAddress();
+	}
+	else {
+		$address = $location->getAddress();
 	}
 
 	$location->dts_created = Database::dts();
@@ -63,6 +75,6 @@ View::include("header");
 View::include("entity_form", [
 	"title" => $title,
 	"model" => $location,
-	"address" => $location->getAddress()
+	"address" => $address
 ]);
 View::include("footer");