public function removeBankInterestAction() { $request = $this->getRequest(); $postData = $request->getPost(); $bankInterestId = $postData['id']; //Remove the previous claim identified by the id $return['success'] = false; if (!empty($bankInterestId)) { $session = new Zend_Session_Namespace('landlords_insurance_quote'); $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID); //Retrieve the quote identifiers. $customerReferenceNumber = $quoteManager->getLegacyCustomerReference(); $policyNumber = $quoteManager->getLegacyID(); //Ensure the bank interest identifier passed in is associated with the //policynumber and customer reference number. $bankInterestManager = new Manager_Insurance_LegacyBankInterest(); $bankInterest = $bankInterestManager->getInterest($bankInterestId); if (!empty($bankInterest)) { if ($bankInterest->getRefno() == $customerReferenceNumber && $bankInterest->getPolicyNumber() == $policyNumber) { //Delete the quote. $bankInterestManager->removeInterest($bankInterestId); //Retrieve all the remaining bank interests for display on the dialog. $bankInterestArray = $bankInterestManager->getAllInterests($policyNumber, $customerReferenceNumber); $model = array(); if (!empty($bankInterestArray)) { foreach ($bankInterestArray as $bankInterest) { $model[] = array('bankInterest' => $bankInterest); } } //Update the dialog. $return['html'] = $this->view->partialLoop('partials/bank-interest-list.phtml', $model); $return['success'] = true; } } else { //This method has been called when there are no bank interests to delete. Can happen on ajax //calls, so accommodate this. $return['success'] = true; } } if (!$return['success']) { $return['errors'] = 'Failed to remove the bank interest'; } echo Zend_Json::encode($return); }
/** * Checks the underwriting answers. */ protected function _checkAnswers($quoteId) { $params = Zend_Registry::get('params'); $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quoteId); $policyNumber = $quoteManager->getLegacyID(); $property = $quoteManager->getProperties(); $postCode = $property[0]['postcode']; $referralReasons = array(); //Test 3: Answering the underwriting questions. $answersManager = new Manager_Insurance_Answers(); $answersArray = $answersManager->getUnderwritingAnswers($policyNumber); if (empty($answersArray)) { //You can't process for referral if no underwriting answers have first been provided. throw new Zend_Exception(get_class() . __FUNCTION__ . ": no underwriting answers provided."); } for ($i = 0; $i < count($answersArray); $i++) { $answerGiven = $answersArray[$i]->getAnswer(); $expectedAnswer = $answersArray[$i]->getExpectedAnswer(); $questionNumber = $answersArray[$i]->getQuestionNumber(); //Process questions 53, 60, 61 specially. if ($questionNumber == '53') { continue; } //Question 6 is dealt with specially. if ($questionNumber == '60') { if ($answerGiven == Model_Insurance_Answer::YES) { //Check the extra args. $underwritingTerms = new Datasource_Insurance_LandlordsPlus_Terms(); $subsidenceScore = $underwritingTerms->getSubsidenceRiskScore($postCode); if ($subsidenceScore == 0) { $referralReasons[] = $params->uw->rr->landlordsp->answer; } } continue; } if ($questionNumber == '61') { //Question 7 is the previous claims answer. The outcome of this is determiend by the //previous claims logic in the checkUwReferralState() method. continue; } //This is the referencing question. Some calls to this method may want this answer to //be ignored. if ($questionNumber == '64' && $this->_ignoreReferencingQuestion) { continue; } //All other questions should be processed here. if ($expectedAnswer == Model_Insurance_Answer::YES || $expectedAnswer == Model_Insurance_Answer::NO) { if ($answerGiven != $expectedAnswer) { print "HERE2 {$questionNumber}<BR>"; $referralReasons[] = $params->uw->rr->landlordsp->answer; } } } //Return the results consistent with this method's contract. if (empty($referralReasons)) { $returnVal = null; } else { $returnVal = $referralReasons; } return $returnVal; }
/** * Step 5 - Payment, incorporates direct debit form * * @return void */ public function step5Action() { $pageForm = new LandlordsInsuranceQuote_Form_Step5(); // Tell page to use AJAX validation as we go $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 5;'); if ($this->getRequest()->isPost()) { // We need to validate and save the data $valid = $this->_formStepCommonValidate($pageForm, 5); if ($valid) { $data = $pageForm->getValues(); $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($this->_quoteID); $quoteManager->setPayBy(strtoupper($data['subform_paymentselection']['payment_method'])); $quoteManager->setPayFrequency(strtoupper($data['subform_paymentselection']['payment_frequency'])); $quoteManager->save(); // Temporarily store payment selection details in session ready for use during bank confirmation step // for DD payers $pageSession = new Zend_Session_Namespace('landlords_insurance_quote'); $pageSession->paymentSelectionDetails = $data['subform_paymentselection']; // Everything has been saved ok so navigate to next step $this->_formStepCommonNavigate(5); return; } elseif (isset($_POST['back'])) { $this->_formStepCommonNavigate(5); 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($this->_quoteID); } $this->view->qhli = $quoteManager->getLegacyID(); // Load the element data from the database if we can if ($this->_formStepCommonPopulate($pageForm, 5)) { // Render the page unless we have been redirected $this->view->form = $pageForm; $this->render('step'); } }
public function isValid($formData) { //We only need additional information if some questions have been answered wrongly. $additionalInfoIsRequired = false; if (!empty($formData['declaration2']) && $formData['declaration2'] == 'no') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration2b']) && $formData['declaration2b'] == 'no') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration2c']) && $formData['declaration2c'] == 'yes') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration2d']) && $formData['declaration2d'] == 'yes') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration3']) && $formData['declaration3'] == 'no') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration4']) && $formData['declaration4'] == 'no') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration6']) && $formData['declaration6'] == 'yes') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration8']) && $formData['declaration8'] == 'yes') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration9']) && $formData['declaration9'] == 'yes') { $additionalInfoIsRequired = true; } else { if (!empty($formData['declaration10']) && $formData['declaration10'] == 'no') { $additionalInfoIsRequired = true; } } } } } } } } } } if ($additionalInfoIsRequired) { $this->getElement('additional_information')->setRequired(true); } else { $this->getElement('additional_information')->setRequired(false); } //Superclass validations $returnVal = parent::isValid($formData); //Some compound processing. If the user has advised they have previous claims, then they must provide //details of these. Ensure this is the case. $session = new Zend_Session_Namespace('landlords_insurance_quote'); $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID); $customerReferenceNumber = $quoteManager->getLegacyCustomerReference(); $policyNumber = $quoteManager->getLegacyID(); if (!empty($formData['declaration7'])) { if ($formData['declaration7'] == 'yes') { //One or more previous claims must exist. $claimsManager = new Manager_Insurance_PreviousClaims(); $previousClaims = $claimsManager->getPreviousClaims($customerReferenceNumber); if (empty($previousClaims)) { //Record error. $this->declaration7->addError('Please provide details of previous claims'); $returnVal = false; } } } //If the user advised they have bank interest, then they must provide details of these. //Ensure this is the case. if (!empty($formData['declaration11'])) { if ($formData['declaration11'] == 'yes') { //One or more bank interests. $bankInterestManager = new Manager_Insurance_LegacyBankInterest(); $bankInterestArray = $bankInterestManager->getAllInterests($policyNumber, $customerReferenceNumber); if (empty($bankInterestArray)) { //Record error. $this->declaration11->addError('Please provide details of bank interest'); $returnVal = false; } } } return $returnVal; }