/** * Helper function for generating possessions summary HTML fragment * * @return string * @munt 10 HTML in strings? REALLY? That's what partials are for. Also in-line styles. Seriously. I'm going grey because of this!! - PB */ public function yourPossessions() { $output = ''; $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $possession = new Datasource_Insurance_Policy_SpecPossessions($pageSession->PolicyNumber); $possessionsData = $possession->listPossessions(); if (count($possessionsData) > 0) { $output .= '<table class="table table-bordered table-condensed table-possessions">'; $output .= '<thead>'; $output .= ' <tr>'; $output .= ' <th>Items you have added to your policy</th>'; $output .= ' <th colspan="2">Value</th>'; $output .= ' </tr>'; $output .= '</thead>'; $output .= '<tbody>'; foreach ($possessionsData as $key => $possession) { $output .= ' <tr>'; // Line container with bottom edge $output .= " <td class='description'>{$possession['category']} - Description: {$possession['description']}</td>"; $output .= " <td class='price'>£" . number_format(doubleval($possession['value']), 2) . "</td>"; $output .= " <td><a id=\"removePossession{$key}\" onclick=\"removePossessionClick('{$key}'); return false;\" class=\"tertiary-colour\" href=\"#\">Remove item</a></td>"; $output .= " </tr>"; } $output .= '</tbody>'; $output .= "</table>"; } return $output; }
/** * Helper function for generating view breakdown HTML fragment * * @param bool $showAdminFees Optional switch to include admin fees, defaults to false * * @return string */ public function viewBreakdown($includeAdminFees = true) { // Get customer ref no and policy number $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $this->_customerReferenceNumber = $pageSession->CustomerRefNo; $this->_policyNumber = $pageSession->PolicyNumber; // Get premium values for quote $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $this->_policyNumber); $premiums = $quoteManager->calculatePremiums(); $this->view->premiums = $premiums; // Get cover amounts $this->view->contentsCoverAmount = $quoteManager->getCoverAmount(Manager_Insurance_TenantsContentsPlus_Quote::CONTENTS); $this->view->bicyclesCoverAmount = $quoteManager->getCoverAmount(Manager_Insurance_TenantsContentsPlus_Quote::PEDALCYCLES); $this->view->specifiedPossessionsCoverAmount = $quoteManager->getCoverAmount(Manager_Insurance_TenantsContentsPlus_Quote::SPECIFIEDPOSSESSIONS); $this->view->unspecifiedPossessionsCoverAmount = $quoteManager->getCoverAmount(Manager_Insurance_TenantsContentsPlus_Quote::UNSPECIFIEDPOSSESSIONS); // Get any sharer occupation details $sharersManager = new Manager_Insurance_TenantsContentsPlus_Sharers(); $sharerData = $sharersManager->getSharers($this->_policyNumber); $this->view->sharer1 = !is_null($sharerData) ? $sharerData->getSharerOccupation(1) : ''; $this->view->sharer2 = !is_null($sharerData) ? $sharerData->getSharerOccupation(2) : ''; // Get specified possessions info $possession = new Datasource_Insurance_Policy_SpecPossessions($this->_policyNumber); $this->view->possessions = $possession->listPossessions(); // Get bicycle info $bike = new Datasource_Insurance_Policy_Cycles($this->_customerReferenceNumber, $this->_policyNumber); $this->view->bicycles = $bike->listBikes(); // Get Current IPT percentage $quote = $quoteManager->getQuoteObject(); $postcode = $quote->propertyPostcode; $taxDatasource = new Datasource_Core_Tax(); $tax = $taxDatasource->getTaxbyTypeAndPostcode('ipt', $postcode); $ipt = 1 + $tax['rate']; // Get admin fees, if required if ($includeAdminFees) { $fees = $quoteManager->getFees(); $this->view->feeMonthly = $fees->tenantspMonthlyFee; $this->view->feeAnnual = 0; // TODO: parameterise? Legacy DB and fee object currently don't handle annual fees } else { $this->view->feeMonthly = 0; $this->view->feeAnnual = 0; } $this->view->includeAdminFees = $includeAdminFees; // Return partial view HTML return $this->view->partial('partials/view-breakdown.phtml', $this->view); }
/** * Implements abstract method from superclass - refer to superclass for description. */ public function getReferralReasons($policyNumber) { $referralReasons = array(); $params = Zend_Registry::get('params'); $quote = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $policyNumber); if ($quote->getPolicyName() == 'tenantsp') { //Test 1: If the cover is greater than the threshold, then refer. $contentsAmount = $quote->getPolicyOptionAmountCovered('contentstp'); $contentsThreshold = new Zend_Currency(array('value' => $params->uw->rt->tenantsp->contents, 'precision' => 0)); if ($contentsAmount >= $contentsThreshold) { $referralReasons[] = $params->uw->rr->tenantsp->cover; } //Test 2: If claim values are greater than 1000 then refer. if (empty($this->_previousClaimsModel)) { $this->_previousClaimsModel = new Datasource_Insurance_PreviousClaims(); } $previousClaimsArray = $this->_previousClaimsModel->getPreviousClaims($quote->getRefno()); if (!empty($previousClaimsArray)) { //Tenant has one or more claims. Add the totals together to see if they exceed //the threshold. $claimsTotal = new Zend_Currency(array('value' => 0, 'precision' => 2)); foreach ($previousClaimsArray as $previousClaim) { $claimsTotal->add($previousClaim->getClaimValue()); } //Test against the previous claims threshold $claimsThreshold = new Zend_Currency(array('value' => $params->uw->rt->tenantsp->claimsThreshold, 'precision' => 2)); if ($claimsTotal->isMore($claimsThreshold)) { $referralReasons[] = $params->uw->rr->tenantsp->previousClaims; } } //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."); } foreach ($answersArray as $currentAnswer) { //Identify if the current answer is one that should be checked. if (in_array($currentAnswer->getQuestionNumber(), $params->uw->rt->tenantsp->checkAnswer->toArray())) { $answer = $currentAnswer->getAnswer(); if ($answer == Model_Insurance_Answer::YES) { $referralReasons[] = $params->uw->rr->tenantsp->answer; } } } //Test 4: pedal cycles over 1500 $pedalCyclesModel = new Datasource_Insurance_Policy_Cycles($quote->getRefno(), $policyNumber); $pedalCyclesArray = $pedalCyclesModel->listBikes(); if (!empty($pedalCyclesArray)) { $pedalCycleThreshold = new Zend_Currency(array('value' => $params->uw->rt->tenantsp->pedalCycle, 'precision' => 2)); foreach ($pedalCyclesArray as $currentPedalCycle) { //Compare the pedal cycle values in Zend_Currency format for simplity. $currentCycleValue = new Zend_Currency(array('value' => $currentPedalCycle['value'], 'precision' => 2)); if ($currentCycleValue->isMore($pedalCycleThreshold)) { $referralReasons[] = $params->uw->rr->tenantsp->pedalCycle; } } } //Test 5: specified possessions greater than threshold $specPossessionsModel = new Datasource_Insurance_Policy_SpecPossessions($policyNumber); $specPossessionsArray = $specPossessionsModel->listPossessions(); if (!empty($specPossessionsArray)) { //Wrap the threshold parameter in a Zend_Currency object for easier comparisons. $specPossessionThreshold = new Zend_Currency(array('value' => $params->uw->rt->tenantsp->specPossession, 'precision' => 2)); //Cycle through each specpossession... foreach ($specPossessionsArray as $currentSpecPossession) { //Wrap the current specpossession value in a Zend_Currency for easier comparision. $currentSpecPossessionValue = new Zend_Currency(array('value' => $currentSpecPossession['value'], 'precision' => 2)); //Determine if the threshold is exceeded: if ($currentSpecPossessionValue->isMore($specPossessionThreshold)) { $referralReasons[] = $params->uw->rr->tenantsp->specPossession; } } } } else { throw new Zend_Exception("Invalid product."); } return $referralReasons; }