/** * Performs a copy of the quote stored within the MYSQL4 db to MYSQL5. */ protected function legacyQuoteMigration($policyNumber, $customerId) { // Assume a record has not been configured within the MySQL 5 database. // Need to copy data over from the MySQL 4 server to patch the web // quote and buy process $legacyQuotesDs = new Datasource_Insurance_LegacyQuotes(); $legacyQuote = $legacyQuotesDs->getByPolicyNumber($policyNumber); // copy data into a Model_Insurance_Quote object $this->_quoteModel = new Model_Insurance_Quote(); $this->_quoteModel->legacyID = $policyNumber; $this->_quoteModel->legacyCustomerID = $legacyQuote->refNo; $this->_quoteModel->customerID = $customerId; $this->_quoteModel->agentSchemeNumber = $legacyQuote->agentSchemeNumber; $this->_quoteModel->issuedDate = $legacyQuote->issueDate; $this->_quoteModel->startDate = $legacyQuote->startDate; $this->_quoteModel->endDate = $legacyQuote->endDate; $this->_quoteModel->payFrequency = $legacyQuote->payBy; $this->_quoteModel->policyNumber = $legacyQuote->policyNumber; $this->_quoteModel->premium = $legacyQuote->premium; $this->_quoteModel->ipt = $legacyQuote->ipt; $this->_quoteModel->policyLength = $legacyQuote->policyLength; // store the object to db $this->_quoteDataSource->save($this->_quoteModel); // properties $tenantTypeID = null; $agentManaged = null; $ownershipLengthID = null; $noClaimsYearsID = null; $excludeFloodCover = null; // // TODO: Quote products // foreach (explode('|', $legacyQuote->policyOptions) as $option) { // if ($option == 'buildingsp') { // // Buildings // } // else if ($option == 'contentslp') { // // Contents // } // else if ($option == 'limitedcontentsp') { // // Limited contents // } // else if ($option == 'legalexpensesp') { // // Legal expenses // } // else if ($option == 'rentguaranteep') { // // Rent guarantee // } // else if ($option == 'emergencyassistancestandalone' || $option == 'emergencyassistancebahstandalone') { // // Emergency assistance // } // // contentslAccidentalDamagep // buildingsAccidentalDamagep // } $legacyPropertiesDs = new Manager_Insurance_LegacyQuote(); $legacyProperties = $legacyPropertiesDs->getProperties($policyNumber); foreach ($legacyProperties as $propertyId => $property) { // Foreach property, check its content and copy into the web quote process if ($propertyId == 3) { // No claims period switch ($property['propertyValue']) { case 0: $noClaimsYearsID = 1; break; // less than 1 year // less than 1 year case 1: $noClaimsYearsID = 2; break; // 1 year // 1 year case 2: $noClaimsYearsID = 3; break; // 2 years // 2 years case 3: $noClaimsYearsID = 4; break; // 3 years // 3 years case 4: $noClaimsYearsID = 5; break; // more than 3 years } } else { if ($propertyId == 4) { // Managed property switch ($property['propertyValue']) { case 0: $agentManaged = 0; break; // No // No case 1: $agentManaged = 1; break; // Yes } } else { if ($propertyId == 5) { // // TODO: Excess // switch ($property['propertyValue']) { // case 0: break; // 0 // case 1: break; // 100 // case 2: break; // 250 // case 3: break; // 500 // case 4: break; // 1000 // } } else { if ($propertyId == 6) { // Tenant type switch ($property['propertyValue']) { case 0: $tenantTypeID = 1; break; // Employed // Employed case 1: $tenantTypeID = 2; break; // Self Employed // Self Employed case 2: $tenantTypeID = 3; break; // Student // Student case 3: $tenantTypeID = 4; break; // Retired // Retired case 4: $tenantTypeID = 5; break; // Unemployed // Unemployed case 5: $tenantTypeID = 7; break; // Housing authority // Housing authority case 6: $tenantTypeID = 8; break; // Unknown // Unknown case 7: $tenantTypeID = 6; break; // Claiming benefits } } else { if ($propertyId == 9) { // Buildings flood risk switch ($property['propertyValue']) { case 0: $excludeFloodCover = 1; break; // No // No case 1: $excludeFloodCover = 0; break; // Yes } } else { if ($propertyId == 11) { // // TODO: Buildings cover over 500,000 // switch ($property['propertyValue']) { // case 0: break; // No // case 1: break; // Yes // } } else { if ($propertyId == 12) { // Ownership length switch ($property['propertyValue']) { case 0: $ownershipLengthID = 1; break; // 0 years // 0 years case 1: $ownershipLengthID = 2; break; // 1 year // 1 year case 2: $ownershipLengthID = 3; break; // 2 years // 2 years case 3: $ownershipLengthID = 4; break; // 3 years // 3 years case 4: $ownershipLengthID = 5; break; // over 3 years } } } } } } } } } // Populate properties $propertiesDs = new Datasource_Insurance_Quote_Properties(); $propertiesDs->add($this->_quoteModel->ID, $legacyQuote->propertyPostcode, '', '', $legacyQuote->propertyAddress1, $tenantTypeID, $agentManaged, $ownershipLengthID, $noClaimsYearsID, $excludeFloodCover, $legacyQuote->propertyAddress2, $legacyQuote->propertyAddress3, ''); // TODO: repeat for products, product_metas and properties }
/** * Adds a property to the quote * * @param string postcode Postcode of the property * @param string town * @param string county * @param string line1 First line of address * @param int tenantTypeID Valid tenant type ID * @param boolean agentManaged Is the property managed by an agent? * @param int ownershipLengthID Valid ID for an ownership length * @param int noClaimsYearsID Valid ID for a number of no claims years discount * @param boolean excludeFloodCover Do you want to exclude flood cover from this property? * @param string line2 Second line of address (optional) * @param string line3 Third line of address (optional) * @param string country Country (optional) * * Note: this is Landlords Insurance + so only one property is allowed per quote */ public function addProperty($postcode, $town, $county, $line1, $tenantTypeID, $agentManaged, $ownershipLengthID, $noClaimsYearsID, $excludeFloodCover, $line2 = null, $line3 = null, $country = null) { $quoteProperties = new Datasource_Insurance_Quote_Properties(); if ($this->propertyCount() > 0) { // You can only have one property on an LI+ quote - so we remove the existing one before adding the new one $quoteProperties->removeAllByQuoteID($this->_quoteModel->ID); } return $quoteProperties->add($this->_quoteModel->ID, $postcode, $town, $county, $line1, $tenantTypeID, $agentManaged, $ownershipLengthID, $noClaimsYearsID, $excludeFloodCover, $line2, $line3, $country); $this->save(); }