From c23845ce140713d81659d47c423abf8d391f6dc3 Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Tue, 27 Feb 2018 03:11:29 +0800 Subject: [PATCH 1/2] Add flag_active and title fields to customer #25 --- src/Entity/Customer.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 8fb59dd1..bbd287c8 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -22,6 +22,13 @@ class Customer */ protected $id; + // title + /** + * @ORM\Column(type="string", length=10) + * @Assert\NotBlank() + */ + protected $title; + // first name /** * @ORM\Column(type="string", length=80) @@ -90,6 +97,12 @@ class Customer */ protected $flag_mobile_app; + // if active + /** + * @ORM\Column(type="boolean") + */ + protected $flag_active; + public function __construct() { $this->numbers = new ArrayCollection(); @@ -102,6 +115,7 @@ class Customer $this->flag_confirmed = false; $this->flag_mobile_app = false; + $this->flag_active = false; } public function getID() @@ -109,6 +123,17 @@ class Customer return $this->id; } + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + public function getTitle() + { + return $this->title; + } + public function setFirstName($first_name) { $this->first_name = $first_name; @@ -256,6 +281,17 @@ class Customer return $this->flag_mobile_app; } + public function setActive($flag_active = true) + { + $this->flag_active = $flag_active; + return $this; + } + + public function isActive() + { + return $this->flag_active; + } + public function getJobOrders() { return $this->job_orders; From 8baa8734bc17c99f72515ebefae2513b176305f8 Mon Sep 17 00:00:00 2001 From: Ramon Gutierrez Date: Tue, 27 Feb 2018 03:50:28 +0800 Subject: [PATCH 2/2] Add title and active fields to customer form and list #25 --- src/Controller/CustomerController.php | 14 ++++++++++---- templates/customer/form.html.twig | 27 +++++++++++++++++++++++---- templates/customer/list.html.twig | 19 +++++++++++++++++++ 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/Controller/CustomerController.php b/src/Controller/CustomerController.php index 5ba29744..a8eef366 100644 --- a/src/Controller/CustomerController.php +++ b/src/Controller/CustomerController.php @@ -109,11 +109,13 @@ class CustomerController extends BaseController foreach ($obj_rows as $orow) { // add row data $row['id'] = $orow->getID(); + $row['title'] = $orow->getTitle(); $row['first_name'] = $orow->getFirstName(); $row['last_name'] = $orow->getLastName(); $row['customer_classification'] = CustomerClassification::getName($orow->getCustomerClassification()); $row['flag_mobile_app'] = $orow->hasMobileApp(); $row['app_mobile_number'] = $orow->hasMobileApp() && !empty($orow->getMobileSessions()) ? $orow->getMobileSessions()[0]->getPhoneNumber() : ''; + $row['flag_active'] = $orow->isActive(); // TODO: properly add mobile numbers and plate numbers as searchable/sortable fields, use doctrine events $row['mobile_numbers'] = implode("
", $orow->getMobileNumberList()); @@ -173,10 +175,12 @@ class CustomerController extends BaseController $row = new Customer(); // set and save values - $row->setFirstName($req->request->get('first_name')) + $row->setTitle($req->request->get('title')) + ->setFirstName($req->request->get('first_name')) ->setLastName($req->request->get('last_name')) ->setCustomerClassification($req->request->get('customer_classification')) - ->setCustomerNotes($req->request->get('customer_notes')); + ->setCustomerNotes($req->request->get('customer_notes')) + ->setActive($req->request->get('flag_active') ? true : false); // initialize error lists $error_array = []; @@ -471,10 +475,12 @@ class CustomerController extends BaseController throw $this->createNotFoundException('The item does not exist'); // set and save values - $cust->setFirstName($req->request->get('first_name')) + $cust->setTitle($req->request->get('title')) + ->setFirstName($req->request->get('first_name')) ->setLastName($req->request->get('last_name')) ->setCustomerClassification($req->request->get('customer_classification')) - ->setCustomerNotes($req->request->get('customer_notes')); + ->setCustomerNotes($req->request->get('customer_notes')) + ->setActive($req->request->get('flag_active') ? true : false); // initialize error lists $error_array = []; diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index 65255dc0..68642d19 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -41,7 +41,7 @@
-
+
@@ -54,14 +54,21 @@
-
+
+ + + +
+
-
+
@@ -70,7 +77,7 @@
-
+
@@ -78,6 +85,18 @@
+
+
+ + + + +
+
diff --git a/templates/customer/list.html.twig b/templates/customer/list.html.twig index f17b28de..f6c87020 100644 --- a/templates/customer/list.html.twig +++ b/templates/customer/list.html.twig @@ -83,6 +83,10 @@ title: 'ID', width: 30 }, + { + field: 'title', + title: 'Title' + }, { field: 'first_name', title: 'First Name' @@ -105,6 +109,21 @@ title: 'Plate Numbers', sortable: false }, + { + field: 'flag_active', + title: 'Active', + template: function (row, index, datatable) { + var tag = ''; + + if (row.flag_active === true) { + tag = 'Yes'; + } else { + tag = 'No'; + } + + return tag; + } + }, {# { field: 'flag_confirmed',