Merge branch '408-resq-additional-dpa-behavior' into 'master'

Resolve "Resq - additional dpa behavior"

Closes #408

See merge request jankstudio/resq!471
This commit is contained in:
Kendrick Chan 2020-05-21 01:50:57 +00:00
commit 2aa6d417b7
3 changed files with 43 additions and 9 deletions

View file

@ -156,6 +156,8 @@ access_keys:
label: Update
- id: customer.delete
label: Delete
- id: customer.dpa
label: Display DPA
- id: location

View file

@ -163,17 +163,31 @@ 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.';
// 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
$vehicles = json_decode($req->request->get('vehicles'));
@ -325,6 +339,21 @@ 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.';
// 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

View file

@ -80,6 +80,7 @@
E-mail
</label>
<input type="text" name="email" class="form-control m-input" value="{{ obj.getEmail }}" data-name="email">
<div class="form-control-feedback hide" data-field="email"></div>
</div>
</div>
<div class="form-group m-form__group row">
@ -122,9 +123,11 @@
</div>
</div>
<div class="col-lg-4">
<input type="checkbox" name="flag_dpa_consent" id="flag-dpa_consent" value="1"{{ obj.isDpaConsent ? ' checked' }} >
<label class="switch-label">With DPA Consent</label>
<div class="form-control-feedback hide" data-field="flag_dpa_consent"></div>
{% if is_granted('customer.dpa') %}
<input type="checkbox" name="flag_dpa_consent" id="flag-dpa_consent" value="1"{{ obj.isDpaConsent ? ' checked' }} >
<label class="switch-label">With DPA Consent</label>
<div class="form-control-feedback hide" data-field="flag_dpa_consent"></div>
{% endif %}
</div>
</div>
<div class="form-group m-form__group row">