private function _doMail($data)
 {
     $pageSession = new Zend_Session_Namespace('portfolio_insurance_quote');
     $customerRefNo = $pageSession->CustomerRefNo;
     // Get Customer
     $customerManager = new Manager_Insurance_Portfolio_LegacyCustomer();
     $customerObject = new Model_Insurance_Portfolio_LegacyCustomer();
     $customerObject = $customerManager->fetchByRefNo($customerRefNo);
     // Get Properties
     $propertyManager = new Manager_Insurance_Portfolio_Property();
     $properties = array();
     // Fetch all the properties related to this customer refNo
     $properties = $propertyManager->fetchAllProperties($customerRefNo)->toArray();
     $propertyHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/property-details.phtml', $properties);
     // Fetch claims releted to this customer refNo
     $claimsManager = new Manager_Insurance_Portfolio_PreviousClaims();
     $claims = $claimsManager->fetchWithClaimTypes($customerRefNo);
     $claimsHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/claims.phtml', $claims);
     // Fetch bank interest related to this customer refNo
     $bankInterestManager = new Manager_Insurance_Portfolio_BankInterest();
     $bankInterest = $bankInterestManager->fetchAllInterests($customerRefNo);
     $bankInterestHtml = $this->view->partialLoop('portfolio-insurance-quote/partials/email-templates/bank-interest.phtml', $bankInterest);
     $uwManager = new Manager_Insurance_Portfolio_UnderwritingAnswers();
     $uwAnswers = $uwManager->fetchByRefNo($customerRefNo);
     // Merge the claim and Interest info into the UW template
     $uwQuestionsHtml = $this->view->partial('portfolio-insurance-quote/partials/email-templates/uw-questions.phtml', array('claimsHtml' => $claimsHtml, 'bankInterestHtml' => $bankInterestHtml, 'uwAnswers' => $uwAnswers->toArray()));
     // Merge all the html together
     $mailBody = $this->view->partial('portfolio-insurance-quote/partials/email-templates/emailQuote.phtml', array('theData' => $data, 'theCustomer' => $customerObject->toArray(), 'propertyHtml' => $propertyHtml, 'uwQuestionsHtml' => $uwQuestionsHtml));
     // Get some parameter stuffs
     $params = Zend_Registry::get('params');
     $emailArray = explode(",", $params->email->portfolioAdmin);
     $toAddress = $emailArray[0];
     $ccAddress = $emailArray[1];
     $fromAddress = $params->email->noreply;
     // Mail that bad boy
     if (isset($data['referred'])) {
         $referred = " - REFERRED";
     }
     $email = new Application_Core_Mail();
     $email->setFrom($fromAddress, "PORTFOLIO NEW BUSINESS {$referred}");
     $email->setTo($toAddress, "Underwriting");
     $email->setCC($ccAddress);
     $email->setSubject("Portfolio Website Query - ref: {$customerRefNo}");
     $email->setBodyHtml($mailBody);
     $email->send();
     return;
 }
 /**
  * remove bank interest
  * @param POST vars
  * @return JSON Encoded html
  * @author John Burrin
  * @since 1.3
  * http://homelet.centos5.dev/json/portfolio-portfolio/remove-bank-interest
  */
 public function removeBankInterestAction()
 {
     $pageSession = new Zend_Session_Namespace('portfolio_insurance_quote');
     $customerReferenceNumber = $pageSession->CustomerRefNo;
     $ajaxForm = new Form_PortfolioInsuranceQuote_claimsDialog();
     $return = array();
     $request = $this->getRequest();
     $postdata = $request->getPost();
     $return['success'] = false;
     if ($ajaxForm->isValid($postdata)) {
         $interestManager = new Manager_Insurance_Portfolio_BankInterest();
         $interestManager->removeInterest($postdata['id']);
         // Do the update stuffs
         // Get the properties to shove back into the page
         $interestArray = $interestManager->fetchAllInterests($customerReferenceNumber);
         if ($interestArray->count() > 0) {
             $return['html'] = $this->view->partialLoop('portfolio-insurance-quote/partials/bank-interest.phtml', $interestArray);
         } else {
             $return['html'] = '<em>None</em>';
         }
         $return['success'] = true;
     } else {
         // TODO: This shouldn't do this should it?
         Zend_Debug::dump($ajaxForm->getMessages());
     }
     echo Zend_Json::encode($return);
 }