/**
  * check customer registration and carry on the registration process if it is not completed 
  *
  * Returns True if valid, false otherwise.
  *
  * @param string $email_address
  *
  * @return int
  */
 public function checkRegister($refno, $email, $isChangeEmail)
 {
     (string) ($refno = preg_replace('/X/', '', $refno));
     $customermgr = new Manager_Core_Customer();
     $customer = $customermgr->getCustomerByEmailAddress($email);
     $params = Zend_Registry::get('params');
     $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false);
     $digest = $mac->generate(array('email' => $email));
     $activationLink = 'refno=' . $refno . '&' . 'email=' . $email . '&' . 'mac=' . $digest;
     $customerMap = new Datasource_Core_CustomerMaps();
     if ($customer) {
         if (!$customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $refno)) {
             $customermgr->linkLegacyToNew($refno, $customer->getIdentifier(Model_Core_Customer::IDENTIFIER));
         }
         if (!$customer->getEmailValidated()) {
             $mail = new Application_Core_Mail();
             $mail->setTo($email, null);
             $mail->setFrom('*****@*****.**', 'HomeLet');
             $mail->setSubject('My HomeLet account validation');
             $mail->applyTemplate('core/account-validation', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $customer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
             $mail->applyTextTemplate('core/account-validationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $customer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
             // Send email
             $mail->send();
             return 1;
         } else {
             return 0;
         }
     } else {
         if ($isChangeEmail) {
             $cMap = $customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $refno);
             if ($cMap) {
                 $customer = $customermgr->getCustomer(Model_Core_Customer::IDENTIFIER, $cMap->getIdentifier());
                 $customer->setEmailAddress($email);
                 $customermgr->updateCustomer($customer);
                 $legacyids = $customerMap->getLegacyIDs($customer->getIdentifier());
                 foreach ($legacyids as $legacyid) {
                     if ($legacyid != $refno) {
                         $customer = $customermgr->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyid);
                         $customer->setEmailAddress($email);
                         $customermgr->updateCustomer($customer);
                     }
                 }
                 return 0;
             }
         }
         $oldCustomer = $customermgr->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $refno);
         $mail = new Application_Core_Mail();
         $mail->setTo($email, null);
         $mail->setFrom('*****@*****.**', 'HomeLet');
         $mail->setSubject("Don't forget to register your My HomeLet account");
         $mail->applyTemplate('core/partial-registration', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $oldCustomer->getFirstName(), 'templateId' => 'HL2469 12-12', 'heading' => 'Get even more with your My HomeLet account', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
         $mail->applyTextTemplate('core/partial-registrationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $oldCustomer->getFirstName(), 'templateId' => 'HL2469 12-12', 'heading' => 'Get even more with your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
         // Send email
         $mail->send();
         return 2;
     }
 }
