From af85a632e5a531090d94cfac1e712e197f4faa2f Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 15 May 2020 08:48:58 +0000 Subject: [PATCH 1/2] Add acl entry for display of DPA Consent. Add checking when adding/updating customer for DPA consent. #408 --- config/acl.yaml | 2 ++ .../CustomerHandler/ResqCustomerHandler.php | 22 ++++++++++++++----- templates/customer/form.html.twig | 8 ++++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/config/acl.yaml b/config/acl.yaml index 25e04dbc..392696df 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -156,6 +156,8 @@ access_keys: label: Update - id: customer.delete label: Delete + - id: customer.dpa + label: Display DPA - id: location diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index e27399e3..151f13fe 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -163,17 +163,22 @@ class ResqCustomerHandler implements CustomerHandlerInterface // add new customer and customer vehicle, if any public function addCustomer(Request $req) { - // create new row - $em = $this->em; - $row = new Customer(); - - $this->setObject($row, $req); - // initialize error lists $error_array = []; $nerror_array = []; $verror_array = []; + // create new row + $em = $this->em; + $row = new Customer(); + + // check if dpa consent is unticked + $is_dpa_checked = $req->request->get('flag_dpa_consent'); + if (!$is_dpa_checked) + $error_array['flag_dpa_consent'] = 'DPA consent should be checked.'; + + $this->setObject($row, $req); + // custom validation for vehicles $vehicles = json_decode($req->request->get('vehicles')); @@ -325,6 +330,11 @@ class ResqCustomerHandler implements CustomerHandlerInterface $nerror_array = []; $verror_array = []; + // check if dpa consent is unticked + $is_dpa_checked = $req->request->get('flag_dpa_consent'); + if (!$is_dpa_checked) + $error_array['flag_dpa_consent'] = 'DPA consent should be checked.'; + // TODO: validate mobile numbers // TODO: validate vehicles diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index cb07b5a3..7adcf52c 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -122,9 +122,11 @@
- - - + {% if is_granted('customer.dpa') %} + + + + {% endif %}
From bbebdb04c8bf16805b36d6f079a77154365543ae Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 15 May 2020 09:24:31 +0000 Subject: [PATCH 2/2] Add checking for email address if email checkbox is checked. #408 --- .../CustomerHandler/ResqCustomerHandler.php | 19 +++++++++++++++++++ templates/customer/form.html.twig | 1 + 2 files changed, 20 insertions(+) diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index 151f13fe..0618a4ed 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -177,6 +177,15 @@ class ResqCustomerHandler implements CustomerHandlerInterface if (!$is_dpa_checked) $error_array['flag_dpa_consent'] = 'DPA consent should be checked.'; + // check if email marketing promo is checked + $is_email_promo_checked = $req->request->get('flag_promo_email'); + if ($is_email_promo_checked) + { + // check email field + if (empty($req->request->get('email'))) + $error_array['email'] = 'Email address required.'; + } + $this->setObject($row, $req); // custom validation for vehicles @@ -335,6 +344,16 @@ class ResqCustomerHandler implements CustomerHandlerInterface if (!$is_dpa_checked) $error_array['flag_dpa_consent'] = 'DPA consent should be checked.'; + // check if email marketing promo is checked + $is_email_promo_checked = $req->request->get('flag_promo_email'); + if ($is_email_promo_checked) + { + // check email field + if (empty($req->request->get('email'))) + $error_array['email'] = 'Email address required.'; + } + + // TODO: validate mobile numbers // TODO: validate vehicles diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index 7adcf52c..97b80884 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -80,6 +80,7 @@ E-mail +