From 5769e1c366ecf5d59f60a0b6f880764888f914df Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sat, 10 Mar 2018 14:18:07 +0800 Subject: [PATCH] Replace contact numbers with individual numbers in customer entity, controllers, and templates #UAT --- src/Controller/CustomerController.php | 9 +++ src/Entity/Customer.php | 94 +++++++++++++++++++++++++++ templates/customer/form.html.twig | 49 ++++++++++++++ 3 files changed, 152 insertions(+) diff --git a/src/Controller/CustomerController.php b/src/Controller/CustomerController.php index 996f1b01..c4e60630 100644 --- a/src/Controller/CustomerController.php +++ b/src/Controller/CustomerController.php @@ -417,6 +417,7 @@ class CustomerController extends BaseController } } + /* public function updateNumbers($em, Customer $cust, $numbers) { $number_ids = []; @@ -461,6 +462,7 @@ class CustomerController extends BaseController } } } + */ public function updateSubmit(Request $req, ValidatorInterface $validator, $id) { @@ -490,9 +492,16 @@ class CustomerController extends BaseController // TODO: validate mobile numbers // TODO: validate vehicles + /* // custom validation for mobile numbers $numbers = json_decode($req->request->get('mobile_numbers')); $this->updateNumbers($em, $cust, $numbers); + */ + // phone numbers + $cust->setPhoneMobile($req->request->get('phone_mobile')) + ->setPhoneLandline($req->request->get('phone_landline')) + ->setPhoneOffice($req->request->get('phone_office')) + ->setPhoneFax($req->request->get('phone_fax')); // custom validation for vehicles $vehicles = json_decode($req->request->get('vehicles')); diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 439fb554..868d2ce1 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -61,6 +61,30 @@ class Customer */ protected $numbers; + // mobile phone + /** + * @ORM\Column(type="text", length=12) + */ + protected $phone_mobile; + + // landline + /** + * @ORM\Column(type="text", length=12) + */ + protected $phone_landline; + + // office phone + /** + * @ORM\Column(type="text", length=12) + */ + protected $phone_office; + + // fax + /** + * @ORM\Column(type="text", length=12) + */ + protected $phone_fax; + // mobile sessions linked to this customer /** * @ORM\OneToMany(targetEntity="MobileSession", mappedBy="customer") @@ -117,6 +141,11 @@ class Customer $this->flag_confirmed = false; $this->flag_mobile_app = false; $this->flag_active = true; + + $this->phone_mobile = ''; + $this->phone_landline = ''; + $this->phone_office = ''; + $this->phone_fax = ''; } public function getID() @@ -179,6 +208,7 @@ class Customer return $this->customer_notes; } + /* public function addMobileNumber(MobileNumber $number) { $this->numbers->add($number); @@ -210,6 +240,70 @@ class Customer return $numbers; } + */ + + public function getMobileNumberList() + { + $phones = []; + + if (!empty($this->phone_mobile)) + $phones[] = '+63' . $this->phone_mobile; + + if (!empty($this->phone_landline)) + $phones[] = '+63' . $this->phone_landline; + + if (!empty($this->phone_office)) + $phones[] = '+63' . $this->phone_office; + + if (!empty($this->phone_fax)) + $phones[] = '+63' . $this->phone_fax; + + return $phones; + } + + public function setPhoneMobile($phone) + { + $this->phone_mobile = $phone; + return $this; + } + + public function getPhoneMobile() + { + return $this->phone_mobile; + } + + public function setPhoneLandline($phone) + { + $this->phone_landline = $phone; + return $this; + } + + public function getPhoneLandline() + { + return $this->phone_landline; + } + + public function setPhoneOffice($phone) + { + $this->phone_office = $phone; + return $this; + } + + public function getPhoneOffice() + { + return $this->phone_office; + } + + public function setPhoneFax($phone) + { + $this->phone_fax = $phone; + return $this; + } + + public function getPhoneFax() + { + return $this->phone_fax; + } public function getPlateNumberList() { diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index 52527c8e..b736191e 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -108,6 +108,52 @@
+
+ +
+ +63 + + +
+
+
+ +
+ +63 + + +
+
+
+
+
+ +
+ +63 + + +
+
+
+ +
+ +63 + + +
+
+
+ + {# +
@@ -122,6 +168,7 @@
+ #}
@@ -537,6 +584,7 @@ var vehicleRows = []; var ticketRows = []; + {# {% for number in obj.getMobileNumbers() %} nrow = { id: "{{ number.getID() }}", @@ -546,6 +594,7 @@ numberRows.push(nrow); numberIds.push("{{ number.getID() }}"); {% endfor %} + #} {% for key, cv in obj.getVehicles() %} {% set vehicle = cv.getVehicle() %}