예제 #2
0
 /**
  * Retrieves the specified customer record, encapsulates the details in a
  * Customer object and returns this.
  *
  * @param $identifier
  * @return param $identifier
  * Identifies the customer record in the customers table.
  *
  * @return \param The customer details encapsulated in a Customer object.
  */
 public function getCustomer($identifier)
 {
     //Retrieve the customer record.
     $select = $this->select();
     $select->where('id = ?', $identifier);
     $customerRow = $this->fetchRow($select);
     if ($customerRow) {
         //Populate the details into a Customer object.
         $customer = new Model_Core_Customer();
         $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $identifier);
         $customerMaps = new Datasource_Core_CustomerMaps();
         $customerMap = $customerMaps->getMap(Model_Core_Customer::IDENTIFIER, $identifier);
         if ($customerMap) {
             $customer->setIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $customerMap->getLegacyIdentifier());
         }
         $customer->setTitle($customerRow->title);
         $customer->setFirstName($customerRow->first_name);
         $customer->setLastName($customerRow->last_name);
         $customer->setLandlordName($customerRow->landname);
         $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, $customerRow->address1);
         $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $customerRow->address2);
         $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $customerRow->address3);
         $customer->setPostCode($customerRow->postcode);
         $customer->setCountry($customerRow->country);
         if ($customerRow->foreign_address == 0) {
             $customer->setIsForeignAddress(false);
         } else {
             $customer->setIsForeignAddress(true);
         }
         $customer->setTelephone(Model_Core_Customer::TELEPHONE1, $customerRow->telephone1);
         $customer->setTelephone(Model_Core_Customer::TELEPHONE2, $customerRow->telephone2);
         $customer->setEmailAddress($customerRow->email_address);
         $customer->setPassword($customerRow->password);
         $customer->setOccupation($customerRow->occupation);
         $customer->setEmailValidated($customerRow->email_validated == 1 ? true : false);
         $customer->setAccountLoadComplete($customerRow->account_load_complete == 1 ? true : false);
         $customerTypeName = array_search($customerRow->type_id, $this->_legacyTypeMap);
         if ($customerTypeName !== false) {
             $customer->typeID = $customerTypeName;
         }
         return $customer;
     } else {
         return null;
     }
 }
 /**
  * Retrieves the specified customer record, encapsulates the details in a
  * Customer object and returns this.
  *
  * @param string $identifier
  * Identifies the customer record in the legacy customer table.
  *
  * @return Model_Core_Customer
  * The customer details encapsulated in a Customer object.#5 /home/benjamin.vickers/HomeLet-Framework/src/application/models/datasources/Core/LegacyCustomers.php(209): Zend_Db_Table_Abstract->fetchRow(Object(Zend_Db_Table_Select))
  *
  * @throws Zend_Exception
  * Throws a Zend_Exception if the customer record cannot be found.
  */
 public function getCustomer($identifier)
 {
     //Retrieve the customer record.
     $select = $this->select();
     $select->where('refno = ?', $identifier);
     $customerRow = $this->fetchRow($select);
     if (empty($customerRow)) {
         throw new Zend_Exception('Customer not found.');
     }
     //Populate the details into a Customer object.
     $customer = new Model_Core_Customer();
     $customer->setIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $identifier);
     $customerMaps = new Datasource_Core_CustomerMaps();
     $customerMap = $customerMaps->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $identifier);
     if ($customerMap) {
         $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $customerMap->getIdentifier());
     }
     $customer->setTitle($customerRow->title);
     $customer->setFirstName($customerRow->firstname);
     $customer->setLastName($customerRow->lastname);
     $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, $customerRow->personaladdress1);
     $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $customerRow->personaladdress3);
     $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $customerRow->personaladdress5);
     $customer->setPostCode($customerRow->personalpostcode);
     $customer->setCountry($customerRow->country);
     if ($customerRow->isForeignAddress == 'no') {
         $customer->setIsForeignAddress(false);
     } else {
         $customer->setIsForeignAddress(true);
     }
     $customer->setTelephone(Model_Core_Customer::TELEPHONE1, $customerRow->phone1);
     $customer->setTelephone(Model_Core_Customer::TELEPHONE2, $customerRow->phone2);
     $customer->setFax($customerRow->fax);
     $customer->setEmailAddress($customerRow->email);
     $customer->setPassword($customerRow->password);
     $customer->setOccupation($customerRow->occupation);
     $customer->setDateOfBirthAt($customerRow->date_of_birth_at);
     $customer->typeID = 2;
     // Default to a tenant
     return $customer;
 }
 /**
  * Policy list action 
  * 
  * @return void
  */
 public function policiesAction()
 {
     $this->_setMetaTitle('My HomeLet | Policies');
     $this->_setBreadcrumbs(array('/' => 'Home', '/my-homelet' => 'My HomeLet', '/my-homelet/policies' => 'My Policies'));
     $request = $this->getRequest();
     // Get the customer session
     $customerSession = $this->auth->getStorage()->read();
     // Search and ordering
     $filteredOrderBy = array();
     $orderBy = $request->getParam('order');
     $quoteNumberSearch = $request->getParam('id');
     // Validate order by to restricted fields to those displayed on the front end
     if (is_array($orderBy)) {
         foreach ($orderBy as $orderByField => $orderByDirection) {
             if (in_array($orderByField, array('policynumber', 'policyname', 'startdate', 'premium', 'renewaldate', 'paystatus'))) {
                 // Copy field into new array
                 $filteredOrderBy[$orderByField] = $orderByDirection;
             }
         }
     }
     // Get list of linked customer reference numbers
     $policyCoverDatasource = new Datasource_Insurance_LegacyPolicyCovers();
     $legacyCustomerMap = new Datasource_Core_CustomerMaps();
     $legacyIDs = $legacyCustomerMap->getLegacyIDs($customerSession->id);
     // Retrieve all quotes for the linked customer reference numbers
     $quoteDatasource = new Datasource_Insurance_LegacyPolicies();
     $policies = $quoteDatasource->getActivePolicies($legacyIDs, $quoteNumberSearch, $filteredOrderBy);
     // Build the list of policy covers.
     // Should be done in a manager, but the quote manager has been written with the row data gateway
     // design pattern in mind.
     foreach ($policies as $policy) {
         // Create list of policy covers
         $policyCoverList = array();
         $policyOptionsplit = explode('|', $policy->policyOptions);
         $sumInsuredSplit = explode('|', $policy->amountsCovered);
         for ($i = 0; $i < count($policyOptionsplit); $i++) {
             if ($sumInsuredSplit[$i] == 'yes' || floatval($sumInsuredSplit[$i]) > 0) {
                 // A sum insured value has been set so assume cover is in force
                 $policyCover = $policyCoverDatasource->getPolicyCoverByLabel($policyOptionsplit[$i]);
                 if ($policyCover) {
                     array_push($policyCoverList, $policyCover->getName());
                 }
             }
         }
         $policy->policyCovers = $policyCoverList;
     }
     $this->view->policies = $policies;
 }
 /**
  * Display a list of quotes that can be retrieved after a user has identified themselves with an auth token via
  * retrieveQuoteAction().  Having this separate action allows an end user to press "Back" for up to an hour if they
  * have chosen to continue the wrong quote.
  *
  * @return void
  */
 public function retrieveMultipleQuotesAction()
 {
     if ($this->getRequest()->getParam('auth') != '') {
         $params = Zend_Registry::get('params');
         $mac = $this->getRequest()->getParam('auth');
         $securityManager = new Application_Core_Security($params->myhomelet->retrieveWithoutAccount->macSecret, $params->myhomelet->retrieveWithoutAccount->macTimestampVariance != 0, $params->myhomelet->retrieveWithoutAccount->macTimestampVariance);
         $dataKeys = array('customerEmail');
         $securityCheck = $securityManager->authenticate($mac, $dataKeys);
         if (isset($securityCheck['result']) && $securityCheck['result']) {
             // Customer has multiple quotes associated with their email address - look them up and generate a set of
             // auth tokens, show user the selection
             $email = $securityCheck['data']['customerEmail'];
             $policyCoverDatasource = new Datasource_Insurance_LegacyPolicyCovers();
             $customerManager = new Manager_Core_Customer();
             // Get all legacy quote IDs by customer e-mail address
             $legacyIDs = array();
             // Try to look up a customer record's quotes' IDs by the e-mail provided
             $newCustomer = $customerManager->getCustomerByEmailAddress($email);
             if ($newCustomer) {
                 $legacyCustomerMap = new Datasource_Core_CustomerMaps();
                 $legacyIDs = $legacyCustomerMap->getLegacyIDs($newCustomer->getIdentifier(Model_Core_Customer::IDENTIFIER));
             }
             // Also check in the legacy DB only to ensure landlords quotes are found
             $customer = $customerManager->getLegacyCustomerByEmailAddress($email);
             if ($customer) {
                 $legacyCustomerId = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER);
                 if (!in_array($legacyCustomerId, $legacyIDs)) {
                     $legacyIDs[] = $legacyCustomerId;
                 }
             }
             // Retrieve all quotes for the linked customer reference numbers
             $quoteDatasource = new Datasource_Insurance_LegacyQuotes();
             $quotes = $quoteDatasource->getActiveQuotes($legacyIDs, '', array('policynumber', 'startdate'));
             // Build the list of policy covers and generate auth tokens for each policy
             // Should be done in a manager, but the quote manager has been written with the row data gateway
             // design pattern in mind.
             $authTokens = array();
             foreach ($quotes as $quote) {
                 // Create list of policy covers
                 $policyCoverList = array();
                 $policyOptionsplit = explode('|', $quote->policyOptions);
                 $sumInsuredSplit = explode('|', $quote->amountsCovered);
                 for ($i = 0; $i < count($policyOptionsplit); $i++) {
                     if ($sumInsuredSplit[$i] == 'yes' || floatval($sumInsuredSplit[$i]) > 0) {
                         // A sum insured value has been set so assume cover is in force
                         $policyCover = $policyCoverDatasource->getPolicyCoverByLabel($policyOptionsplit[$i]);
                         if ($policyCover) {
                             array_push($policyCoverList, array('cover' => $policyOptionsplit[$i], 'name' => $policyCover->getName()));
                         }
                     }
                 }
                 $quote->policyCovers = $policyCoverList;
                 // Generate a policy-specific authentication token
                 $securityManager = new Application_Core_Security($params->myhomelet->retrieveWithoutAccount->macSecret, $params->myhomelet->retrieveWithoutAccount->macTimestampVariance != 0, $params->myhomelet->retrieveWithoutAccount->macTimestampVariance);
                 $securityData = array('quoteNumber' => $quote->policyNumber);
                 $authTokens[$quote->policyNumber] = $securityManager->generate($securityData);
             }
             // Pass quotes and auth tokens into view and finish
             $this->view->quotes = $quotes;
             $this->view->authTokens = $authTokens;
             return;
         }
     }
     // Failover for non-auth or other issue - go to main retrieve quote form
     $this->_helper->redirector->gotoUrl('/my-homelet/retrieve-quote');
 }
 /**
  * Resume an existing quote for authenticated customers. Customers
  * who are not authenticated are redirected to the login page.
  *
  * @return void
  */
 public function retrieveAction()
 {
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     if ($auth->hasIdentity()) {
         // Check to see if we have a reference number to load up
         if ($this->getRequest()->getParam('quote') != '') {
             $quoteNumber = $this->getRequest()->getParam('quote');
             // Customer is logged in and is trying to retrieve a specific quote
             // We need to check to make sure they own it
             $customerID = $auth->getStorage()->read()->id;
             // Get customers legacy IDs and confirm the refno of the quote
             // can be accessed by the customer.
             $legacyCustomerMap = new Datasource_Core_CustomerMaps();
             $legacyIDs = $legacyCustomerMap->getLegacyIDs($customerID);
             $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $quoteNumber);
             $quote = $quoteManager->getQuoteObject();
             if (in_array($quote->refNo, $legacyIDs)) {
                 // This customer does own this reference - so set the page session stuff up and redirect
                 if ($quote->policyType == 'T') {
                     // Make sure this is a tenants quote
                     $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
                     $pageSession->CustomerRefNo = $quote->refNo;
                     $pageSession->PolicyNumber = $quote->policyNumber;
                     //Retrieve the WebLead summary ID so that the WebLead can continue to be updated and important
                     //details captured, such as the campaign code.
                     $webLeadManager = new Manager_Core_WebLead();
                     $pageSession->webLeadSummaryId = $webLeadManager->getSummaryId($pageSession->PolicyNumber);
                     $this->_helper->redirector->gotoUrl('/tenants/insurance-quote-b/step1');
                 } else {
                     // This isn't a tenants quote! OOPS
                     $this->render('retrieve-failed');
                     return;
                 }
             }
         }
     }
     $this->_helper->redirector->gotoUrl('/login?referrerUrl=/my-homelet/quotes');
 }
