/** * */ public function getEndorsements() { $endorsementManager = new Manager_Insurance_LandlordsPlus_Endorsement(); $endorsements = $endorsementManager->getEndorsementsRequired($this->_quoteModel->ID); $endorsementsArray['floodArea'] = false; $endorsementsArray['floodOptional'] = false; if (count($endorsements) > 0) { foreach ($endorsements as $endorsement) { if ($endorsement->getEndorsementType()->getName() == Model_Insurance_EndorsementTypes::FLOOD_EXCLUSION) { $endorsementsArray['floodArea'] = true; // Flood exclusion endorsement - need to find out if it's optional or not $properties = $this->getProperties(); $floodOptional = $endorsementManager->getIsFloodEndorsementOptional($properties[0]['postcode']); $endorsementsArray['floodOptional'] = $floodOptional; } } } $endorsementsArray['endorsements'] = $endorsements; return $endorsementsArray; }
public function step4Action() { $pageForm = new LandlordsInsuranceQuote_Form_Step4(); // Tell page to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 4;'); // Check to make sure the user has actually added a product - if they haven't stop them going forward $session = new Zend_Session_Namespace('landlords_insurance_quote'); $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID); if ($quoteManager->productCount() == 0 && !isset($_POST['back'])) { $this->view->stepNum = "no-product"; // AJD - Not happy about this, but it's the way HLF was built. $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID); $policyNumber = $quoteManager->getLegacyID(); $this->view->quoteID = $policyNumber; $this->render('no-cover-selected'); return; } elseif ($quoteManager->productCount() == 0 && isset($_POST['back'])) { // No products/options selected, send them back to step 2 $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step2'); return; } elseif ($this->getRequest()->isPost()) { // We need to validate and save the data $valid = $this->_formStepCommonValidate($pageForm, 4); if ($valid) { //Update the WebLead summary and create a STEP4 blob. $session = new Zend_Session_Namespace('landlords_insurance_quote'); $webLeadManager = new Manager_Core_WebLead(); $webLeadSummary = $webLeadManager->getSummary($session->webLeadSummaryId); $webLeadSummary->lastUpdatedTime = $this->_offsetDate(); $webLeadManager->updateSummary($webLeadSummary); //Determine if a new STEP4 blob needs to be created, or an existing one retrieved. if ($webLeadManager->getBlobExists($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP4)) { $webLeadBlob = $webLeadManager->getBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP4); } else { $webLeadBlob = $webLeadManager->createNewBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP4); } //Update the blob and store $webLeadBlob->blob = Zend_Json::encode($_POST); $webLeadBlob->blobChecksum = crc32($webLeadBlob->blob); $webLeadManager->updateBlob($webLeadBlob); //Store the underwriting datas not already stored. $pageForm->applyAnswersLogics(); $pageForm->applyAdditionalInformationLogics(); $endorsementManager = new Manager_Insurance_LandlordsPlus_Endorsement(); $endorsements = $endorsementManager->getEndorsementsRequired($session->quoteID); //Look for a flood endorsement, and if found, identify if it is applicable (the //customer may have chosen to pay a premium to cover flood). $finalEndorsementArray = array(); foreach ($endorsements as $currentEndorsement) { if ($currentEndorsement->getEndorsementType()->getName() == Model_Insurance_EndorsementTypes::FLOOD_EXCLUSION) { $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID); $propertiesArray = $quoteManager->getProperties(); if ($propertiesArray[0]['exclude_flood_cover'] == 0) { //Flood cover IS provided, which means the endorsement is not applicable. continue; } } if ($endorsementManager->getIsEndorsementAlreadyApplied($currentEndorsement)) { //No need to add the endorsement again... continue; } $finalEndorsementArray[] = $currentEndorsement; } if (count($finalEndorsementArray) > 0) { $endorsementManager->insertEndorsements($finalEndorsementArray); } //Execute the underwriting referral logics. $referralManager = new Manager_Insurance_LandlordsPlus_Referral(); $reasons = $referralManager->getReferralReasons($session->quoteID); if (!empty($reasons)) { // Notify Underwriting of the referral. $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID); $policyNumber = $quoteManager->getLegacyID(); $refNo = $quoteManager->getLegacyCustomerReference(); $notificationManager = new Manager_Core_Notification(); $notesManager = new Manager_Core_Notes(); $otherReason = ''; for ($i = 0; $i < count($reasons); $i++) { if ('Referral due to buildings type' === $reasons[$i]) { $otherReason = "Policy has been referred due to property type of Other."; break; } } if ($otherReason) { $notesManager->save($policyNumber, "Refer to UW - " . $otherReason); $notificationManager->_reason = "Other"; } else { $notesManager->save($policyNumber, "Refer to UW - The application has fallen outside UW criteria."); } $notificationManager->notifyUnderwriting($policyNumber, $refNo); $referralManager->setToRefer($session->quoteID); //Redirect to referredAction. $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/referred'); return; } // Everything has been saved ok so navigate to next step $this->_formStepCommonNavigate(4); return; } elseif (isset($_POST['back'])) { $this->_formStepCommonNavigate(4); return; } } // If there's no quote manager, then set it up so we can make use of the // QHLI in the templates. if (!isset($quoteManager)) { $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID); } $this->view->qhli = $quoteManager->getLegacyID(); // Load the element data from the database if we can if ($this->_formStepCommonPopulate($pageForm, 4)) { // Render the page unless we have been redirected $this->view->form = $pageForm; $this->render('step'); } }