From af85a632e5a531090d94cfac1e712e197f4faa2f Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 15 May 2020 08:48:58 +0000 Subject: [PATCH] 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 %}