예제 #7
0
 public function createCustomerFromLegacy($emailAddress, $legacyIdentifier)
 {
     //Validate the data passed in.
     if (empty($emailAddress) || empty($legacyIdentifier)) {
         throw new Zend_Exception('Required parameters missing');
     }
     //Save the customer into the DataStore and LegacyDataStore. To do this
     //first obtain the email address, password, customer type (tenant, landlord,
     //agent) and an unused legacy identifier (customerRefno).
     $passwordUtil = new Application_Core_Password();
     $password = $passwordUtil->generate();
     //And create:
     $identifier = $this->_customerModel->insertCustomer($emailAddress, $password, Model_Core_Customer::CUSTOMER);
     //Next link the LegacyDataStore and the DataStore.
     $customerMap = new Datasource_Core_CustomerMaps();
     $customerMap->insertMap($legacyIdentifier, $identifier);
     //Finally, encapsulate the customer details in a Model_Insurance_Common_Customer_DomainObjects_Customer
     //object and return.
     $customer = new Model_Core_Customer();
     $customer->setIdentifier(Model_Core_Customer::IDENTIFIER, $identifier);
     $customer->setIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyIdentifier);
     $customer->setEmailAddress($emailAddress);
     $customer->setPassword($password);
     return $customer;
 }
 /**
  * Resume an existing quote for customers who either have a temporary auth token for a retrieval with no My HomeLet
  * account, or who are My HomeLet authenticated.  Customers with no form of valid authentication are redirected to
  * the My HomeLet login page.
  *
  * @return void
  */
 public function retrieveAction()
 {
     // Authorisation using no-account My HomeLet retrieval auth token
     if ($this->getRequest()->getParam('auth') != '') {
         $mac = $this->getRequest()->getParam('auth');
         $securityManager = new Application_Core_Security($this->_params->myhomelet->retrieveWithoutAccount->macSecret, $this->_params->myhomelet->retrieveWithoutAccount->macTimestampVariance != 0, $this->_params->myhomelet->retrieveWithoutAccount->macTimestampVariance);
         $dataKeys = array('quoteNumber');
         $securityCheck = $securityManager->authenticate($mac, $dataKeys);
         if (isset($securityCheck['result']) && $securityCheck['result']) {
             $quoteNumber = $securityCheck['data']['quoteNumber'];
             $quoteManager = new Manager_Insurance_LegacyQuote();
             $customerManager = new Manager_Core_Customer();
             $quote = $quoteManager->getQuoteByPolicyNumber($quoteNumber);
             $quoteRefNo = $quote->refNo;
             $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $quoteRefNo);
             $customerID = $referenceNumber = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER, $quoteRefNo);
             $quoteManager = new Manager_Insurance_LandlordsPlus_Quote(null, $quoteNumber, null, $customerID);
             $quote = $quoteManager->getModel();
             $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
             $pageSession->quoteID = $quote->ID;
             $pageSession->customerRefNo = $referenceNumber;
             //Retrieve the WebLead summary ID so that the WebLead can continue to be updated and important
             //details captured, such as the campaign code.
             $webLeadManager = new Manager_Core_WebLead();
             $pageSession->webLeadSummaryId = $webLeadManager->getSummaryId($quoteNumber);
             $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step1');
             return;
         }
     }
     // Authorisation using My HomeLet logged in details
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
     if ($auth->hasIdentity()) {
         // Check to see if we have a reference number to load up
         if ($this->getRequest()->getParam('quote') != '') {
             $quoteNumber = $this->getRequest()->getParam('quote');
             // Customer is logged in and is trying to retrieve a specific quote
             // We need to check to make sure they own it
             $customerID = $auth->getStorage()->read()->id;
             // Now we need to get their legacy ID
             $customerManager = new Manager_Core_Customer();
             $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $customerID);
             $referenceNumber = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER);
             // Need to find the quote ID by the policy number
             $quotes = new Manager_Insurance_LandlordsPlus_Quote(null, $quoteNumber, null, $customerID);
             $quote = $quotes->getModel();
             $legacyCustomerMap = new Datasource_Core_CustomerMaps();
             $legacyIDs = $legacyCustomerMap->getLegacyIDs($customerID);
             if (in_array($quote->legacyCustomerID, $legacyIDs)) {
                 // This customer does own this reference - so set the page session stuff up and redirect
                 $pageSession = new Zend_Session_Namespace('landlords_insurance_quote');
                 $pageSession->quoteID = $quote->ID;
                 $pageSession->customerRefNo = $referenceNumber;
                 //Retrieve the WebLead summary ID so that the WebLead can continue to be updated and important
                 //details captured, such as the campaign code.
                 $webLeadManager = new Manager_Core_WebLead();
                 $pageSession->webLeadSummaryId = $webLeadManager->getSummaryId($quoteNumber);
                 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step1');
             }
         }
     }
     $this->_helper->redirector->gotoUrl('/login?referrerUrl=/my-homelet/quotes');
 }
 /**
  * Login form for existing customers
  *
  * @return void
  */
 public function loginAction()
 {
     $form = new TenantsInsuranceQuote_Form_Login();
     $request = $this->getRequest();
     $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
     $pageForm = new TenantsInsuranceQuote_Form_Step1();
     $pageForm->populate($pageSession->step1FormValues);
     $subFormPersonalDetails = $pageForm->getSubForm('subform_personaldetails');
     $form->getElement('email')->setValue($subFormPersonalDetails->getElement('email_address')->getValue());
     // Look up customer details if possible, note if the customer has already validated their My HomeLet account
     $customerValidated = false;
     $customerFirstName = '';
     $customerManager = new Manager_Core_Customer();
     $customer = $customerManager->getCustomerByEmailAddress($form->getElement('email')->getValue('email'));
     if ($customer) {
         $customerValidated = $customer->getEmailValidated();
         $customerFirstName = $customer->getFirstName();
     }
     if ($request->isPost()) {
         if (isset($_POST['resendValidation'])) {
             // User wants a new validation link
             if ($customer) {
                 $customer->sendAccountValidationEmail();
                 $form->setDescription('Thank you, we&rsquo;ve sent you an email to validate your My HomeLet account, please make sure you check your inbox and your junk folder just in case.');
             } else {
                 $form->setDescription('Sorry, we could not find a customer with that email address. Please check the details you entered are correct and try again.');
             }
         } else {
             if (isset($_POST['forgottenPassword'])) {
                 // User has forgotten password
                 if ($customer) {
                     $customer->resetPassword();
                     $customerManager->updateCustomer($customer);
                     $newPassword = $customer->getPassword();
                     $customerID = $customer->getIdentifier(Model_Core_Customer::IDENTIFIER);
                     // Now we have a new customer password - we also (sadly) need to update ALL the linked legacy customer entries
                     // or next time an old quote is opened it over-writes this new password (you couldn't make this stuff up!)
                     $legacyCustomerMap = new Datasource_Core_CustomerMaps();
                     $legacyIDs = $legacyCustomerMap->getLegacyIDs($customerID);
                     foreach ($legacyIDs as $legacyID) {
                         $oldCustomer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyID);
                         $oldCustomer->setPassword($newPassword);
                         $customerManager->updateLegacyCustomer($oldCustomer);
                     }
                     // That's hopefully done it so we can show a nice message
                     $form->setDescription('Thank you, we&rsquo;ve sent you an email to reset your password, please make sure you check your inbox and your junk folder just in case.');
                 } else {
                     $form->setDescription('Sorry, we could not find a customer with that email address. Please check the details you entered are correct and try again.');
                 }
             } else {
                 if ($form->isValid($_POST)) {
                     // Save step1 form data and move to step 2
                     // Null off all reference numbers that may have been set via a new customer who has gone
                     // back and used an existing customer email address.
                     // Only do this if the user is has not retrieved a quote - if they have we want them to edit the same
                     // one that was fetched.
                     if (!isset($pageSession->RetrievedQuote) || !$pageSession->RetrievedQuote) {
                         $this->_customerReferenceNumber = null;
                         $pageSession->CustomerRefNo = null;
                         $this->_policyNumber = null;
                         $pageSession->PolicyNumber = null;
                         $this->_webLeadSummaryId = null;
                         $pageSession->webLeadSummaryId = null;
                     }
                     $this->saveStep1($pageForm);
                     $this->_helper->redirector->gotoUrl('/tenants/insurance-quote/step2');
                 } else {
                     $form->setDescription('Sorry, we could not log you in with the details given. Please check the details you entered are correct and try again.');
                 }
             }
         }
     }
     $this->view->form = $form;
     $this->view->customerValidated = $customerValidated;
     $this->view->customerFirstName = $customerFirstName;
 }
 /**
  * Retrieve the document
  *
  * @param string $policyNumber Policy number
  * @param string $documentId Unique document request hash
  * @return string null or PDF contents
  */
 private function _fetchDocument($policyNumber, $documentId)
 {
     // Get the customer session
     $customerSession = $this->auth->getStorage()->read();
     // Get the request policy
     if ($policyNumber[0] == 'Q') {
         // Quotes
         $legacyPolicies = new Datasource_Insurance_LegacyQuotes();
     } else {
         // Policies
         $legacyPolicies = new Datasource_Insurance_LegacyPolicies();
     }
     $policy = $legacyPolicies->getByPolicyNumber($policyNumber);
     if (!$policy) {
         return null;
     }
     // Check the policy customer refno is linked to the customer id through mapping
     $customerMaps = new Datasource_Core_CustomerMaps();
     $customerMap = $customerMaps->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $policy->refNo);
     // Confirm the policy number belongs to the logged in customer
     if ($customerMap == false || $customerMap->getIdentifier() != $customerSession->id) {
         // Customer map not found or customer is not mapped to refno, render error message
         return null;
     }
     // Get all document details
     $documentHistory = new Datasource_Insurance_DocumentHistory();
     $document = $documentHistory->getDocument($documentId, $policyNumber);
     if (!$document) {
         return null;
     }
     // Retrieve document from store
     $documentFulfillmentService = new Service_Insurance_Document();
     return $documentFulfillmentService->retrieveDocumentFromStore($documentId, $document->template_name, Service_Insurance_Document::DOCUMENT_AND_ATTACHMENTS);
 }