/** * 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); }
/** * Action for the Confirmation of a Successful Credit card Payment * * @return void * @todo The company name need to be fetched from branding * */ public function ddconfirmationAction() { $policyNumber = $this->getRequest()->getParam("pn") ? $this->getRequest()->getParam("pn") : $this->_policyNumber; $quoteNumber = str_replace('P', 'Q', $policyNumber); // Check to see if this quote has already been converted to a policy - if it has we don't want to do any of the below $policyManager = new Manager_Insurance_LegacyPolicy(); $policy = $policyManager->getByPolicyNumber($policyNumber); if (is_null($policy)) { $refNo = $this->_customerReferenceNumber; $params = Zend_Registry::get('params'); // Set up the validators and filters $filters = array(); $validators = array(); $request = $this->getRequest(); $input = new Zend_Filter_Input($filters, $validators, $request->getParams()); if ($input->isValid()) { // Update Pay Status $quote = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $this->_policyNumber); $quoteObject = new Model_Insurance_LegacyQuote(); $quoteObject = $quote->getQuoteObject(); $quoteObject->startTime = date("h:j:s"); $quoteObject->payStatus = "UpToDate"; $quote->update($quoteObject); /*$quoteObject->startTime = date("h:j:s"); $quoteObject->payStatus = "UpToDate"; $quote->update($quoteObject);*/ $schedule = new Manager_Insurance_Schedule(); $schedule->save($refNo, $quote); $quoteToPolicyManager = new Manager_Insurance_TenantsContentsPlus_QuoteToPolicy(); $quoteToPolicyManager->changeQuoteToPolicy($quoteNumber); //Update the WebLeads $webLeadManager = new Manager_Core_WebLead(); $webLeadSummary = $webLeadManager->getSummary($this->_webLeadSummaryId); $webLeadSummary->quoteNumber = $policyNumber; $webLeadSummary->status = Model_Core_WebLeadStatus::COMPLETE; $webLeadSummary->completedTime = $this->_offsetDate(); $webLeadManager->updateSummary($webLeadSummary); $agentSchemeNumber = Manager_Core_Agent::filterAsn($quote->getAgentSchemeNumber()); // Transaction is complete unset the Session to prevent navigation to other steps again Zend_Session::namespaceUnset('tenants_insurance_quote'); // Document management stuff, only runs on first conversion of quote -> policy $documentManager = new Manager_Insurance_Document(); $documentManager->createAndPostDocument($policyNumber, Model_Insurance_TenantsContentsPlus_DocumentTypes::NEW_POLICY_DOCS); $documentArray = $documentManager->getDocuments($policyNumber, Model_Insurance_TenantsContentsPlus_DocumentTypes::NEW_POLICY_DOCS); $firstDocument = $documentArray[0]; // Put document number in the view, on any later page loads to the same URL this part will not be available for better security if (!is_null($firstDocument)) { $this->view->documentNumber = $firstDocument->request_hash; } } } else { $agentSchemeNumber = Manager_Core_Agent::filterAsn($policy->agentSchemeNumber); } $disbursement = new Manager_Core_Disbursement(); $disbursement->createTermImage($policyNumber); $params = Zend_Registry::get('params'); // Put domain name of the legacy server in the view $this->view->domain = $params->homelet->legacyDomain; $whiteLabelManager = new Manager_Core_WhiteLabel(); $whiteLabelData = new Model_Core_WhiteLabel(); $whiteLabelData = $whiteLabelManager->fetchByAgentSchemeNumber($agentSchemeNumber); $this->view->companyName = $whiteLabelData->companyName; $this->view->companyName = "HomeLet"; // Put Policy number in the view $this->view->policyNumber = $policyNumber; $this->view->openingTimes = $params->cms->openingtimes->insurance->tenants; // Extra values passed into view for Google Analytics commerce tracking: if (is_null($policy)) { $policy = $policyManager->getByPolicyNumber($policyNumber); } $this->view->policy = $policy; // Policy object // todo: Fix disgusting way of passing additional data through two chained views. $extraVars = new stdClass(); $monthMultiplier = strtolower($policy->paySchedule) == 'monthly' ? 12 : 1; $extraVars->quoteAnnual = $policy->quote * $monthMultiplier; $extraVars->iptAnnual = $policy->ipt * $monthMultiplier; $this->view->extraVars = $extraVars; }