diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 2a476dce..63691592 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -395,6 +395,17 @@ class APIController extends Controller // update mobile phone of customer $cust->setPhoneMobile(substr($this->session->getPhoneNumber(), 2)); + // get privacy policy for mobile + $policy = $em->createQuery('SELECT policy FROM App\Entity\PrivacyPolicy policy WHERE policy.name LIKE :policy_type') + ->setParameter('policy_type', "%" . "mobile" . "%") + ->getOneOrNullResult(); + + // set policy id + if ($policy != null) + { + $cust->setPrivacyPolicyMobile($policy); + } + $em->flush(); return $res->getReturnResponse(); @@ -1787,9 +1798,40 @@ class APIController extends Controller // set privacy settings $priv_promo = $req->request->get('priv_promo', false); - $cust->setPrivacyThirdParty($req->request->get('priv_third_party')) + $priv_third_party = $req->request->get('priv_third_party'); + $cust->setPrivacyThirdParty($priv_third_party) ->setPrivacyPromo($priv_promo); + // check if privacy settings are true + // if true, set the private policy for the customer + if ($priv_promo) + { + // find the promo policy + $policy = $em->createQuery('SELECT policy FROM App\Entity\PrivacyPolicy policy WHERE policy.name LIKE :policy_type') + ->setParameter('policy_type', "%" . "promo" . "%") + ->getOneOrNullResult(); + + // set policy id + if ($policy != null) + { + $cust->setPrivacyPolicyPromo($policy); + } + } + + if ($priv_third_party) + { + // find the third party policy + $policy = $em->createQuery('SELECT policy FROM App\Entity\PrivacyPolicy policy WHERE policy.name LIKE :policy_type') + ->setParameter('policy_type', "%" . "third party" . "%") + ->getOneOrNullResult(); + + // set policy id + if ($policy != null) + { + $cust->setPrivacyPolicyThirdParty($policy); + } + } + $em->flush(); return $res->getReturnResponse();