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 @@