public function __construct($agentSchemeNumber = null) { $this->_offline = true; $this->_quoteModel = new Model_Insurance_LegacyQuote(); if ($agentSchemeNumber != "" && !is_null($agentSchemeNumber)) { $this->_quoteModel->agentSchemeNumber = $agentSchemeNumber; } // Default the settings $agent = new Datasource_Core_Agents(); $this->_quoteModel->agentRateSetID = $agent->getRatesetID($this->_quoteModel->agentSchemeNumber); $this->_quoteModel->status = 'Quote'; $this->_quoteModel->startTime = date("H:m:s"); }
/** * Load an existing quote from the database into the object * * @param string $policyNumber * @return Model_Insurance_LegacyQuote */ public function getByPolicyNumber($policyNumber) { $quote = new Model_Insurance_LegacyQuote(); $select = $this->select()->where('policynumber = ?', $policyNumber); $row = $this->fetchRow($select); if ($row) { $quote->refNo = $row->refno; $quote->policyNumber = $row->policynumber; $quote->agentSchemeNumber = $row->companyschemenumber; $quote->policyName = $row->policyname; $quote->issueDate = $row->issuedate; $quote->startDate = $row->startdate; $quote->endDate = $row->enddate; $quote->cancelledDate = $row->cancdate; $quote->payBy = $row->payby; $quote->payMethod = $row->paymethod; $quote->payStatus = $row->paystatus; $quote->policyOptions = $row->policyoptions; $quote->amountsCovered = $row->amountscovered; $quote->optionPremiums = $row->optionpremiums; $quote->paidNet = $row->paidnet; $quote->propertyAddress1 = $row->propaddress1; $quote->propertyAddress2 = $row->propaddress3; $quote->propertyAddress3 = $row->propaddress5; $quote->propertyPostcode = $row->proppostcode; $quote->dateOfLastPayment = $row->datelastpayment; $quote->policyType = $row->policytype; $quote->timeCompleted = $row->timecompleted; $quote->riskArea = $row->riskarea; $quote->whiteLabelID = $row->whitelabelID; $quote->policyLength = $row->policylength; $quote->origin = $row->origin; $quote->rateSetID = $row->rateSetID; $quote->excessID = $row->excessID; $quote->status = $row->status; $quote->startTime = $row->startTime; $quote->paySchedule = $row->payby; $quote->underwritingQuestionSetID = $row->underwritingQuestionSetID; $quote->dateStarted = $row->dateStarted; $quote->premium = $row->premium; $quote->ipt = $row->IPT; $quote->quote = $row->quote; // Calculate the missing data that isn't currently stored in the database $agent = new Datasource_Core_Agents(); $quote->agentRateSetID = $agent->getRatesetID($quote->agentSchemeNumber); return $quote; } else { return null; } }
/** * Deletes the logo for document logo file * * @param object $pathParams * @param null|int $agentSchemeNumber * @return bool */ public function deleteDocumentLogo($pathParams, $agentSchemeNumber = null) { $this->_imageUtils->deleteLogo($pathParams); // Amend DB to say "no logo" $this->_agentDatasource->deleteDocumentLogo($this->_agentSchemeNumber); return true; }
/** * @todo: Fix this so it's not messing around with arrays. * * @param unknown_type $schemeNumber * @param unknown_type $emailAddresses */ public function setEmailAddresses($schemeNumber, $emailAddresses) { // First of all check to make sure this is a valid agent schemeNumber $agent = new Datasource_Core_Agents(); $agentSelect = $agent->getBySchemeNumber($schemeNumber); $agentRow = $agent->fetchRow($agentSelect); if (!$agentRow) { return false; } // There is no 'replace' functionality in zend as it is, sadly, mysql specific // so we have to do a delete then an insert // First build a select object to get all email addresses for the specified agent $where = $this->quoteInto('scheme_number = ?', $schemeNumber); // Then delete them if (!$this->delete($where)) { //return false; } // Now build the insert array foreach ($emailAddresses as $emailAddress) { $tempEmailAddress = ''; $tempCategoryId = ''; if (is_array($emailAddress)) { $tempEmailAddress = $emailAddress['emailAddress']; $tempCategoryId = $emailAddress['categoryID']; } else { if (is_object($emailAddress)) { $tempEmailAddress = $emailAddress->emailAddress; $tempCategoryId = $emailAddress->categoryID; } else { Application_Core_Logger::log("Datatype unknown when changing email address for agent {$schemeNumber}.", 'error'); return false; } } if ($tempEmailAddress != '') { $data = array('scheme_number' => $schemeNumber, 'email_address' => $tempEmailAddress, 'category_id' => $tempCategoryId); if (!$this->insert($data)) { // Failed insertion Application_Core_Logger::log("Can't insert e-mail address in table {$this->_name} (scheme_number = {$schemeNumber})", 'error'); return false; } } } return true; }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { // Need to load the letting agents into the drop down or it fails validation // with an invalid id - by default zend does an inArray check on select boxes if (array_key_exists('letting_agent_asn', $formData)) { $agentLookup = new Datasource_Core_Agents(); $agentList = $agentLookup->searchByAsnOrNameAndAddress($formData['letting_agent_asn'], $formData['letting_agent_name'], $formData['letting_agent_town']); $agentDropdownValues = array(); if ($agentList) { foreach ($agentList as $agent) { $agentDropdownValues[$agent['asn']] = $agent['name'] . ', ' . $agent['address']; } } $agentDropdown = $this->letting_agent; $agentDropdown->setMultiOptions($agentDropdownValues); $agentDropdown->setRequired(true); } // Check if letting_agent_agent is 'Yes', if so then either: // letting_agent_name AND letting_agent_town are mandatory, OR // letting_agent_asn is mandatory if (isset($formData['letting_agent_has']) && $formData['letting_agent_has'] == 'yes') { // Set all three to mandatory first $this->getElement('letting_agent_name')->setRequired(true); $this->getElement('letting_agent_town')->setRequired(true); $this->getElement('letting_agent_asn')->setRequired(true); // Decide which can be un-mandatory if (trim($formData['letting_agent_asn']) != '') { $this->getElement('letting_agent_name')->setRequired(false); $this->getElement('letting_agent_town')->setRequired(false); } if (trim($formData['letting_agent_name']) != '' && trim($formData['letting_agent_town']) != '') { $this->getElement('letting_agent_asn')->setRequired(false); } } elseif (isset($formData['letting_agent_has']) && $formData['letting_agent_has'] == 'no') { // The user has said they don't have a letting agent so ignore all the validation // TODO: This is a dirty fix to QC4364 - this code is so complex and dirty that I can't actually find // why it's throwing weird haystack validation errors. Needs re-factoring. return true; } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { // If the ASN, Name and Town are all entered - the form is technically // valid - but we need to check to make sure the ASN is actually a // valid one. if (isset($formData['letting_agent_asn']) && $formData['letting_agent_asn'] != '') { $agentDatasource = new Datasource_Core_Agents(); $agent = $agentDatasource->getDetailsByASN($formData['letting_agent_asn']); if (count($agent) == 0) { // Call the parent isValid to generate other error messages parent::isValid($formData); $this->getElement('letting_agent_asn')->addError('Not a valid Agent Scheme Number'); // Return invalid return false; } } // Check if letting_agent_agent is 'Yes', if so then either: // letting_agent_name AND letting_agent_town are mandatory, OR // letting_agent_asn is mandatory if (isset($formData['have_letting_agent']) && $formData['have_letting_agent'] == 'yes') { // Set all three to mandatory first $this->getElement('letting_agent_name')->setRequired(true); $this->getElement('letting_agent_town')->setRequired(true); $this->getElement('letting_agent_asn')->setRequired(true); // Decide which can be un-mandatory if (trim($formData['letting_agent_asn']) != '') { $this->getElement('letting_agent_name')->setRequired(false); $this->getElement('letting_agent_town')->setRequired(false); } if (trim($formData['letting_agent_name']) != '' && trim($formData['letting_agent_town']) != '') { $this->getElement('letting_agent_asn')->setRequired(false); } } elseif (isset($formData['have_letting_agent']) && $formData['have_letting_agent'] == 'no') { // The user has said they don't have a letting agent so ignore all the validation // TODO: This is a dirty fix to QC4364 - this code is so complex and dirty that I can't actually find // why it's throwing weird haystack validation errors. Needs re-factoring. return true; } // Call original isValid() return parent::isValid($formData); }
/** * Saves the disbursement info to the relevant table * * @param String policy, double $amount, int $months, String $paymethod, date $paymentdate, double $fee, int $csuID * * @return * * */ public function processDisbursement($policynumber, $amount, $months, $paymethod, $paymentdate = null, $fee = null, $csuid = 0, $transactionType = 'payment') { if (is_null($paymentdate)) { $paymentdate = date("Y-m-d"); } /** * prepair data to build transactions */ $this->_policynumber = $policynumber; $this->_amount = $amount; $this->_months = $months; $policyDisb = new Datasource_Insurance_LegacyPolicies(); $policy = $policyDisb->getByPolicyNumber($policynumber); $this->_policyname = $policy->policyName; $customerDisb = new Datasource_Core_LegacyCustomers(); $customer = $customerDisb->getCustomer($policy->refNo); $scheduleDisb = new Datasource_Insurance_Schedules(); $schedule = $scheduleDisb->retrieveByPolicyNumber($policynumber); $agentDisb = new Datasource_Core_Agents(); $agentS = $agentDisb->getBySchemeNumber($policy->agentSchemeNumber); $agent = $agentDisb->fetchrow($agentS); $termDisb = new Datasource_Insurance_Policy_Term(); $term = $termDisb->getPolicyTerm($policynumber, $policy->startDate); $this->_startdate = $policy->startDate; $transdata = array(); $transdata['paymentrefno'] = $schedule->paymentRefNo; $transdata['policynumber'] = $policynumber; $transdata['paymentdate'] = $paymentdate; $transdata['amount'] = $amount; $transdata['handlingcharge'] = isset($fee) ? $fee : $schedule->ddFee; $transdata['csuid'] = $csuid; $transdata['months'] = $months; $transdata['paymethod'] = $paymethod; $transdata['whitelabelID'] = $agent['twolettercode']; $transdata['agentschemeno'] = $policy->agentSchemeNumber; $transdata['premier'] = ucfirst($agent['premier']); $transdata['salesman'] = $agent['salesman']; $transdata['riskarea'] = $policy->riskArea; $transdata['riskareab'] = $policy->riskAreaB; $transdata['isNewBusiness'] = $term['term'] == 1 ? 'yes' : 'no'; $transdata['isPaidnet'] = $policy->paidNet; $transdata['policyTermID'] = $term['id']; $transdata['policyname'] = $policy->policyName; $transdata['type'] = $transactionType; $this->_transID = $this->_newtransaction->saveDetails($transdata); $transdata['trans_id'] = $this->_transID; $this->_termid = $transdata['policyTermID']; /* Create transaction record for MI */ $transupportdata = array(); $this->_transIDDW = $this->_transaction->saveDetails($transdata); $transupportdata['trans_id'] = $this->_transIDDW; $transupportdata['customerTitle'] = $customer->getTitle(); $transupportdata['customerFirstName'] = $customer->getFirstName(); $transupportdata['customerLastName'] = $customer->getLastName(); $transupportdata['riskAddress1'] = $policy->propertyAddress1; $transupportdata['riskAddress2'] = $policy->propertyAddress2; $transupportdata['riskAddress3'] = $policy->propertyAddress3; $transupportdata['riskPostcode'] = $policy->propertyPostcode; $transupportdata['policytype'] = $policy->policyType; $transupportdata['payby'] = $policy->payBy; $transupportdata['policyLength'] = $policy->policyLength; $this->_transactionSupport->saveDetails($transupportdata); $this->_ptranID = $this->_paymentTransaction->saveDetails($transdata); $this->_getMult($policy); /* calculate for disbursement */ $this->_calculateGrossprem($policy); $this->_calculateAgentComm($policy, $agent, $term['term']); $policyOptionsArray = explode("|", $policy->policyOptions); $es = array(4, 28, 29, 30); foreach ($policyOptionsArray as $key => $value) { $this->_initialise(); $option = new Datasource_Insurance_Policy_Options($policy->policyType); $this->_optionID = $option->fetchOptionsByName($value); $this->_sumInsOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->amountsCovered); if ($this->_sumInsOption > 0 || in_array($this->_optionID, $es)) { $this->_premOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->optionPremiums) * $this->_mult; $this->_discOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->optionDiscounts); $this->_calculateAgentCommOption(); $this->_calculateTax(); $this->_calculateNet($policy, $value); $this->_storeOptionDisbursement(); } $this->_policynetprem += $this->_netOption; $this->_policyIPT += $this->_iptOption; if ($value == "contentstp") { $this->_disTcontents = $this->_netOption; $this->_iptTcontents = $this->_iptOption; $this->_premTcontents = $this->_premOption; $this->_sumTcontents = $this->_sumInsOption; } elseif ($value == "pedalcyclesp") { $this->_disTpedel = $this->_netOption; $this->_iptTpedel = $this->_iptOption; $this->_premTpedel = $this->_premOption; $this->_sumTpedel = $this->_sumInsOption; } elseif ($value == "possessionsp" || $value == "specpossessionsp") { $this->_disTposs += $this->_netOption; $this->_iptTposs += $this->_iptOption; $this->_premTposs += $this->_premOption; $this->_sumTposs += $this->_sumInsOption; } elseif ($value == "buildingsp" || $value == "buildingslflood") { $this->_disLbuilding += $this->_netOption; $this->_iptLbuilding += $this->_iptOption; $this->_premLbuilding += $this->_premOption; $this->_sumLbuilding = $this->_sumInsOption; } elseif ($value == "buildingsAccidentalDamagep") { $this->_disLBA = $this->_netOption; $this->_iptLBA = $this->_iptOption; $this->_premLBA = $this->_premOption; $this->_sumLBA = $this->_sumInsOption; } elseif ($value == "limitedcontentsp") { $this->_disLcontents = $this->_netOption; $this->_iptLcontents = $this->_iptOption; $this->_premLcontents = $this->_premOption; $this->_sumLcontents = $this->_sumInsOption; } elseif ($value == "contentslp" || $value == "contentslflood") { $this->_disLcontents += $this->_netOption; $this->_iptLcontents += $this->_iptOption; $this->_premLcontents += $this->_premOption; $this->_sumLcontents = $this->_sumInsOption; } elseif ($value == "contentslAccidentalDamagep") { $this->_disLCA = $this->_netOption; $this->_iptLCA = $this->_iptOption; $this->_premLCA = $this->_premOption; $this->_sumLCA = $this->_sumInsOption; } elseif ($value == "emergencyassistance" || $value == "emergencyassistancestandalone") { $this->_disES += $this->_netOption; $this->_iptES += $this->_iptOption; $this->_premES += $this->_premOption; $this->_sumES = $this->_sumInsOption; } elseif ($value == "emergencyassistancebahbuildings" || $value == "emergencyassistancebahstandalone") { $this->_disEB += $this->_netOption; $this->_iptEB += $this->_iptOption; $this->_premEB += $this->_premOption; $this->_sumEB = $this->_sumInsOption; } //Zend_Debug::dump($this); } $this->_grosspremium = round($this->_policypremium + $this->_policyIPT, 2); $this->_calCulateBalance(); if ($this->_policyname == "tenantsp") { $this->_newtransaction->updateNewTranForTenant($this); $this->_transaction->updateTranForTenant($this); } if ($this->_policyname == "landlordsp") { $this->_newtransaction->updateTranForLandlord($this); $this->_transaction->updateTranForLandlord($this); } $this->_paymentTransaction->updatePaymentTransaction($this); /* * TODO reverse or refund disbursement */ if ($amount < 0) { } }
/** * Retrieves the specified Reference. * * @param mixed $referenceId * The unique Reference identifier. May be the IRN (internal refno) or the ERN (external * refno). * * @return mixed * The Reference details, encapsulated in a Model_Referencing_Reference object, * or null if the Reference cannot be found. */ public function getEnquiry($referenceId) { $enquiryRow = $this->_getEnquiryRow($referenceId); if (empty($enquiryRow)) { Application_Core_Logger::log(get_class() . '::' . __FUNCTION__ . ':Unable to find Enquiry.'); $returnVal = null; } else { //Populate the details into a Customer object. $reference = new Model_Referencing_Reference(); $reference->internalId = $enquiryRow->ID; $reference->externalId = $enquiryRow->RefNo; $reference->declarationVersion = $enquiryRow->declaration_version; $productDatasource = new Datasource_ReferencingLegacy_Product(); $product = $productDatasource->getProductByID($enquiryRow->ProductID); if (!empty($product)) { $reference->productSelection = new Model_Referencing_ProductSelection(); $reference->productSelection->referenceId = $enquiryRow->ID; $reference->productSelection->product = $product; switch ($enquiryRow->PolicyLength) { case 0: $reference->productSelection->duration = 0; break; case 6: $reference->productSelection->duration = 6; break; case 12: $reference->productSelection->duration = 12; break; default: $reference->productSelection->duration = 0; } } $progressDatasource = new Datasource_ReferencingLegacy_Progress(); $reference->progress = $progressDatasource->getByEnquiry($enquiryRow->RefNo); $propertyLeaseDatasource = new Datasource_ReferencingLegacy_PropertyLease(); $reference->propertyLease = $propertyLeaseDatasource->getPropertyLease($enquiryRow->proprefno, $enquiryRow->RefNo); $referenceSubjectDatasource = new Datasource_ReferencingLegacy_ReferenceSubject(); $reference->referenceSubject = $referenceSubjectDatasource->getReferenceSubject($enquiryRow->TenantID, $enquiryRow->RefNo); //Build the reference status. $referenceStatus = new Model_Referencing_ReferenceStatus(); $referenceStatus->referenceId = $enquiryRow->ID; if ($enquiryRow->nochange == 'cancelled') { $referenceStatus->state = Model_Referencing_ReferenceStates::CANCELLED; } else { $progressManager = new Manager_Referencing_Progress(); $progressItem = $progressManager->findSpecificProgressItem($reference->progress, Model_Referencing_ProgressItemVariables::FINAL_REPORT_BUILT); if ($progressItem == null || $progressItem->itemState == Model_Referencing_ProgressItemStates::INCOMPLETE) { $referenceStatus->state = Model_Referencing_ReferenceStates::INPROGRESS; } else { if (strcasecmp("Incomplete - Awaiting further information", $enquiryRow->conclusion) == 0) { $referenceStatus->state = Model_Referencing_ReferenceStates::INCOMPLETE; $referenceStatus->reasonForState = Model_Referencing_ReferenceStateReasons::AWAITING_FURTHER_INFORMATION; } else { if (strcasecmp("Incomplete - Awaiting Completion of Tenant", $enquiryRow->conclusion) == 0) { $referenceStatus->state = Model_Referencing_ReferenceStates::INCOMPLETE; $referenceStatus->reasonForState = Model_Referencing_ReferenceStateReasons::AWAITING_TENANT_COMPLETION; } else { $referenceStatus->state = Model_Referencing_ReferenceStates::COMPLETE; } } } } $reference->status = $referenceStatus; //Build the reference decision if ($enquiryRow->conclusion == '' || preg_match("/incomplete/i", $enquiryRow->conclusion)) { $reference->decision = null; } else { $decision = new Model_Referencing_Decision(); $decision->referenceId = $enquiryRow->ID; if (preg_match("/not acceptable/i", $enquiryRow->conclusion)) { $decision->decision = Model_Referencing_Decisions::NOT_ACCEPTABLE; $decision->decisionReasons = ''; //TO DO HERE } else { $decision->decision = Model_Referencing_Decisions::ACCEPTABLE; //Add caveats, if applicable $caveats = array(); if (preg_match("/guarantor/i", $enquiryRow->conclusion)) { $decisionCaveat = new Model_Referencing_DecisionCaveat(); $decisionCaveat->caveat = Model_Referencing_DecisionCaveats::WITH_GUARANTOR; //Identify the caveat reasons. $decisionCaveat->caveatReason = null; $caveats[] = $decisionCaveat; } if (preg_match("/condition/i", $enquiryRow->conclusion)) { $decisionCaveat = new Model_Referencing_DecisionCaveat(); $decisionCaveat->caveat = Model_Referencing_DecisionCaveats::WITH_CONDITION; //Identify the caveat reasons. $decisionCaveat->caveatReason = null; $caveats[] = $decisionCaveat; } if (!empty($caveats)) { //Attach the array of caveat(s) to the Decision object. $decision->caveats = $caveats; } } //Attach the Decision object to the Reference object. $reference->decision = $decision; } /* $reference->termsAgreedBy = $enquiryRow->termsagreedby; */ if ($enquiryRow->termsagreedby == 'Tenant') { $reference->completionMethod = Model_Referencing_ReferenceCompletionMethods::TWO_STEP; } else { $reference->completionMethod = Model_Referencing_ReferenceCompletionMethods::ONE_STEP; } //Set the customer details. If the agent is HomeLet Direct, then the customer is a PLL. $agentDatasource = new Datasource_Core_Agents(); $lettingAgent = $agentDatasource->getAgent($enquiryRow->AgentID); $params = Zend_Registry::get('params'); if ($lettingAgent->agentSchemeNumber != $params->homelet->defaultAgent) { $reference->customer = new Model_Referencing_CustomerMap(); $reference->customer->customerType = Model_Referencing_CustomerTypes::AGENT; $reference->customer->customerId = $lettingAgent->agentSchemeNumber; $reference->customer->legacyCustomerId = null; } else { $reference->customer = new Model_Referencing_CustomerMap(); $reference->customer->customerType = Model_Referencing_CustomerTypes::LANDLORD; if ($enquiryRow->landrefno != 0) { $reference->customer->legacyCustomerId = $enquiryRow->landrefno; } } $returnVal = $reference; } return $returnVal; }
/** * Sends an initial notification to the reference subject (tenant or guarantor). * * The initital notification sent to the reference subject advises them that their * reference is on the system and they can track it. * * @param mixed $enquiryId * The unique Enquiry identifier (internal or external). May be integer or string. * * @return boolean * Returns true on succesful sending of the notification, false otherwise. */ public function sendTatInvitation() { //Get the general parameters. $params = Zend_Registry::get('params'); $metaData = array(); $emailFromName = $params->tat->email->fromname; $emailFrom = $params->tat->email->from; $emailSubject = $params->tat->email->subject; $metaData['tatUrl'] = $params->url->tenantsTrackApplicationFromEmail; $metaData['homeLetUrl'] = $params->homelet->domain . '/'; // Ensure enquiry ID given out is an internal one $metaData['tenantIrn'] = $this->_reference->internalId; //Set the destination email address. $referenceSubjectContact = $this->_reference->referenceSubject->contactDetails; if (!empty($referenceSubjectContact->email1)) { $emailTo = $referenceSubjectContact->email1; } else { if (!empty($referenceSubjectContact->email2)) { $emailTo = $referenceSubjectContact->email2; } else { return false; } } //Set the reference subject name into the email body. $referenceSubjectName = $this->_reference->referenceSubject->name; $referenceSubjectNameString = $referenceSubjectName->firstName . ' ' . $referenceSubjectName->lastName; $metaData['tenantName'] = $referenceSubjectNameString; //Set the property address into the email body. $propertyAddress = $this->_reference->propertyLease->address; $propertyAddressString = ''; $propertyAddressString .= $propertyAddress->addressLine1 != '' ? "{$propertyAddress->addressLine1}\n" : ''; $propertyAddressString .= $propertyAddress->addressLine2 != '' ? "{$propertyAddress->addressLine2}\n" : ''; $propertyAddressString .= $propertyAddress->town != '' ? "{$propertyAddress->town}\n" : ''; $propertyAddressString .= $propertyAddress->postCode != '' ? "{$propertyAddress->postCode}\n" : ''; $metaData['propertyAddress'] = nl2br(substr($propertyAddressString, 0, -1)); $metaData['propertyAddressTxt'] = $propertyAddressString; //Put the letting agent name and ASN into the email body. if ($this->_reference->customer->customerType == Model_Referencing_CustomerTypes::LANDLORD) { $agentId = $params->homelet->defaultAgent; } else { $agentId = $this->_reference->customer->customerId; } $agentDatasource = new Datasource_Core_Agents(); $lettingAgent = $agentDatasource->getAgent($agentId); $lettingAgentNameString = $lettingAgent->name; $metaData['lettingAgentName'] = $lettingAgentNameString; $metaData['lettingAgentAsn'] = $lettingAgent->agentSchemeNumber; //Prepare the email. $emailer = new Application_Core_Mail(); $emailer->setTo($emailTo, $emailFromName); $emailer->setFrom($emailFrom, $emailFromName); $emailer->setSubject($emailSubject); $emailer->applyTemplate('tenants_tatInvitation', $metaData, false, '/email-branding/homelet/generic-with-signature-footer.phtml'); $emailer->applyTextTemplate('tenants_tatInvitationTxt', $metaData, false, '/email-branding/homelet/generic-with-signature-footer-txt.phtml'); //Send, update and return $success = $emailer->send(); if ($success) { //Update the notification log. $tatInvitationDatasource = new Datasource_Referencing_TatInvitation(); $tatInvitationDatasource->insertInvitation($this->_reference->externalId); $returnVal = true; } else { $returnVal = false; } return $returnVal; }
/** * Calculate quicker for this quote and return them - used by the ajax on the fly * * @return array Array of premiums */ public function calculateQuickPremiums() { $dsi = 0; $annualContentsCover = 0; $annualBuildingCover = 0; $contentsRates = array(); $buildingRates = array(); $annualEmergencyAssistance = 0; $annualRentGuarantee = 0; $annualLegalExpensesCover = 0; $dsiValues = array(); // Check to see if this quote has any products - if not we don't need to do anything :) if ($this->productCount() > 0) { // First we need the postcode for our property $propertiesDatasource = new Datasource_Insurance_Quote_Properties(); $properties = $propertiesDatasource->getByQuoteID($this->_quoteModel->ID); $postcode = $properties[0]['postcode']; // Check to see if we have an agents Rate ID $agentsRateID = 0; $agentsDatasource = new Datasource_Core_Agents(); $agent = $agentsDatasource->getAgent($this->getAgentSchemeNumber()); // If this agent has an active valid rate ID we can use it if (isset($agent->agentsRateID)) { if ($agent->agentsRateID == 5 || $agent->agentsRateID == 11) { $agentsRateID = $agent->agentsRateID; } } // Get the risk areas for LI+ // Then we need to get the LI+ risk areas for this postcode $riskAreasDatasource = new Datasource_Insurance_LandlordsPlus_RiskAreas(); $riskAreas = $riskAreasDatasource->getByPostcode($postcode); // Calculate the discounts/loadings to be applied based on the quote meta data $loadings = $this->_calculateLoadings(); // ** BUILDINGS COVER PREMIUMS ** // if ($this->hasProduct(self::BUILDING_COVER)) { $productMeta = $this->getProductMeta(self::BUILDING_COVER); $dsiValues = $this->_calculateDSI($postcode); $dsi = $dsiValues['rebuildValue']; // If we don't have a DSI - use the manually entered rebuild value if (isset($productMeta['rebuild_value']) && $productMeta['rebuild_value'] > 0) { $dsi = $productMeta['rebuild_value']; } if ($dsi > 0) { // and we need to get the rates for Buildings insurance $ratesDatasource = new Datasource_Insurance_LandlordsPlus_BuildingCover_Rates(); $buildingRates = $ratesDatasource->getByProperty($riskAreas['buildingsAreaID'], $productMeta['build_year'], $this->getStartDate()); // now we can calculate the premiums based on the DSI Value and the rates $grossRate = $buildingRates['gross']; $netRate = $buildingRates['net']; if (isset($productMeta['accidental_damage']) && $productMeta['accidental_damage'] == 'yes') { $grossRate = $grossRate + $buildingRates['grossAccidentalDamage']; $netRate = $netRate + $buildingRates['netAccidentalDamage']; } $grossRate = $grossRate * $loadings['buildingMultiplier']; $netRate = $netRate * $loadings['buildingMultiplier']; // Check to see if the property needs flood loadings applying $endorsements = $this->getEndorsements(); // See if the property is in a flood area with optional endorsement // If the endorsement is mandatory we don't charge extra - we just exclude the cover if ($endorsements['floodArea'] == true && $endorsements['floodOptional'] == true) { // Check to see if the customer has opted out of the flood cover $properties = $this->getProperties(); if ($properties[0]['exclude_flood_cover'] == 1) { } else { $annualBFlood = $buildingRates['grossFlood'] * ($dsi / 1000); $netBFlood = $buildingRates['netFlood'] * ($dsi / 1000); $grossRate = $grossRate + $buildingRates['grossFlood']; $netRate = $netRate + $buildingRates['netFlood']; } } $buildingRates['grossAfterLoadings'] = $grossRate; $buildingRates['netAfterLoadings'] = $netRate; $annualBuildingCover = $grossRate * ($dsi / 1000); } else { // We don't have a DSI and no rebuild value has been entered... oops!! // Todo: panic!! return ''; } } // ** UNFURNISHED CONTENTS COVER ** // if ($this->hasProduct(self::UNFURNISHED_CONTENTS_COVER)) { if ($agentsRateID != 0) { $annualContentsCover = 60; } else { $annualContentsCover = 72; } } // ** FURNISHED CONTENTS COVER ** // if ($this->hasProduct(self::CONTENTS_COVER)) { $productMeta = $this->getProductMeta(self::CONTENTS_COVER); $ratesDatasource = new Datasource_Insurance_LandlordsPlus_ContentsCover_Rates(); $contentsRates = $ratesDatasource->getByProperty($riskAreas['contentsAreaID'], $this->getStartDate()); if (isset($productMeta['accidental_damage']) && $productMeta['accidental_damage'] == 'yes') { $annualContentsCover = ($contentsRates['gross'] + $contentsRates['grossAccidentalDamage']) * $loadings['contentsMultiplier'] * ($productMeta['cover_amount'] / 1000); } else { $annualContentsCover = $contentsRates['gross'] * $loadings['contentsMultiplier'] * ($productMeta['cover_amount'] / 1000); } // Check to see if the property needs flood loadings applying $endorsements = $this->getEndorsements(); // See if the property is in a flood area with optional endorsement // If the endorsement is mandatory we don't charge extra - we just exclude the cover if ($endorsements['floodArea'] == true && $endorsements['floodOptional'] == true) { // Todo: Check to see if the customer has opted out of the flood cover $annualCFlood = $contentsRates['grossFlood'] * ($productMeta['cover_amount'] / 1000); $grossRate = $grossRate + $contentsRates['grossFlood']; $annualContentsCover += $annualCFlood; } } // ** EMERGENCY ASSISTANCE & BOILER AND HEATING COVER** // if ($this->hasProduct(self::EMERGENCY_ASSISTANCE) && (!$this->hasProduct(self::BUILDING_COVER) && !$this->hasProduct(self::CONTENTS_COVER))) { // Stand-alone emergency assistance if ($agentsRateID != 0) { $annualEmergencyAssistance = 90; } else { $annualEmergencyAssistance = 120; } } elseif ($this->hasProduct(self::BUILDING_COVER) || $this->hasProduct(self::CONTENTS_COVER)) { // Free emergency assistance included with buildings cover if ($this->hasProduct(self::BOILER_HEATING)) { $annualEmergencyAssistance = 60; } if ($this->hasProduct(self::BUILDING_COVER)) { $annualBuildingCover += 6.5; } else { $annualContentsCover += 6.5; } } // ** RENT GUARANTEE ** // if ($this->hasProduct(self::RENT_GUARANTEE)) { $productMeta = $this->getProductMeta(self::RENT_GUARANTEE); $annualRentGuarantee = $productMeta['monthly_rent'] * 0.36; } // ** LEGAL EXPENSES ** // if ($this->hasProduct(self::LEGAL_EXPENSES)) { if ($this->hasProduct(self::RENT_GUARANTEE)) { // Free Legal Expenses cover as part of Rent Guarantee $annualLegalExpensesCover = 0; } else { // Stand alone Legal Expenses cover $annualLegalExpensesCover = 114; } } if ($this->hasProduct(self::BUILDING_COVER)) { $dsiValues = $this->_calculateDSI($postcode); $calculatedDSI = $dsiValues['rebuildValue']; } else { $calculatedDSI = 0; } $premiums = array('calculatedDSIValue' => (double) $calculatedDSI, 'rebuildValue' => $dsi > 0 ? (double) $dsi : 0, 'grossAnnualBuildingCover' => (double) number_format($annualBuildingCover, 2, '.', ''), 'grossAnnualContentsCover' => (double) number_format($annualContentsCover, 2, '.', ''), 'grossAnnualEmergencyAssistance' => (double) number_format($annualEmergencyAssistance, 2, '.', ''), 'grossAnnualRentGuarantee' => (double) number_format($annualRentGuarantee, 2, '.', ''), 'grossAnnualLegalExpensesCover' => (double) number_format($annualLegalExpensesCover, 2, '.', '')); $premiums['totalGrossAnnualPremium'] = round($annualBuildingCover + $annualContentsCover + $annualEmergencyAssistance + $annualRentGuarantee + $annualLegalExpensesCover, 2); $premiums['totalGrossMonthlyPremium'] = round($premiums['totalGrossAnnualPremium'] / 12, 2); // Get IPT percentage $propertiesDatasource = new Datasource_Insurance_Quote_Properties(); $properties = $propertiesDatasource->getByQuoteID($this->_quoteModel->ID); $postcode = $properties[0]['postcode']; $taxDatasource = new Datasource_Core_Tax(); $tax = $taxDatasource->getTaxbyTypeAndPostcode('ipt', $postcode); $ipt = 1 + $tax['rate'] / 100; $premiums['totalGrossAnnualIPT'] = round($premiums['totalGrossAnnualPremium'] * $ipt - $premiums['totalGrossAnnualPremium'], 2); $premiums['totalGrossMonthlyIPT'] = round($premiums['totalGrossMonthlyPremium'] * $ipt - $premiums['totalGrossMonthlyPremium'], 2); return $premiums; } else { return ''; } }
/** * Helper function to populate the zend form elements with database data * * @param Zend_Form $pageForm form definition for this step * @param int $stepNum current step number * * @return void */ private function _formStepCommonPopulate($pageForm, $stepNum) { $this->view->stepNum = $stepNum; $this->view->stepMax = $this->_stepMax; // Check to see if the user is trying to skip ahead in the quote $pageSession = new Zend_Session_Namespace('landlords_insurance_quote'); $tooFarAhead = false; if ((!isset($pageSession->completed) || is_null($pageSession->completed)) && $stepNum != 1) { $tooFarAhead = true; $lastCompleted = 1; } elseif ($stepNum > 1) { // Check to see if any pages previous to the one the user's trying to get to are incomplete $tooFarAhead = false; for ($i = 1; $i < $stepNum; $i++) { if (!isset($pageSession->completed[$i]) || !$pageSession->completed[$i]) { $tooFarAhead = true; $lastCompleted = $i; break; } } } if ($tooFarAhead) { // Drop user onto page that needs completing $this->_helper->redirector->gotoUrl('/landlords/insurance-quote/step' . $lastCompleted); return false; } if ($stepNum > 1) { // Before we do ANYTHING we need to check to see if the email address entered matches a customer record // we already have - if it does we need to ask them to login before they proceed. $customerReferenceNumber = $this->_customerReferenceNumber; $customerManager = new Manager_Core_Customer(); $legacyCustomer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $customerReferenceNumber); $emailAddress = $legacyCustomer->getEmailAddress(); $customer = $customerManager->getCustomerByEmailAddress($emailAddress); if ($customer) { // There is already a customer entry for this email address - so we need to see if they are logged in // if not we need to force them to login $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer')); if ($auth->hasIdentity()) { $loggedInEmail = $auth->getStorage()->read()->email_address; if ($loggedInEmail != $customer->getEmailAddress()) { // They are logged in but not who they should be to do this quote $this->_helper->redirector->gotoUrl('/account/login?refer=landlords-insurance&step=' . $stepNum); return false; } } else { // TODO: Check that removing the login redirection will not break other processes // They aren't logged in and need to /*$this->_helper->redirector->gotoUrl('/account/login?refer=landlords-insurance&step='. $stepNum); return false;*/ } } } $formData = array(); // If step 1 and not in session (so producing a quick quote) - we need to pre-populate // a few bits if the customer is already logged into the site if ($stepNum == 1 && !isset($pageSession->CustomerRefNo)) { $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer')); if ($auth->hasIdentity()) { // Customer is logged in and starting a new quote - so we need to pre-populate the customers details from stored details $customerID = $auth->getStorage()->read()->id; $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $customerID); $formData['title'] = $customer->getTitle(); $formData['first_name'] = $customer->getFirstName(); $formData['last_name'] = $customer->getLastName(); $formData['phone_number'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE1); $formData['mobile_number'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE2); $formData['email_address'] = $customer->getEmailAddress(); $formData['date_of_birth_at'] = $customer->getDateOfBirthAt(); $pageForm->populate($formData); } } if (isset($this->_quoteID) && $this->_quoteID > 0) { $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($this->_quoteID); $premiums = $quoteManager->calculatePremiums(); if ($premiums != '') { $this->view->premiums = array('annual' => $premiums['totalGrossAnnualPremium'] + $premiums['totalGrossAnnualIPT'], 'monthly' => $premiums['totalGrossMonthlyPremium'] + $premiums['totalGrossMonthlyIPT']); $this->view->premiumsFull = $premiums; } $fees = $quoteManager->getFees(); $this->view->fees = $fees; switch ($stepNum) { case 1: $customerManager = new Manager_Core_Customer(); $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $quoteManager->getLegacyCustomerReference()); // Populate the customer details $titleOptions = LandlordsInsuranceQuote_Form_Subforms_PersonalDetails::$titles; if (in_array($customer->getTitle(), $titleOptions)) { $formData['title'] = $customer->getTitle(); } else { $formData['title'] = "Other"; $formData['other_title'] = $customer->getTitle(); } $formData['first_name'] = $customer->getFirstName(); $formData['last_name'] = $customer->getLastName(); $formData['phone_number'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE1); $formData['mobile_number'] = $customer->getTelephone(Model_Core_Customer::TELEPHONE2); $formData['email_address'] = $customer->getEmailAddress(); $dob = $customer->getDateOfBirthAt(); if (null != $dob && '0000-00-00' != $dob) { $formData['date_of_birth_at'] = Application_Core_Utilities::mysqlDateToUk($dob); } // Populate the correspondence address details $formData['cor_address_line1'] = $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE1); $formData['cor_address_line2'] = $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE2); $formData['cor_address_line3'] = $customer->getAddressLine(Model_Core_Customer::ADDRESSLINE3); $formData['cor_address_postcode'] = $customer->getPostcode(); $formData['country'] = $customer->getCountry(); // Populate the insured property address details $properties = $quoteManager->getProperties(); if (count($properties) > 0) { $formData['ins_address_line1'] = $properties[0]['line_1']; $formData['ins_address_line2'] = $properties[0]['line_2']; $formData['ins_address_line3'] = $properties[0]['town']; $formData['ins_address_postcode'] = $properties[0]['postcode']; $formData['owned_for'] = $properties[0]['ownership_length_id']; $formData['no_claims'] = $properties[0]['no_claims_years_id']; $formData['tenants_type'] = $properties[0]['tenant_type_id']; $formData['have_letting_agent'] = $quoteManager->getAgentSchemeNumber() != Manager_Core_Agent::filterAsn($quoteManager->getAgentSchemeNumber()) ? 'yes' : 'no'; $formData['through_letting_agent'] = $properties[0]['letting_agent_managed'] ? 'yes' : 'no'; // Check to see if this postcode is in a flood risk area - if it is then populate the exclude flood cover data // Populating this will also cause the question to be shown on the front end $landlordsRiskAreas = new Datasource_Insurance_LandlordsPlus_RiskAreas(); $riskAreas = $landlordsRiskAreas->getByPostcode($properties[0]['postcode']); if ($riskAreas['floodArea'] == '600') { $formData['exclude_flood_cover'] = $properties[0]['exclude_flood_cover'] ? 'no' : 'yes'; // Backwards true/false stuff - I'm sooo sorry :( } } // Populate agent details if one has been chosen $agentSchemeNumber = Manager_Core_Agent::filterAsn($quoteManager->getAgentSchemeNumber()); $defaultASN = $this->_params->homelet->defaultAgent; if ($formData['have_letting_agent'] == 'yes') { $agents = new Datasource_Core_Agents(); $agent = $agents->getAgent($agentSchemeNumber); $formData['letting_agent_name'] = $agent->name; $formData['letting_agent_town'] = $agent->town; $formData['letting_agent_asn'] = $agent->agentSchemeNumber; // Fix for Redmine Ref. #10511: $agentDropdown = $pageForm->subform_lettingagent->letting_agent; $agentDropdown->setMultiOptions(array($agent->agentSchemeNumber => $agent->name . ', ' . $agent->town)); $formData['letting_agent'] = $agent->agentSchemeNumber; } // Load the policy start date $startDate = $quoteManager->getStartDate(); if ($startDate != '' && $startDate != '0000-00-00') { $formData['policy_start'] = substr($startDate, 8, 2) . '/' . substr($startDate, 5, 2) . '/' . substr($startDate, 0, 4); } // If step1 has been marked complete - we can assume they said yes to the IDD question $pageSession = new Zend_Session_Namespace('landlords_insurance_quote'); if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) { $formData['idd'] = true; } // Data Protection section $customerReferenceNumber = $customer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER); $dpaManager = new Manager_Core_DataProtection(); $dpaItems = $dpaManager->getItems($customerReferenceNumber, Model_Core_DataProtection_ItemEntityTypes::INSURANCE); foreach ($dpaItems as $currentItem) { switch ($currentItem->constraintTypeId) { case Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_PHONEANDPOST: if ($currentItem->isAllowed) { $formData['dpa_phone_post'] = 0; } else { $formData['dpa_phone_post'] = 1; } break; case Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_SMSANDEMAIL: if ($currentItem->isAllowed) { $formData['dpa_sms_email'] = 0; // For Redmine Ref #8003, "Updated marketing preference questions on online quotes" } else { $formData['dpa_sms_email'] = 1; // For Redmine Ref #8003, "Updated marketing preference questions on online quotes" } break; case Model_Core_DataProtection_ItemConstraintTypes::MARKETING_BY_THIRDPARTY: if ($currentItem->isAllowed) { $formData['dpa_resale'] = 1; } else { $formData['dpa_resale'] = 0; } break; } } case 2: // If step2 has been marked complete - we can assume they said no to the questions unless // they've been set in the quote manager if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) { $formData['need_building_insurance'] = 'no'; $formData['need_contents_insurance'] = 'no'; } if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER)) { $formData['need_building_insurance'] = 'yes'; $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER); $formData['building_built'] = $productMeta['build_year']; $formData['building_bedrooms'] = $productMeta['bedroom_quantity']; $formData['building_type'] = $productMeta['building_type']; $formData['building_insurance_excess'] = $productMeta['excess']; $formData['building_accidental_damage'] = $productMeta['accidental_damage']; $quote = $quoteManager->getModel(); if ((int) $productMeta['rebuild_value'] > 0) { // There's a manually entered rebuild value - need to work out if it is because they // chose £500k+ - or if it's because we don't have a dsi $premiums = $quoteManager->calculatePremiums(); if ($premiums['calculatedDSIValue'] > 0) { $formData['override_dsi'] = 1; } $formData['building_value'] = $productMeta['rebuild_value']; } } if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER) || $quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::UNFURNISHED_CONTENTS_COVER)) { $formData['need_contents_insurance'] = 'yes'; if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) { $formData['property_furnished'] = 'yes'; $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER); $formData['contents_amount'] = $productMeta['cover_amount']; $formData['contents_excess'] = $productMeta['excess']; $formData['contents_accidental_damage'] = $productMeta['accidental_damage']; } else { $formData['property_furnished'] = 'no'; } } break; case 3: if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) { $formData['need_emergency_assistance'] = 'no'; $formData['need_prestige_rent_guarantee'] = 'no'; $formData['need_legal_expenses'] = 'no'; $formData['need_boiler_heating'] = 'no'; } // If we have contents/buildings cover then EAS is already included for free so we can hide the form if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER) || $quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) { // Change the subforms view script to one that just says it's already included for free // yeah yeah.. this aint pretty :( $emergencyAssistanceForm = $pageForm->getSubForm('subform_emergencyassistance'); $emergencyAssistanceForm->setDecorators(array(array('ViewScript', array('viewScript' => 'subforms/emergency-assistance-free.phtml')))); if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BOILER_HEATING)) { $formData['need_boiler_heating'] = 'yes'; } } else { // We can allow stand-alone EAS - so we hide the boiler and heating section // yes... this is waaay too complex... I know :( $pageForm->removeSubForm('subform_boilerheating'); if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::EMERGENCY_ASSISTANCE)) { $formData['need_emergency_assistance'] = 'yes'; } } if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::RENT_GUARANTEE)) { $formData['need_prestige_rent_guarantee'] = 'yes'; $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::RENT_GUARANTEE); $formData['rent_amount'] = $productMeta['monthly_rent']; } elseif ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::LEGAL_EXPENSES)) { $formData['need_legal_expenses'] = 'yes'; } break; case 4: if (isset($pageSession->completed[$stepNum]) && $pageSession->completed[$stepNum] == true) { // Load underwriting answers from the database as they've already been answered $answersManager = new Manager_Insurance_Answers(); $quote = $quoteManager->getModel(); $policyNumber = $quote->legacyID; $customerReferenceNumber = $quote->legacyCustomerID; $answers = $answersManager->getUnderwritingAnswers($policyNumber); foreach ($answers as $answer) { switch ($answer->getQuestionNumber()) { case '53': $formData['declaration1'] = $answer->getAnswer(); break; case '54': $formData['declaration2'] = $answer->getAnswer(); break; case '55': $formData['declaration2b'] = $answer->getAnswer(); break; case '56': $formData['declaration2c'] = $answer->getAnswer(); break; case '57': $formData['declaration2d'] = $answer->getAnswer(); break; case '58': $formData['declaration3'] = $answer->getAnswer(); break; case '59': $formData['declaration4'] = $answer->getAnswer(); break; case '60': $formData['declaration6'] = $answer->getAnswer(); break; case '61': $formData['declaration7'] = $answer->getAnswer(); break; case '62': $formData['declaration8'] = $answer->getAnswer(); break; case '63': $formData['declaration9'] = $answer->getAnswer(); break; case '64': $formData['declaration10'] = $answer->getAnswer(); break; } } // Also need to see if they said yes or no to bank interest on the propery… $bankInterestManager = new Manager_Insurance_LegacyBankInterest(); $bankInterestArray = $bankInterestManager->getAllInterests($policyNumber, $customerReferenceNumber); $model = array(); if (!empty($bankInterestArray)) { $formData['declaration11'] = 'yes'; } else { $formData['declaration11'] = 'no'; } // They must have agreed to the declaration or they wouldn't have been able to continue $formData['declaration_confirmation'] = 'yes'; } break; case 5: // Payment Selection section if (isset($pageSession->paymentSelectionDetails) && is_array($pageSession->paymentSelectionDetails)) { $formData = $pageSession->paymentSelectionDetails; } break; } } $pageForm->populate($formData); return true; }
/** * Gets the details for a specific agent * * @return void */ public function getagentdetailsAction() { $output = array(); $request = $this->getRequest(); $postdata = $request->getPost(); $agentLookup = new Datasource_Core_Agents(); $output['data'] = $agentLookup->getDetailsByASN($postdata['letting_agent_asn']); $output['errorJs'] = ''; $output['errorCount'] = 0; $output['errorHtml'] = ''; echo Zend_Json::encode($output); }
/** * Set the agent scheme number * * @param int $asn Agent scheme number * * @return void **/ public function setAgentSchemeNumber($asn) { $this->_quoteModel->agentSchemeNumber = $asn; $agent = new Datasource_Core_Agents(); $this->_quoteModel->agentRateSetID = $agent->getRatesetID($this->_quoteModel->agentSchemeNumber); // Premiums are dependant on the agent scheme number so we need to recalculate premiums before saving $this->calculatePremiums(); $this->_save(); }