示例#1
0
 /**
  * Saves the form data to the datastore.
  * 
  * @return void
  */
 public function saveData()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $data = $this->getValues();
     // Create the new customer in the legacy datasource only.
     $customerManager = new Manager_Core_Customer();
     $customer = $customerManager->createNewCustomer($data['email'], Model_Core_Customer::CUSTOMER);
     // Update the newly created customer with values submitted on the registration form.
     //$customer->setTitle($data['personal_title']);
     $customer->setTitle($data['title']);
     $customer->setFirstName($data['first_name']);
     $customer->setLastName($data['last_name']);
     $customer->setTelephone(Model_Core_Customer::TELEPHONE1, $data['phone_number']);
     $customer->setTelephone(Model_Core_Customer::TELEPHONE2, $data['mobile_number']);
     $customer->setFax($data['fax_number']);
     $customer->setEmailAddress($data['email']);
     $customer->setPassword($data['password']);
     $customer->setSecurityQuestion($data['security_question']);
     $customer->setSecurityAnswer($data['security_answer']);
     //Address update
     $postcode = new Manager_Core_Postcode();
     $propertyAddress = $postcode->getPropertyByID($data['property_address'], false);
     $addressLine1 = ($propertyAddress['organisation'] != '' ? "{$propertyAddress['organisation']}, " : '') . ($propertyAddress['houseNumber'] != '' ? "{$propertyAddress['houseNumber']} " : '') . ($propertyAddress['buildingName'] != '' ? "{$propertyAddress['buildingName']}, " : '') . $propertyAddress['address2'];
     $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, $addressLine1);
     $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $propertyAddress['address4']);
     $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $propertyAddress['address5']);
     $customer->setPostCode($data['property_postcode']);
     $customer->typeID = Model_Core_Customer::CUSTOMER;
     // Update the customer record
     $customerManager->updateCustomer($customer);
     //		// Log the customer in automatically
     //        $auth = Zend_Auth::getInstance();
     //        $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     //        $customerManager = new Manager_Core_Customer();
     //        $adapter = $customerManager->getAuthAdapter(array('email' => $data['email'], 'password' => $data['password']));
     //        $auth->authenticate($adapter);
     //        // Writer customer data to session
     //        $storage = $auth->getStorage();
     //        $storage->write($adapter->getResultRowObject(array(
     //            'title',
     //            'first_name',
     //            'last_name',
     //            'email_address',
     //            'id')));
     //Finally, set the necessary session variables.
     $session->awaitingvalidation = 1;
     $session->customerId = $customer->getIdentifier(Model_Core_Customer::IDENTIFIER);
     // Save dpa preferences for direct landlord to insurance dpa system - direct landlords save their customer records to insurance
     $dpaManager = new Manager_Core_DataProtection();
     $item = new Model_Core_DataProtection_Item();
     $item->itemGroupId = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER);
     $item->entityTypeId = Model_Core_DataProtection_ItemEntityTypes::INSURANCE;
     // Phone and post
     $item->constraintTypeId = Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_PHONEANDPOST;
     $item->isAllowed = $data['subform_dataprotection']['dpa_phone_post'] == 1 ? true : false;
     $dpaManager->upsertItem($item);
     // Sms and email
     $item->constraintTypeId = Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_SMSANDEMAIL;
     $item->isAllowed = $data['subform_dataprotection']['dpa_sms_email'] == 1 ? true : false;
     $dpaManager->upsertItem($item);
     // Third party sale
     $item->constraintTypeId = Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_THIRDPARTY;
     $item->isAllowed = $data['subform_dataprotection']['dpa_resale'] == 1 ? true : false;
     $dpaManager->upsertItem($item);
     // Save insurance renewal mi data, if provided
     if ($this->getElement('insurance_renewal_date')->getValue() != '') {
         $renewalDate = new Zend_Date($this->getElement('insurance_renewal_date')->getValue(), Zend_Date::DAY . '/' . Zend_Date::MONTH . '/' . Zend_Date::YEAR);
         $miInsuranceRenewalDataSource = new Datasource_Referencing_MiInsuranceRenewal();
         $miInsuranceRenewalDataSource->insertMiData($customer->getIdentifier(Model_Core_Customer::IDENTIFIER), $renewalDate);
     }
     // Create sign-up completion email
     $customer->sendAccountValidationEmail();
 }
 /**
  * Saves the TCI+ data protection values specified by the user.
  *
  * @param mixed $itemGroupId
  * The WebLead identifier.
  *
  * @param integer $phonePost
  * Indicates whether the user wants marketing by phone/post. Should be taken directly from
  * the user interface without modification.
  *
  * @param integer $smsEmail
  * Indicates whether the user wants marketing by sms/email. Should be taken directly from
  * the user interface without modification.
  *
  * @param integer $thirdParty
  * Indicates whether the user wants marketing by third parties. Should be taken directly from
  * the user interface without modification.
  *
  * @return void
  */
 protected function _saveWebLeadDPA($itemGroupId, $phonePost, $smsEmail, $thirdParty)
 {
     //Capture and store the data protections.
     $dpaList = array();
     //Capture and translate the details of the dpa item - marketing by phone and post.
     $dpaItem = new Model_Core_DataProtection_Item();
     $dpaItem->itemGroupId = $itemGroupId;
     $dpaItem->entityTypeId = Model_Core_DataProtection_ItemEntityTypes::WEBLEAD;
     $dpaItem->constraintTypeId = Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_PHONEANDPOST;
     if ($phonePost == 1) {
         $dpaItem->isAllowed = false;
     } else {
         $dpaItem->isAllowed = true;
     }
     array_push($dpaList, $dpaItem);
     //Capture and translate the details of dpa item - marketing by sms and email.
     $dpaItem = new Model_Core_DataProtection_Item();
     $dpaItem->itemGroupId = $itemGroupId;
     $dpaItem->entityTypeId = Model_Core_DataProtection_ItemEntityTypes::WEBLEAD;
     $dpaItem->constraintTypeId = Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_SMSANDEMAIL;
     if ($smsEmail == 1) {
         $dpaItem->isAllowed = true;
     } else {
         $dpaItem->isAllowed = false;
     }
     array_push($dpaList, $dpaItem);
     //Capture and translate the details of dpa item - third party details resale.
     $dpaItem = new Model_Core_DataProtection_Item();
     $dpaItem->itemGroupId = $itemGroupId;
     $dpaItem->entityTypeId = Model_Core_DataProtection_ItemEntityTypes::WEBLEAD;
     $dpaItem->constraintTypeId = Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_THIRDPARTY;
     if ($thirdParty == 1) {
         $dpaItem->isAllowed = true;
     } else {
         $dpaItem->isAllowed = false;
     }
     array_push($dpaList, $dpaItem);
     //Store the data protections.
     $dpaManager = new Manager_Core_DataProtection(Manager_Core_DataProtection::USE_DBASE);
     foreach ($dpaList as $currentItem) {
         $dpaManager->upsertItem($currentItem);
     }
 }
 protected function _storeDataProtections()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $request = $this->getRequest();
     $data = $request->getPost();
     //Capture and store the data protections.
     $dpaList = array();
     //Capture and translate the details of the dpa item - non-digital marketing.
     $dpaItem = new Model_Core_DataProtection_Item();
     $dpaItem->itemGroupId = $session->referenceId;
     $dpaItem->entityTypeId = Model_Core_DataProtection_ItemEntityTypes::REFERENCING;
     $dpaItem->constraintTypeId = Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_NONDIGITAL_MEANS;
     if ($data['consent_nondigital_marketing'] == 1) {
         $dpaItem->isAllowed = true;
     } else {
         $dpaItem->isAllowed = false;
     }
     // If this is version 3 of the terms, invert the preference
     if (3 == $this->_getDeclarationVersion()) {
         $dpaItem->isAllowed = !$dpaItem->isAllowed;
     }
     array_push($dpaList, $dpaItem);
     //Capture and translate the details of dpa item - marketing by sms and email.
     $dpaItem = new Model_Core_DataProtection_Item();
     $dpaItem->itemGroupId = $session->referenceId;
     $dpaItem->entityTypeId = Model_Core_DataProtection_ItemEntityTypes::REFERENCING;
     $dpaItem->constraintTypeId = Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_DIGITAL_MEANS;
     if ($data['consent_digital_marketing'] == 1) {
         $dpaItem->isAllowed = true;
     } else {
         $dpaItem->isAllowed = false;
     }
     array_push($dpaList, $dpaItem);
     //Data protections stored directly without being attached to the Reference object.
     //This should be refactored so that that data protections are stored in their
     //own object which is linked from the Reference object.
     $dpaManager = new Manager_Core_DataProtection(Manager_Core_DataProtection::USE_DBASE);
     foreach ($dpaList as $currentItem) {
         $dpaManager->upsertItem($currentItem);
     }
 }