diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index b96dfae9..de60e772 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -165,6 +165,21 @@ class Customer */ protected $privpol_promo; + /** + * @ORM\Column(type="boolean", options={"default":false}) + */ + protected $flag_promo_email; + + /** + * @ORM\Column(type="boolean", options={"default":false}) + */ + protected $flag_promo_sms; + + /** + * @ORM\Column(type="boolean", options={"default":false}) + */ + protected $flag_dpa_consent; + public function __construct() { $this->numbers = new ArrayCollection(); @@ -191,6 +206,10 @@ class Customer $this->priv_promo = 0; $this->flag_csat = false; + + $this->flag_promo_email = false; + $this->flag_promo_sms = false; + $this->flag_dpa_consent = false; } public function getID() @@ -490,5 +509,36 @@ class Customer return $this->privpol_promo; } + public function setPromoEmail($flag_promo_email = true) + { + $this->flag_promo_email = $flag_promo_email; + return $this; + } + public function isPromoEmail() + { + return $this->flag_promo_email; + } + + public function setPromoSms($flag_promo_sms = true) + { + $this->flag_promo_sms = $flag_promo_sms; + return $this; + } + + public function isPromoSms() + { + return $this->flag_promo_sms; + } + + public function setDpaConsent($flag_dpa_consent = true) + { + $this->flag_dpa_consent = $flag_dpa_consent; + return $this; + } + + public function isDpaConsent() + { + return $this->flag_dpa_consent; + } } diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index 5f7e00e2..e27399e3 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -514,6 +514,10 @@ class ResqCustomerHandler implements CustomerHandlerInterface 'phone_landline' => $customer->getPhoneLandline(), 'phone_office' => $customer->getPhoneOffice(), 'phone_fax' => $customer->getPhoneFax(), + 'email' => $customer->getEmail(), + 'flag_dpa_consent' => $customer->isDpaConsent(), + 'flag_promo_sms' => $customer->isPromoSms(), + 'flag_promo_email' => $customer->isPromoEmail(), ], 'vehicle' => [ 'id' => $vehicle->getID(), @@ -566,7 +570,10 @@ class ResqCustomerHandler implements CustomerHandlerInterface ->setCustomerNotes($req->request->get('customer_notes')) ->setEmail($req->request->get('email')) ->setIsCSAT($req->request->get('flag_csat') ? true : false) - ->setActive($req->request->get('flag_active') ? true : false); + ->setActive($req->request->get('flag_active') ? true : false) + ->setPromoSms($req->request->get('flag_promo_sms', false)) + ->setPromoEmail($req->request->get('flag_promo_email', false)) + ->setDpaConsent($req->request->get('flag_dpa_consent', false)); // phone numbers $obj->setPhoneMobile($req->request->get('phone_mobile')) diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 497b6599..2badddaa 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -24,6 +24,7 @@ use App\Entity\Promo; use App\Entity\Rider; use App\Entity\JORejection; use App\Entity\Warranty; +use App\Entity\Customer; use App\Ramcar\InvoiceCriteria; use App\Ramcar\ServiceType; @@ -280,6 +281,22 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $jo = new JobOrder(); } + // find customer + $cust_id = $req->request->get('cid'); + $customer = $em->getRepository(Customer::class)->find($cust_id); + if (empty($customer)) + { + $error_array['customer_vehicle'] = 'Invalid customer specified.'; + } + else + { + // get email, dpa_consent, promo_sms, and promo_email, if set + $customer->setEmail($req->request->get('customer_email')) + ->setPromoSms($req->request->get('flag_promo_sms', false)) + ->setPromoEmail($req->request->get('flag_promo_email', false)) + ->setDpaConsent($req->request->get('flag_dpa_consent', false)); + } + // check if lat and lng are provided if (empty($req->request->get('coord_lng')) || empty($req->request->get('coord_lat'))) { $error_array['coordinates'] = 'No map coordinates provided. Please click on a location on the map.'; @@ -365,8 +382,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // check if errors are found if (empty($error_array)) { - // validated, no error. save the job order + // validated, no error. save the job order and customer $em->persist($jo); + $em->persist($customer); // the event $event = new JOEvent(); diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index f502e778..cb07b5a3 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -92,30 +92,54 @@
-
- - - - -
-
+
+ + + +
+
+
+
+ +
+ + +
+
+
+
+ + +
+
+
-
- - - - -
-
- +
+ + + +
+
+ +
diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index fe9f00ac..a0e5985c 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -46,6 +46,7 @@
+
{% if ftags.vehicle_dropdown %} @@ -148,6 +149,11 @@
+
+ + + +
@@ -295,8 +301,8 @@
-
-
+
+
-
+
@@ -331,6 +337,34 @@
+
+
+
+
+ +
+ + +
+
+
+
+
+ + + +
+