/** * 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'); }