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'); } }
/** * Referred action * @param none * This function handles the referred underwriting state, including unsetting the session * @return void * **/ public function referredAction() { // Show the policy number to the end user $this->view->policyNumber = $this->_policyNumber; // Perform referral - set quote status to referred $referralManager = new Manager_Insurance_TenantsContentsPlus_Referral(); $referralManager->setToRefer($this->_policyNumber); // Notify Underwriting $notificationManager = new Manager_Core_Notification(); $notificationManager->notifyUnderwriting($this->_policyNumber, $this->_customerReferenceNumber); // Unset the session to prevent navigation to other steps Zend_Session::namespaceUnset('tenants_insurance_quote'); }
/** * Referred action * @param none * This function handles the referred underwriting state, including unsetting the session * @return void * **/ public function referredAction() { // Show the policy number to the end user $this->view->policyNumber = $this->_policyNumber; // Perform referral - set quote status to referred $referralManager = new Manager_Insurance_TenantsContentsPlus_Referral(); $referralManager->setToRefer($this->_policyNumber); // Notify Underwriting $notificationManager = new Manager_Core_Notification(); $notificationManager->notifyUnderwriting($this->_policyNumber, $this->_customerReferenceNumber); // Pop an e-mail to the end user $params = Zend_Registry::get('params'); $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber); $replacements = array('title' => $customer->getTitle(), 'firstName' => $customer->getFirstName(), 'lastName' => $customer->getLastName(), 'fullName' => $customer->getTitle() . ' ' . $customer->getFirstName() . ' ' . $customer->getLastName(), 'quoteNumber' => $this->_policyNumber, 'imageBaseUrl' => $this->_params->weblead->mailer->imageBaseUrl); $subjectLine = $params->weblead->mailer->tenant->referredQuote->subject; foreach ($replacements as $key => $val) { $subjectLine = str_replace("[{$key}]", $val, $subjectLine); } $replacements['pageTitle'] = $subjectLine; $template = $params->weblead->mailer->tenant->referredQuote->template; $mail = new Application_Core_Mail(); $mail->setTo($customer->getEmailAddress(), $replacements['fullName'])->setFrom($params->weblead->mailer->fromAddress, $params->weblead->mailer->fromName)->setSubject($subjectLine)->applyTemplate($template, $replacements, true); $mail->send(); // Tag quote as mailer sent, stops abandone quote mailer cron from sending a continue mailer $webLeadManager = new Manager_Core_WebLead(); $webLeadManager->setIsMailerSent($this->_policyNumber, true); // Unset the session to prevent navigation to other steps Zend_Session::namespaceUnset('tenants_insurance_quote'); }