Exemple #1
0
 /**
  * This will convert all the new data into the old lagacy tables
  * @param
  * @return
  * @author John Burrin
  * @since 1.3
  *
  * Munten ergo sum
  */
 public function convertLegacy($refNo)
 {
     // fetch quote premiums
     $premiums = $this->quote($refNo);
     // Fetch the Landlords details
     $landlord = new Manager_Insurance_Portfolio_LegacyCustomer();
     $landlordDetails = $landlord->fetchByRefNo($refNo);
     // Fetch all the properties
     $propertyManager = new Manager_Insurance_Portfolio_Property();
     $propertyObject = new Model_Insurance_Portfolio_Property();
     $propertyObject = $propertyManager->fetchAllProperties($refNo);
     // populate the legacy portfoliostat table
     $legacyPortfolioStat = new Model_Insurance_Portfolio_LegacyPortfolio();
     $legacyPortfolioStat->agentSchemeNo = 1403796;
     // $legacyPortfolioStat->csuId = "";
     $legacyPortfolioStat->customerRefNo = "";
     $legacyPortfolioStat->date = date("Y-m-d");
     $legacyPortfolioStat->email = $landlordDetails['email_address'];
     $legacyPortfolioStat->heardFrom = "";
     $legacyPortfolioStat->hpc = "";
     $legacyPortfolioStat->name = $landlordDetails['first_name'] . " " . $landlordDetails['last_name'];
     $legacyPortfolioStat->numOfHouse = count($propertyObject);
     $legacyPortfolioStat->policyNumber = "";
     $legacyPortfolioStat->quote = $premiums['premiums']['UserQuoteAnnualPremium'];
     $legacyPortfolioStat->referred = "";
     $legacyPortfolioStat->refNo = $refNo;
     $legacyPortfolioStat->telephone = $landlordDetails['telephone1'];
     // Set up datasources to the risk areas
     $dsBuildingsRiskArea = new Datasource_Insurance_RiskAreas_Buildings();
     $dsContentsRiskArea = new Datasource_Insurance_RiskAreas_LandlordsContents();
     //Save the portfoliostat data
     $legacyPortfolioManager = new Manager_Insurance_Portfolio_LegacyPortfolio();
     $legacyPortfolioManager->save($legacyPortfolioStat);
     $idd = new Datasource_Insurance_IddSupport();
     if (!$idd->isIddSupport($legacyPortfolioStat->refNo)) {
         $inserArray = array();
         $insertArray['policynumber'] = $legacyPortfolioStat->refNo;
         $insertArray['agentschemeno'] = $legacyPortfolioStat->agentSchemeNo;
         $insertArray['csuid'] = 0;
         $fsaAgentStatusDatasource = new Datasource_Fsa_AgentStatus();
         $fsaStatus = $fsaAgentStatusDatasource->getAgentFsaStatus($legacyPortfolioStat->agentSchemeNo);
         if (isset($fsaStatus['status_abbr'])) {
             $insertArray['FSA_status'] = $fsaStatus['status_abbr'];
         } else {
             $insertArray['FSA_status'] = "";
         }
         $insertArray['origsaleid'] = 9;
         $insertArray['callerid'] = 2;
         $idd->setIddSupport($insertArray);
     }
     // Setup an agent manager
     $agent = new Manager_Core_Agent();
     // get polict options
     $ds_rates = new Datasource_Insurance_Portfolio_PortfolioRates();
     $rates = $ds_rates->fetchRates();
     $optionsString = $this->_getPolicyOptions();
     // Save the property data into the legacy portfolio table
     $legacyPropertyManager = new Manager_Insurance_Portfolio_LegacyProperty();
     foreach ($propertyObject as $property) {
         // Create a new Model_Insurance_Portfolio_LegacyProperty Object
         $legacyPropertyObject = new Model_Insurance_Portfolio_LegacyProperty();
         $legacyPropertyObject->amountsCovered = $this->_getAmountsCovered($property);
         $legacyPropertyObject->discount = "";
         $legacyPropertyObject->excessId = "";
         $legacyPropertyObject->ipt = "";
         $legacyPropertyObject->optionDiscounts = "";
         $legacyPropertyObject->optionPremiums = "";
         $legacyPropertyObject->policyNumber = $refNo;
         $legacyPropertyObject->policyOptions = $optionsString;
         $legacyPropertyObject->premium = "";
         $legacyPropertyObject->propAddress1 = $property->address1;
         $legacyPropertyObject->propAddress3 = $property->address2;
         $legacyPropertyObject->propAddress5 = $property->address3;
         $legacyPropertyObject->propPostcode = $property->postcode;
         $legacyPropertyObject->quote = 0.0;
         $legacyPropertyObject->rateSetId = $agent->getRatesetIDByASN($refNo);
         $legacyPropertyObject->riskArea = $dsContentsRiskArea->getCurrentRate($property['postcode']);
         $legacyPropertyObject->riskAreaB = $dsBuildingsRiskArea->getCurrentRate($property['postcode']);
         $legacyPropertyObject->surcharge = "";
         $legacyPropertyManager->save($legacyPropertyObject);
     }
 }
 private function _doMail($data)
 {
     $pageSession = new Zend_Session_Namespace('portfolio_insurance_quote');
     $customerRefNo = $pageSession->CustomerRefNo;
     // Get Customer
     $customerManager = new Manager_Insurance_Portfolio_LegacyCustomer();
     $customerObject = new Model_Insurance_Portfolio_LegacyCustomer();
     $customerObject = $customerManager->fetchByRefNo($customerRefNo);
     // Get Properties
     $propertyManager = new Manager_Insurance_Portfolio_Property();
     $properties = array();
     // Fetch all the properties related to this customer refNo
     $properties = $propertyManager->fetchAllProperties($customerRefNo)->toArray();
     $propertyHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/property-details.phtml', $properties);
     // Fetch claims releted to this customer refNo
     $claimsManager = new Manager_Insurance_Portfolio_PreviousClaims();
     $claims = $claimsManager->fetchWithClaimTypes($customerRefNo);
     $claimsHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/claims.phtml', $claims);
     // Fetch bank interest related to this customer refNo
     $bankInterestManager = new Manager_Insurance_Portfolio_BankInterest();
     $bankInterest = $bankInterestManager->fetchAllInterests($customerRefNo);
     $bankInterestHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/bank-interest.phtml', $bankInterest);
     $uwManager = new Manager_Insurance_Portfolio_UnderwritingAnswers();
     $uwAnswers = $uwManager->fetchByRefNo($customerRefNo);
     // Merge the claim and Interest info into the UW template
     $uwQuestionsHtml = $this->view->partial('portfolio-insurance-quote/partials/email-templates/uw-questions.phtml', array('claimsHtml' => $claimsHtml, 'bankInterestHtml' => $bankInterestHtml, 'uwAnswers' => $uwAnswers->toArray()));
     // Merge all the html together
     $mailBody = $this->view->partial('portfolio-insurance-quote/partials/email-templates/emailQuote.phtml', array('theData' => $data, 'theCustomer' => $customerObject->toArray(), 'propertyHtml' => $propertyHtml, 'uwQuestionsHtml' => $uwQuestionsHtml));
     // Get some parameter stuffs
     $params = Zend_Registry::get('params');
     $emailArray = explode(",", $params->email->portfolioAdmin);
     $toAddress = $emailArray[0];
     $ccAddress = $emailArray[1];
     $fromAddress = $params->email->noreply;
     // Mail that bad boy
     if (isset($data['referred'])) {
         $referred = " - REFERRED";
     }
     $email = new Application_Core_Mail();
     $email->setFrom($fromAddress, "PORTFOLIO NEW BUSINESS {$referred}");
     $email->setTo($toAddress, "Underwriting");
     $email->setCC($ccAddress);
     $email->setSubject("Portfolio Website Query - ref: {$customerRefNo}");
     $email->setBodyHtml($mailBody);
     $email->send();
     return;
 }