/**
  * Build and send e-mail.
  *
  * @param RentRecoveryPlusReferral $referral
  */
 private function buildAndSendEmail(RentRecoveryPlusReferral $referral)
 {
     $toAddress = $this->configHandler->connect->settings->rentRecoveryPlus->referral->emailToAddress;
     $fromAddress = $this->configHandler->connect->settings->rentRecoveryPlus->referral->emailFromAddress;
     $toName = $this->configHandler->connect->settings->rentRecoveryPlus->referral->emailToName;
     $fromName = $this->configHandler->connect->settings->rentRecoveryPlus->referral->emailFromName;
     $this->mailManager->setTo($toAddress, $toName)->setFrom($fromAddress, $fromName)->setSubject($this->getEmailSubject($referral))->setBodyText($this->getEmailBodyText($referral))->send();
 }
 /**
  * check customer registration and carry on the registration process if it is not completed 
  *
  * Returns True if valid, false otherwise.
  *
  * @param string $email_address
  *
  * @return int
  */
 public function checkRegister($refno, $email, $isChangeEmail)
 {
     (string) ($refno = preg_replace('/X/', '', $refno));
     $customermgr = new Manager_Core_Customer();
     $customer = $customermgr->getCustomerByEmailAddress($email);
     $params = Zend_Registry::get('params');
     $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false);
     $digest = $mac->generate(array('email' => $email));
     $activationLink = 'refno=' . $refno . '&' . 'email=' . $email . '&' . 'mac=' . $digest;
     $customerMap = new Datasource_Core_CustomerMaps();
     if ($customer) {
         if (!$customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $refno)) {
             $customermgr->linkLegacyToNew($refno, $customer->getIdentifier(Model_Core_Customer::IDENTIFIER));
         }
         if (!$customer->getEmailValidated()) {
             $mail = new Application_Core_Mail();
             $mail->setTo($email, null);
             $mail->setFrom('*****@*****.**', 'HomeLet');
             $mail->setSubject('My HomeLet account validation');
             $mail->applyTemplate('core/account-validation', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $customer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
             $mail->applyTextTemplate('core/account-validationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $customer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
             // Send email
             $mail->send();
             return 1;
         } else {
             return 0;
         }
     } else {
         if ($isChangeEmail) {
             $cMap = $customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $refno);
             if ($cMap) {
                 $customer = $customermgr->getCustomer(Model_Core_Customer::IDENTIFIER, $cMap->getIdentifier());
                 $customer->setEmailAddress($email);
                 $customermgr->updateCustomer($customer);
                 $legacyids = $customerMap->getLegacyIDs($customer->getIdentifier());
                 foreach ($legacyids as $legacyid) {
                     if ($legacyid != $refno) {
                         $customer = $customermgr->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyid);
                         $customer->setEmailAddress($email);
                         $customermgr->updateCustomer($customer);
                     }
                 }
                 return 0;
             }
         }
         $oldCustomer = $customermgr->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $refno);
         $mail = new Application_Core_Mail();
         $mail->setTo($email, null);
         $mail->setFrom('*****@*****.**', 'HomeLet');
         $mail->setSubject("Don't forget to register your My HomeLet account");
         $mail->applyTemplate('core/partial-registration', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $oldCustomer->getFirstName(), 'templateId' => 'HL2469 12-12', 'heading' => 'Get even more with your My HomeLet account', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
         $mail->applyTextTemplate('core/partial-registrationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $oldCustomer->getFirstName(), 'templateId' => 'HL2469 12-12', 'heading' => 'Get even more with your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
         // Send email
         $mail->send();
         return 2;
     }
 }
 public function contactUsAction()
 {
     $filters = array('name' => 'StringTrim', 'tel' => 'StringTrim', 'email' => 'StringTrim', 'enquiry' => 'StringTrim');
     $validators = array('name' => 'NotEmpty', 'tel' => 'NotEmpty', 'email' => 'NotEmpty', 'enquiry' => 'NotEmpty');
     $input = new Zend_Filter_Input($filters, $validators, $_POST);
     $returnArray = array();
     if ($input->isValid()) {
         $emailer = new Application_Core_Mail();
         $params = Zend_Registry::get('params');
         $emailer->setTo($params->email->contactUs, 'HomeLet');
         $emailer->setFrom($input->email, $input->name);
         $emailer->setSubject('HomeLet - Contact Us Form');
         $bodyHtml = 'Name : ' . $input->name . '<br />';
         $bodyHtml .= 'Email : ' . $input->email . '<br />';
         $bodyHtml .= 'Tel : ' . $input->tel . '<br />';
         $bodyHtml .= 'Enquiry : <pre>' . $input->enquiry . '</pre><br />';
         $emailer->setBodyHtml($bodyHtml);
         if ($emailer->send()) {
             // Email sent successfully
             $returnArray['success'] = true;
             $returnArray['errorMessage'] = '';
         } else {
             $returnArray['success'] = false;
             $returnArray['errorMessage'] = 'Problem sending email.';
         }
     } else {
         $returnArray['success'] = false;
         $returnArray['errorMessage'] = $input->getMessages();
     }
     echo Zend_Json::encode($returnArray);
 }
Exemplo n.º 4
0
 /**
  * Sends a notification email to underwriting with referral details.
  *
  * This method provides a convenient way of notifying underwriting when
  * a customer has failed the underwriting critera during a quote, MTA or
  * renewal.
  *
  * @param string $policyNumber
  * The quote/policynumber to include in the email.
  *
  * @param string $refNo
  * The customer reference number to include in the email.
  *
  * @return boolean
  * Returns true if the email was successfully sent, false otherwise.
  */
 public function notifyUnderwriting($policyNumber, $refNo)
 {
     //Get the necessary parameters.
     $params = Zend_Registry::get('params');
     $emailTo = $params->uw->re->to;
     $emailFromName = $params->uw->re->fromname;
     $emailFrom = $params->uw->re->from;
     $emailSubject = $params->uw->re->subject;
     if ('Other' === $this->_reason) {
         $emailBody = $params->uw->re->other_body;
     } else {
         $emailBody = $params->uw->re->body;
     }
     //Prepare the email.
     $emailer = new Application_Core_Mail();
     $emailer->setTo($emailTo, $emailFromName);
     $emailer->setFrom($emailFrom, $emailFromName);
     $emailSubject = preg_replace("/\\[--POLNO--\\]/", $policyNumber, $emailSubject);
     $emailer->setSubject($emailSubject);
     $emailBody = preg_replace("/\\[--POLNO--\\]/", $policyNumber, $emailBody);
     $emailBody = preg_replace("/\\[--REFNO--\\]/", $refNo, $emailBody);
     $emailer->setBodyText($emailBody);
     $success = $emailer->send();
     if ($success) {
         //Update the notification log.
         $underwritingEmailLog = new Datasource_Core_UnderwritingEmailLog();
         $underwritingEmailLog->insertNotification(new Zend_Date(), $policyNumber, $emailBody);
     }
     return $success;
 }
Exemplo n.º 5
0
 public function saveAction()
 {
     if ($this->getRequest()->isPost()) {
         $password1 = $this->getRequest()->getPost('password1');
         $password2 = $this->getRequest()->getPost('password2');
         if ($password1 != $password2) {
             $return['status'] = 'error';
             $return['errorMessage'] = 'Passwords do not match. Please re-enter';
         } else {
             $customerManager = new Manager_Core_Customer();
             $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
             $legacyCustomerReference = $pageSession->CustomerRefNo;
             // This will create a customer record as we don't currently have one (only a legacy one)
             $customerID = $customerManager->linkLegacyToNew($legacyCustomerReference, null, Model_Core_Customer::TENANT);
             // Now we need to retreive the newly created customer and update the password
             $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $customerID);
             $customer->setPassword($password1);
             $customerManager->updateCustomer($customer);
             // Email the new customer to give them their details
             $metaData = array('name' => $customer->getFirstName(), 'quoteNumber' => $pageSession->PolicyNumber);
             // Log the customer in
             $auth = Zend_Auth::getInstance();
             $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
             $adapter = $customerManager->getAuthAdapter(array('password' => $this->getRequest()->getPost('password1'), 'email' => $customer->getEmailAddress()));
             $result = $auth->authenticate($adapter);
             if (!$result->isValid()) {
                 // This really shouldn't ever happen as we've just created the customer!!
             } else {
                 $storage = $auth->getStorage();
                 $storage->write($adapter->getResultRowObject(array('title', 'first_name', 'last_name', 'email_address', 'id')));
             }
             $emailer = new Application_Core_Mail();
             $emailer->setTo($customer->getEmailAddress(), $customer->getFirstName() . ' ' . $customer->getLastName())->setSubject('Homelet - Saved Tenants Contents Insurance Quote')->applyTemplateWithoutFooter('tenantsinsurancequote_saved', $metaData);
             $emailer->send();
             $return['status'] = 'saved';
         }
         echo Zend_Json::encode($return);
     }
 }
Exemplo n.º 6
0
 public function emailCompanyWithAttachments($toAddress, $content, $filename)
 {
     $emailer = new Application_Core_Mail();
     $emailer->setTo($toAddress, $toAddress);
     $emailer->setFrom('*****@*****.**', '*****@*****.**');
     $emailer->setSubject('Company Application');
     $emailer->setBodyText($content);
     // Attach all files from detailAttachments
     $emailer->addAttachment($filename, substr($filename, strrpos($filename, '/') + 1));
     // Send and set returnval
     $success = $emailer->send();
     if ($success) {
         $returnVal = true;
     } else {
         $returnVal = false;
     }
     return $returnVal;
 }
Exemplo n.º 7
0
 public function sendPdfAction()
 {
     // Check user is logged in to get ASN from
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session('hl_connect'));
     if ($auth->hasIdentity()) {
         // Fetch ASN and agent user ID
         $asn = $auth->getStorage()->read()->agentschemeno;
         $userId = $auth->getStorage()->read()->agentid;
         $request = $this->getRequest();
         if (!is_null($request->getParam('filename'))) {
             $filename = $request->getParam('filename');
             // Is this a special agent application form that requires content injection and is sent to a specific agent user?
             if (preg_match('/agent-form\\?form=([\\w\\-]+)$/i', $filename, $matches) > 0) {
                 // Yes, requires agent content injection and sending
                 $formName = $matches[1];
                 $agentFormManager = new Manager_Connect_AgentForm();
                 $agentFormManager->populateAndOuput($formName, $asn, $userId, 'email');
                 echo "{\"successMessage\":\"Email sent\"}\n";
                 exit;
             } else {
                 // Standard PDF, load and send as-is
                 $filters = array('*' => array('StringTrim', 'HtmlEntities', 'StripTags'));
                 // Check e-mail present and valid
                 $formInput['to'] = htmlentities($request->getParam('to'));
                 $formInput['message'] = htmlentities($request->getParam('message'));
                 $formInput['filename'] = htmlentities($request->getParam('filename'));
                 $emailValidator = new Zend_Validate_EmailAddress();
                 $emailValidator->setMessages(array(Zend_Validate_EmailAddress::INVALID_HOSTNAME => 'Domain name invalid in email address', Zend_Validate_EmailAddress::INVALID_FORMAT => 'Invalid email address'));
                 $validators = array('*' => array('allowEmpty' => true), 'email' => $emailValidator);
                 $validate = new Zend_Filter_Input($filters, $validators, $formInput);
                 if ($validate->isValid()) {
                     // Security - ensure PDF can only be requested from public webspace
                     $params = Zend_Registry::get('params');
                     $realpath = realpath($params->connect->basePublicPath . $validate->filename);
                     if (strpos($realpath, $params->connect->safePublicRealPathContains) !== false && strtolower(substr($realpath, -4, 4)) == '.pdf') {
                         // Generate e-mail
                         $mailer = new Application_Core_Mail();
                         $mailer->setTo($validate->to, $validate->to);
                         // TODO: Parameterise:
                         $mailer->setFrom('*****@*****.**', 'HomeLet');
                         $mailer->setSubject("{$validate->filename} sent by HomeLet");
                         $mailer->setBodyText($validate->message);
                         $mailer->addAttachment($realpath, $validate->filename);
                         $mailer->send();
                         echo "{\"successMessage\":\"Email sent\"}\n";
                         exit;
                     }
                 } else {
                     echo "{\"errorMessage\":\"Invalid e-mail address\"}\n";
                     exit;
                 }
             }
         } else {
             echo "{\"errorMessage\":\"No PDF specified\"}\n";
             exit;
         }
     }
     echo "{\"errorMessage\":\"There was an error, please try again later\"}\n";
 }
Exemplo n.º 8
0
 /**
  * Intended to be run by cron.
  *
  * Looks through recent quotes to process mailers for.  Criteria to be satisfied: a) must be x minutes old (eg,
  * probably abandoned) (also should be no older than y to prevent historic quotes being pinged), b) user must have
  * reached at least step z, and c) no mailer has been sent.
  *
  * Values for x, y and z are set in parameters and are independent of the web lead view and status from IAS.
  *
  * @return void
  */
 public function sendMailers()
 {
     // Prepare web lead summary data source
     if (null == $this->_webLeadSummaries) {
         $this->_webLeadSummaries = new Datasource_Core_WebLeadSummaries();
     }
     // Fetch relevant parameters
     $params = Zend_Registry::get('params');
     $hourOffset = $params->weblead->hourOffset;
     $minLastUpdated = $params->weblead->mailer->abandonedAge;
     // In seconds
     $maxLastUpdated = $params->weblead->mailer->ignoredAge;
     // In seconds
     $mailerAtSteps = array(Model_Core_WebLeadProduct::TCIPLUS => array('continueQuote' => explode(',', $params->weblead->mailer->tenant->continueQuote->steps), 'completeQuote' => explode(',', $params->weblead->mailer->tenant->completeQuote->steps)), Model_Core_WebLeadProduct::LANDLORDSPLUS => array('continueQuote' => explode(',', $params->weblead->mailer->landlord->continueQuote->steps), 'completeQuote' => explode(',', $params->weblead->mailer->landlord->completeQuote->steps)));
     $mailerProduct = array(Model_Core_WebLeadProduct::TCIPLUS => 'tenant', Model_Core_WebLeadProduct::LANDLORDSPLUS => 'landlord');
     $searchCriteria = array('hourOffset' => $hourOffset, 'minLastUpdated' => $minLastUpdated, 'maxLastUpdated' => $maxLastUpdated, 'products' => array(Model_Core_WebLeadProduct::TCIPLUS, Model_Core_WebLeadProduct::LANDLORDSPLUS), 'isMailerSent' => 0);
     // Fetch summaries that match the criteria
     $webLeadSummaries = $this->_webLeadSummaries->searchActiveSummaries($searchCriteria);
     // Early exit if there's nothing to do
     if (count($webLeadSummaries) == 0) {
         return;
     }
     // Loop through summaries looking for those that meet a "mailer at step" requirement
     foreach ($webLeadSummaries as $webLeadSummary) {
         $product = $webLeadSummary->product;
         $maxCompletedStep = $this->getBlobMaxStep($webLeadSummary->webLeadSummaryId);
         foreach ($mailerAtSteps[$product] as $mailerType => $mailerStepFilter) {
             if (in_array($maxCompletedStep, $mailerStepFilter)) {
                 // We need to send a mailer!
                 $mail = new Application_Core_Mail();
                 $link = str_replace('http:', 'https:', $params->homelet->domain) . $params->weblead->mailer->retrieveRelativeUrl;
                 $link = str_replace(array('[quoteNumber]', '[email]'), array($webLeadSummary->quoteNumber, $webLeadSummary->emailAddress), $link);
                 $replacements = array('title' => $webLeadSummary->title, 'firstName' => $webLeadSummary->firstName, 'lastName' => $webLeadSummary->lastName, 'fullName' => "{$webLeadSummary->title} {$webLeadSummary->firstName} {$webLeadSummary->lastName}", 'quoteNumber' => $webLeadSummary->quoteNumber, 'link' => htmlentities($link), 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl);
                 $subjectLine = $params->weblead->mailer->{$mailerProduct[$product]}->{$mailerType}->subject;
                 foreach ($replacements as $key => $val) {
                     $subjectLine = str_replace("[{$key}]", $val, $subjectLine);
                 }
                 $replacements['pageTitle'] = $subjectLine;
                 // If this is a "Complete Quote" mailer then fetch the actual quote to get some values out of it
                 if ('completeQuote' == $mailerType) {
                     $replacements['annualPremium'] = '';
                     $replacements['monthlyPremium'] = '';
                     $replacements['expiryDate'] = '';
                     $quoteManager = new Manager_Insurance_LegacyQuote();
                     $quote = $quoteManager->getQuoteByPolicyNumber($webLeadSummary->quoteNumber);
                     if ($quote) {
                         if ('Annually' == $quote->payBy) {
                             $replacements['annualPremium'] = number_format($quote->quote, 2);
                             $replacements['monthlyPremium'] = number_format($quote->quote / 12, 2);
                         } else {
                             $replacements['annualPremium'] = number_format($quote->quote * 12, 2);
                             $replacements['monthlyPremium'] = number_format($quote->quote, 2);
                         }
                         $replacements['expiryDate'] = $quote->getExpiresAt();
                     }
                 }
                 $template = $params->weblead->mailer->{$mailerProduct[$product]}->{$mailerType}->template;
                 $mail->setTo($webLeadSummary->emailAddress, $replacements['fullName'])->setFrom($params->weblead->mailer->fromAddress, $params->weblead->mailer->fromName)->setSubject($subjectLine)->applyTemplate($template, $replacements, true);
                 $mail->send();
                 // Update web lead summary to mark mailer as sent
                 $webLeadSummary->isMailerSent = true;
                 $this->_webLeadSummaries->updateSummary($webLeadSummary);
             }
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Opens a PDF from local storage, populates it with agent details (if
  * needed) and outputs it to either browser or by e-mail.
  *
  * @param string $formName The name of the PDF form, or 'all' for all by e-mail.
  * @param mixed $asn Agent scheme number of agent whose details are to be inserted.
  * @param int $agentUserId Optional user ID - needed for e-mailing forms.
  * @param string $destination Optional output mechanism, if set should be 'browser' or not 'browser'.
  * @param mixed $refno Optional reference number, for a special case PDF that requires applicant data injection.
  */
 public function populateAndOuput($formName, $asn, $agentUserId = null, $destination = 'browser', $refno = null)
 {
     $attachmentList = array();
     switch ($formName) {
         // Forms that require agent details to be injected
         case 'Agent-Company':
         case 'Agent-Guarantor':
         case 'Agent-Individual':
         case 'Agent-Student-guarantor':
         case 'Agent-Unemployed-guarantor':
             // Instantiate agent manager and fetch agent details
             $agentManager = new Manager_Core_Agent();
             $agent = $agentManager->getAgent($asn);
             // Shove agent details through form
             $this->setForm($formName);
             $this->agentPopulate($agent);
             // For "Print Guarantor Form" from ref summary screen:
             if (!is_null($refno)) {
                 // Fetch reference by refno using the Referencing MUNT Manager class
                 $refMuntManager = new Manager_ReferencingLegacy_Munt();
                 $reference = $refMuntManager->getReference($refno);
                 // For safety, ensure reference belongs to this ASN before injecting applicant details
                 if ($reference->customer->customerId == $asn) {
                     $this->applicantPopulate($reference);
                 }
             }
             if ($destination == 'browser') {
                 $this->output('browser');
             } else {
                 $attachmentList[$formName] = $this->output('file');
             }
             break;
             // Forms that are a pass-through
         // Forms that are a pass-through
         case 'Tenant-Declaration':
         case 'Guarantor-Declaration':
             $this->setForm($formName);
             if ($destination == 'browser') {
                 $this->output('browser');
             } else {
                 $attachmentList[$formName] = $this->output('file');
             }
             break;
             // Send all forms - by e-mail only
         // Send all forms - by e-mail only
         case 'all':
             // Instantiate agent manager and fetch agent details
             $agentManager = new Manager_Core_Agent();
             $agent = $agentManager->getAgent($asn);
             // Generate those needing agent data merged in
             foreach (array('Agent-Company', 'Agent-Guarantor', 'Agent-Individual', 'Agent-Student-guarantor', 'Agent-Unemployed-guarantor') as $thisFormName) {
                 $this->setForm($thisFormName);
                 $this->agentPopulate($agent);
                 $attachmentList[$thisFormName] = $this->output('file');
             }
             // Generate straight throughs
             foreach (array('Tenant-Declaration', 'Guarantor-Declaration') as $thisFormName) {
                 $this->setForm($thisFormName);
                 $attachmentList[$thisFormName] = $this->output('file');
             }
             break;
     }
     // If there are attachments, this is/these are to be sent by e-mail
     if (count($attachmentList) > 0) {
         // Instantiate agent user manager to get name and e-mail address
         $agentUserManager = new Manager_Core_Agent_User();
         $agentUser = $agentUserManager->getUser($agentUserId);
         // Generate e-mail
         $mailer = new Application_Core_Mail();
         $mailer->setTo($agentUser->email->emailAddress, $agentUser->name);
         // TODO: Parameterise:
         $mailer->setFrom('*****@*****.**', 'HomeLet Referencing');
         $mailer->setSubject('HomeLet Referencing Application Form');
         $mailer->setBodyText('Please find your HomeLet referencing application forms attached.');
         foreach ($attachmentList as $name => $location) {
             $mailer->addAttachment($location, "{$name}.pdf");
         }
         $mailer->send();
         // Garbage collection
         $this->garbageCollect($attachmentList);
     }
 }
Exemplo n.º 10
0
 /**
  * Send e-mail to agent or agent's master user.
  *
  * @param $toEmail
  * @param $toName
  * @param $agentEmail
  * @param $agentFullname
  * @param $agentSchemeNo
  * @param $agentUsername
  * @param $secToken
  *
  * @return bool
  */
 protected function _emailPasswordReset($toEmail, $toName, $agentEmail = '', $agentFullname, $agentSchemeNo, $agentUsername, $secToken)
 {
     // Get parameters.
     $params = Zend_Registry::get('params');
     // Instantiate and set up an e-mailer object.
     $emailer = new Application_Core_Mail();
     $emailer->setTo($toEmail, $toName);
     $emailer->setFrom($params->connect->lostlogin->emailFromAddress, $params->connect->lostlogin->emailFromName);
     $emailer->setSubject($params->connect->lostlogin->emailSubject);
     $metaData = array('agentFullname' => $agentFullname, 'agentSchemeNo' => $agentSchemeNo, 'agentUsername' => $agentUsername, 'resetLink' => "{$params->url->connectLogin}reset-password?code={$secToken}");
     $emailer->applyTemplate('connect_lostLogin', $metaData, false, '/email-branding/homelet/generic-with-signature-footer.phtml');
     return $emailer->send();
 }
 public function applyAction()
 {
     $this->view->pageTitle = 'Careers';
     if ($this->getRequest()->isPost()) {
         // Handle the cv file and form data
         $filters = array('name' => 'StringTrim', 'tel' => 'StringTrim', 'email' => 'StringTrim', 'enquiry' => 'StringTrim');
         $validators = array('name' => array('NotEmpty', 'messages' => 'Please enter your name'), 'tel' => array('NotEmpty', 'messages' => 'Please enter your telephone number'), 'email' => array('NotEmpty', 'messages' => 'Please enter your email address'), 'enquiry' => array('NotEmpty', 'messages' => 'Please tell us why this position interests you'));
         $input = new Zend_Filter_Input($filters, $validators, $_POST);
         if ($input->isValid()) {
             $upload = new Zend_File_Transfer();
             // Make sure the file is actually a document
             $upload->clearValidators();
             $upload->setOptions(array('ignoreNoFile' => true));
             //$upload->addValidator('MimeType', false, array('application/msword', 'application/pdf', 'application/rtf', 'text/plain'));
             if ($upload->isValid()) {
                 $params = Zend_Registry::get('params');
                 $uploadPath = $params->cms->fileUploadPath;
                 $upload->setDestination($uploadPath);
                 $upload->receive();
                 $fileInfo = $upload->getFileInfo();
                 $emailer = new Application_Core_Mail();
                 $emailer->setTo($params->email->careers, 'HomeLet');
                 $emailer->setFrom($input->email, $input->name);
                 $emailer->setSubject('HomeLet - Job Application (' . $input->position . ')');
                 $bodyHtml = 'Position : ' . $input->position . '<br />';
                 $bodyHtml .= 'Name : ' . $input->name . '<br />';
                 $bodyHtml .= 'Email : ' . $input->email . '<br />';
                 $bodyHtml .= 'Tel : ' . $input->tel . '<br />';
                 $bodyHtml .= 'Enquiry : <pre>' . $input->enquiry . '</pre><br />';
                 if ($fileInfo['cv_file']['type'] !== null) {
                     $emailer->addAttachment($fileInfo['cv_file']['destination'] . '/' . $fileInfo['cv_file']['name'], $fileInfo['cv_file']['name']);
                 }
                 $emailer->setBodyHtml($bodyHtml);
                 if ($emailer->send()) {
                     $this->_helper->redirector('thanks', 'careers');
                 } else {
                 }
             } else {
                 // Invalid file type
                 $this->view->errors = array('cv_file' => 'Invalid file type');
                 $this->view->name = $input->name;
                 $this->view->tel = $input->tel;
                 $this->view->email = $input->email;
                 $this->view->enquiry = $input->enquiry;
             }
         } else {
             // Invalid form data
             $this->view->errors = $input->getMessages();
             $this->view->name = $input->name;
             $this->view->tel = $input->tel;
             $this->view->email = $input->email;
             $this->view->enquiry = $input->enquiry;
         }
     }
     $careerUrl = $this->getRequest()->getParam('careerID');
     $careerID = substr($careerUrl, 0, strpos($careerUrl, '-'));
     $careers = new Datasource_Cms_Careers();
     $career = $careers->getById($careerID);
     $this->view->title = $career['title'];
     $this->view->id = $career['id'];
 }
 /**
  * RRP MTA's
  */
 public function rentRecoveryPlusMtaAction()
 {
     $request = $this->getSymfonyRequest();
     $mtaType = $this->getContainer()->get('rrp.form.mta');
     $policyNumber = null;
     if ($request->isMethod('GET')) {
         $policyNumber = $request->get('policyNumber');
     } else {
         if ($request->isMethod('POST')) {
             $postedData = $request->request->get($mtaType->getName());
             if (array_key_exists('policyNumber', $postedData)) {
                 $policyNumber = $postedData['policyNumber'];
             }
         }
     }
     if (!empty($policyNumber)) {
         /** @var object $applicationDecoratorClass */
         $applicationDecoratorClass = $this->getContainer()->get('rrp.application.decorator.class');
         /** @var RRP\Application\Decorators\RentRecoveryPlusPolicy $policy */
         $policy = $applicationDecoratorClass::getDecorator('RentRecoveryPlusPolicy');
         if (!$policy->populateByPolicyNumber($policyNumber)) {
             $this->renderTwigView('/rentguarantee/rent-recovery-plus-error.html.twig');
             return;
         }
         $policyOptionsManagerClass = $this->getContainer()->get('rrp.utility.policy_options_manager.class');
         $propertyRental = $policyOptionsManagerClass::getOption($policy->getAppData()->getPolicyOptions(), Model_Insurance_RentRecoveryPlus_LegacyPolicy::POLICY_OPTION_RRP, $policy->getAppData()->getAmountsCovered());
         $isNilExcess = $policyOptionsManagerClass::isOptionSet($policy->getAppData()->getPolicyOptions(), Model_Insurance_RentRecoveryPlus_LegacyPolicy::POLICY_OPTION_RRP_NIL_EXCESS, $policy->getAppData()->getAmountsCovered());
         /** @var RRP\Model\RentRecoveryPlusMta $mtaSetter */
         $defaultMta = $this->getContainer()->get('rrp.model.mta');
         $defaultMta->setPolicyNumber($policy->getAppData()->getPolicyNumber())->setPolicyStartedAt($policy->getAppData()->getStartDate())->setPolicyExpiresAt($policy->getAppData()->getEndDate())->setReferenceType($policy->getRrpData()->getReferenceType())->setPropertyRental($propertyRental)->setRefNo($policy->getAppData()->getRefNo());
         $referenceTypeClass = $this->getContainer()->get('rrp.reference_types.class');
         $isNilExcessAllowed = $referenceTypeClass::isNilExcessAllowed($policy->getRrpData()->getReferenceType());
         // Ensure date picker CSS and JS are available
         $this->view->headLink()->appendStylesheet('/assets/vendor/jquery-datepicker/css/datePicker.css');
         $this->view->headScript()->appendFile('/assets/vendor/jquery-date/js/date.js');
         $this->view->headScript()->appendFile('/assets/vendor/jquery-datepicker/js/jquery.datePicker.js');
         $form = $this->getFormFactory()->create($mtaType, $defaultMta);
         if ($request->isMethod('POST')) {
             $form->submit($request);
             if ($form->isValid()) {
                 // Check if only an update of the form to add/remove field. If so it will pass the isValid check
                 //  as it doesn't undergo full validation so we need catch it separately
                 if ($request->isXmlHttpRequest()) {
                     $update = true;
                 } else {
                     $update = $form->get('update')->isClicked();
                 }
                 if (!$update) {
                     // Check if only an update of the form to add/remove field. If so it will pass the isValid check
                     //  as it doesn't undergo full validation so we need catch it separately
                     /** @var RRP\Model\RentRecoveryPlusMta $mta */
                     $mta = $form->getData();
                     /** @var RRP\Rate\RateDecorators\RentRecoveryPlus $rateManager */
                     $rateDecoratorClass = $this->getContainer()->get('rrp.rate.decorator.class');
                     $referralRequired = false;
                     try {
                         /** @var RRP\Rate\RateDecorators\RentRecoveryPlus $rateManager */
                         $rateManager = $rateDecoratorClass::getDecorator('RentRecoveryPlus', $this->_agentsRateID, $this->_params->connect->settings->rentRecoveryPlus->riskArea, $this->_params->connect->settings->rentRecoveryPlus->iptPercent, $mta->getPropertyRental(), $isNilExcess, $policy->getRrpData()->getReferenceType(), $policy->getAppData()->getPolicyLength(), $policy->getAppData()->isPayMonthly(), DateTime::createFromFormat('Y-m-d', $policy->getAppData()->getStartDate()));
                     } catch (Exception $ex) {
                         $referralRequired = true;
                     }
                     $mtaDecoratorClass = $this->getContainer()->get('rrp.mta.decorator.class');
                     /** @var RRP\Mta\Decorators\RentRecoveryPlusMta $mtaDecorator */
                     $mtaDecorator = $mtaDecoratorClass::getDecorator('RentRecoveryPlusMta');
                     $mtaID = $mtaDecorator->create($policy, $mta, $rateManager->getPremium(), $rateManager->getQuote(), $rateManager->getIpt(), $rateManager->getNilExcessOption());
                     $proRataCalcClass = $this->getContainer()->get('rrp.utility.pro_rata_calcs.class');
                     /** @var RRP\Utility\ProRataCalculations $proRataCalcs */
                     $proRataCalcs = new $proRataCalcClass($mta->getPolicyStartedAt(), $mta->getMtaEffectiveAt());
                     $premiumDelta = $proRataCalcs->getAdjustment($policy->getAppData()->getPolicyLength(), $policy->getAppData()->getPolicyLength(), $rateManager->getPremium(), $policy->getAppData()->getPremium());
                     $iptDelta = $proRataCalcs->getAdjustment($policy->getAppData()->getPolicyLength(), $policy->getAppData()->getPolicyLength(), $rateManager->getIpt(), $policy->getAppData()->getIpt());
                     $quoteDelta = $proRataCalcs->getAdjustment($policy->getAppData()->getPolicyLength(), $policy->getAppData()->getPolicyLength(), $rateManager->getQuote(), $policy->getAppData()->getQuote());
                     $premiumProRata = $proRataCalcs->getProRata($policy->getAppData()->getPolicyLength(), $policy->getAppData()->getPolicyLength(), $rateManager->getPremium(), $policy->getAppData()->getPremium());
                     $iptProRata = $proRataCalcs->getProRata($policy->getAppData()->getPolicyLength(), $policy->getAppData()->getPolicyLength(), $rateManager->getIpt(), $policy->getAppData()->getIpt());
                     $quoteProRata = $proRataCalcs->getProRata($policy->getAppData()->getPolicyLength(), $policy->getAppData()->getPolicyLength(), $rateManager->getQuote(), $policy->getAppData()->getQuote());
                     /** @var RRP\Referral\RentRecoveryPlusReferral $referral */
                     $referral = $this->getContainer()->get('rrp.referral');
                     $referral->setFromMta($mta, $rateManager->getPremium());
                     if (!$referralRequired) {
                         $referralRequired = $referral->isReferralRequired();
                     }
                     if ($referralRequired) {
                         $policy->getAppData()->setPayStatus(Model_Insurance_RentRecoveryPlus_LegacyPolicy::PAY_STATUS_REFERRED);
                         $policyNote = new Datasource_Insurance_PolicyNotes();
                         $note = "This policy has been referred for the following reason(s)\n\n" . implode("\n", $referral->getReferralReason());
                         $policyNote->addNote($policy->getAppData()->getPolicyNumber(), $note);
                         // Send referral email
                         $subject = str_replace('{$policyNumber}', $policy->getAppData()->getPolicyNumber(), $this->_params->connect->settings->rentRecoveryPlus->referral->emailSubject);
                         $message = $this->getContainer()->get('twig')->render('rent-recovery-plus-mta-referral-mail.plain.twig', array('agentName' => $this->_agentObj->name, 'agentSchemeNumber' => $this->_agentSchemeNumber, 'referralReasons' => $referral->getReferralReason()));
                         $mailManager = new Application_Core_Mail();
                         $mailManager->setTo($this->_params->connect->settings->rentRecoveryPlus->referral->emailToAddress, $this->_params->connect->settings->rentRecoveryPlus->referral->emailToName)->setFrom($this->_params->connect->settings->rentRecoveryPlus->referral->emailFromAddress, $this->_params->connect->settings->rentRecoveryPlus->referral->emailFromName)->setSubject($subject)->setBodyText($message);
                         $mailManager->send();
                         $this->renderTwigView('/rentguarantee/rent-recovery-plus-mta-referral.html.twig');
                         return;
                     }
                     if ($premiumDelta == 0) {
                         $paymentDetails = 'We are pleased to confirm this has not affected your premium.';
                     } else {
                         if ($policy->getAppData()->isPayMonthly()) {
                             $paymentDetails = sprintf('From the date of the adjustment this will appear on your invoices as monthly' . ' payments of £%.02f plus £%.02f (IPT at %d%%). Total monthly payment £%.02f. ', $premiumProRata, $iptProRata, $this->_params->connect->settings->rentRecoveryPlus->iptPercent, $quoteProRata);
                         } else {
                             if ($premiumDelta < 0) {
                                 $paymentDetails = sprintf('This will appear on your next invoice as a refund of' . ' £%.02f plus £%.02f (IPT at %d%%). Total £%.02f. ', -$premiumDelta, -$iptDelta, $this->_params->connect->settings->rentRecoveryPlus->iptPercent, -$quoteDelta);
                             } else {
                                 $paymentDetails = sprintf('This will appear on your next invoice as £%.02f plus £%.02f (IPT at %d%%). Total £%.02f. ', $premiumDelta, $iptDelta, $this->_params->connect->settings->rentRecoveryPlus->iptPercent, $quoteDelta);
                             }
                         }
                     }
                     // Show premium and ask for confirmation
                     $this->renderTwigView('/rentguarantee/rent-recovery-plus-mta-quote.html.twig', array('policyNumber' => $policyNumber, 'paymentDetails' => $paymentDetails, 'mtaID' => $mtaID));
                     return;
                 }
             }
         }
         if ($this->getRequest()->isXmlHttpRequest()) {
             $this->_helper->viewRenderer->setNoRender(true);
             $this->_helper->layout->disableLayout();
         }
         $this->renderTwigView('/rentguarantee/rent-recovery-plus-mta.html.twig', array('form' => $form->createView(), 'nilExcessAllowed' => $isNilExcessAllowed));
         return;
     }
     $this->renderTwigView('/rentguarantee/rent-recovery-plus-error.html.twig');
 }
 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;
 }
Exemplo n.º 14
0
 /**
  * Register action
  *
  * @return void
  */
 public function partialRegistrationAction()
 {
     $this->_setBreadcrumbs(array('/' => 'Home', '/my-homelet' => 'My HomeLet', '/my-homelet/partial-registration' => 'Continue Registration'));
     $params = Zend_Registry::get('params');
     $form = new Account_Form_Register();
     // Populate the form with the security question options
     $securityQuestionModel = new Datasource_Core_SecurityQuestion();
     $securityQuestionOptions = $securityQuestionModel->getOptions();
     foreach ($securityQuestionOptions as $option) {
         $form->security_question->addMultiOption($option['id'], $option['question']);
     }
     $customerManager = new Manager_Core_Customer();
     if (!$this->getRequest()->isPost()) {
         $refno = $_GET['refno'];
         $email = $_GET['email'];
         $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false);
         $digest = $mac->generate(array('email' => $email));
         if ($refno) {
             // Try by legacy customer refno
             $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $refno);
         } else {
             // Try by email
             $customer = $customerManager->getCustomerByEmailAddress($email);
         }
         $formData = array();
         $formData['title'] = $customer->getTitle();
         $formData['first_name'] = $customer->getFirstName();
         $formData['last_name'] = $customer->getLastName();
         $formData['email'] = $email;
         $formData['refno'] = $refno;
         #$form->title->setAttrib('readonly','readonly');
         #$form->first_name->setAttrib('readonly','readonly');
         #$form->last_name->setAttrib('readonly','readonly');
         $form->email->setAttrib('readonly', 'readonly');
         $form->populate($formData);
         if ($digest != $_GET['mac']) {
             // Render error page if invalid mac
             $this->render('activate-account-invalidmac');
             return;
         }
     } else {
         if ($form->isValid($this->getRequest()->getPost())) {
             // Detect if the customer has already registered with this email address
             $customer = $customerManager->getCustomerByEmailAddress($form->email->getValue());
             if ($customer) {
                 // Customer already exists, flag form in error
                 // Ideally this should go in the form as an overridden validation method, but this would
                 // tightly couple the form to the customer manager anyway, which itself is bad.
                 // Alternatively I could inject the found customer object into the form, but then this doesn't change
                 // much to using the code here anyway.
                 $form->email->addError('This email is already in use. Have you signed up before?')->markAsError();
             } else {
                 // Create customer. Because this is the generic registration page, we use a generic customer type
                 $customer = $customerManager->createCustomerFromLegacy($form->email->getValue(), $form->refno->getValue());
                 $custID = $customer->getIdentifier(Model_Core_Customer::IDENTIFIER);
                 $leg = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $form->refno->getValue());
                 // Update customer with password and security data
                 $customerManager->updateCustomerByLegacy($leg, $custID);
                 $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $custID);
                 $customer->setSecurityQuestion($form->security_question->getValue());
                 $customer->setSecurityAnswer($form->security_answer->getValue());
                 $customer->setPassword($form->password->getValue());
                 $customer->setEmailValidated(true);
                 $customerManager->updateCustomer($customer);
                 // Create welcome email
                 $mail = new Application_Core_Mail();
                 $mail->setTo($_GET['email'], null);
                 $mail->setFrom('*****@*****.**', 'HomeLet');
                 $mail->setSubject('Registration for My HomeLet');
                 // Apply template
                 $mail->applyTemplate('core/account-welcome', array('homeletWebsite' => $params->homelet->domain, 'templateId' => 'HL2443 12-12', 'firstname' => $customer->getFirstName(), 'heading' => 'Your registration for My HomeLet is complete!', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
                 $mail->applyTextTemplate('core/account-welcometxt', array('homeletWebsite' => $params->homelet->domain, 'templateId' => 'HL2443 12-12', 'firstname' => $customer->getFirstName(), 'heading' => 'Your registration for My HomeLet is complete!'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
                 // Send email
                 $mail->send();
                 // Find all customers in mysql4 insurance that have the same email address
                 $legacyCustomers = $customerManager->getAllLegacyCustomersByEmailAddress($_GET['email']);
                 $customerIdentifier = $customer->getIdentifier(Model_Core_Customer::IDENTIFIER);
                 foreach ($legacyCustomers as $legacyCustomer) {
                     // For each customer found, insert a record into the mysql5 customer_legacy_customer_map table
                     $legacyIdentifier = $legacyCustomer->getIdentifier(Model_Core_Customer::LEGACY_IDENTIFIER);
                     $customerMap = new Datasource_Core_CustomerMaps();
                     if (!$customerMap->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $legacyIdentifier)) {
                         $customerManager->linkLegacyToNew($legacyIdentifier, $customerIdentifier);
                     }
                 }
                 $this->_helper->redirector->gotoUrl('/my-homelet/login?message=registration-complete');
             }
         }
     }
     $this->view->form = $form;
 }
Exemplo n.º 15
0
 /**
  * Resets the customer's password
  *
  * @return void
  */
 public function resetpassword()
 {
     $this->_password = Application_Core_Password::generate();
     $params = Zend_Registry::get('params');
     // Email the customer with the new password
     $metaData = array('name' => $this->getFirstName(), 'email' => $this->getEmailAddress(), 'password' => $this->_password, 'homeletWebsite' => $params->homelet->domain, 'templateId' => 'HL2485 12-12', 'heading' => 'We’ve reset your password for you', 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl);
     $emailer = new Application_Core_Mail();
     $emailer->setTo($this->getEmailAddress(), $this->getFirstName() . ' ' . $this->getLastName())->setSubject('HomeLet - Your Password')->applyTemplate('core_resetpassword', $metaData, false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
     $emailer->send();
 }
 /**
  * Handles display, validation and sending of company application form
  */
 public function companyApplicationAction()
 {
     // Instantiate form
     $pageForm = new Connect_Form_ReferencingCompanyApplication();
     $request = $this->getRequest();
     if ($request->isPost()) {
         // We have post data from the company app form - so attempt
         //   validation
         if ($pageForm->isValid($request->getPost())) {
             // Form valid!
             // Format text data ready for e-mail
             $agentManager = new Manager_Core_Agent($this->_agentSchemeNumber);
             $address = $agentManager->getPhysicalAddressByCategory(Model_Core_Agent_ContactMapCategory::OFFICE);
             $agentAddress = $address->toString();
             switch ($request->getParam('how_rg_offered')) {
                 case 1:
                     $howOffered = "Free of charge";
                     break;
                 case 2:
                     $howOffered = "Included in Management Fees";
                     break;
                 case 3:
                     $howOffered = "Separate charge for Rent Guarantee to the landlord";
                     break;
                 case 4:
                     $howOffered = "Referening Only";
                     break;
             }
             switch ($request->getParam('property_managed')) {
                 case 1:
                     $howManaged = "Let Only";
                     break;
                 case 2:
                     $howManaged = "Managed";
                     break;
                 case 3:
                     $howManaged = "Rent Collect";
                     break;
             }
             //Convert the product id into a product name
             $cleanData = $pageForm->getValues();
             $productManager = new Manager_Referencing_Product();
             $product = $productManager->getById($cleanData['subform_product']['product']);
             $productName = empty($product->name) ? '' : $product->name;
             $message = 'Agent Scheme Number: ' . $this->_agentSchemeNumber . "\n" . 'Agent Name: ' . $this->_agentObj->name . "\n" . 'Agent address: ' . $agentAddress . "\n\n" . 'Product: ' . $product->name . "\n" . "\nProperty To Let:\n" . 'Address: ' . $request->getParam('property_address') . "\n" . 'Postcode: ' . $request->getParam('property_postcode') . "\n" . 'Managed Property: ' . $howManaged . "\n" . 'How is Rent Guarantee offered to the landlord: ' . $howOffered . "\n" . 'Total Rent: ' . $request->getParam('tenant_renttotal') . "\n" . 'Rent Share: ' . $request->getParam('tenant_rentshare') . "\n" . 'Tenancy Term: ' . $request->getParam('tenant_term') . "\n" . 'Start Date: ' . $request->getParam('tenant_startdate') . "\n" . 'Total Reference Count: ' . $request->getParam('tenant_number') . "\n" . "\nLandlord Details: \n" . 'First Name: ' . $request->getParam('landlord_firstname') . "\n" . 'Last Name: ' . $request->getParam('landlord_lastname') . "\n" . 'Address: ' . $request->getParam('landlord_address') . "\n" . 'Postcode: ' . $request->getParam('landlord_postcode') . "\n" . 'Telno: ' . $request->getParam('landlord_landlinenumber') . "\n" . 'Mobile: ' . $request->getParam('landlord_mobilenumber') . "\n" . "\nCompany Details: \n" . 'Company Name: ' . $request->getParam('company_name') . "\n" . 'Trading Name: ' . $request->getParam('company_tradingname') . "\n" . 'Registered Number: ' . $request->getParam('company_registration') . "\n" . 'Incorporation Date: ' . $request->getParam('company_incorporation') . "\n" . 'Contact Name: ' . $request->getParam('company_contactname') . "\n" . 'Telno: ' . $request->getParam('company_phone') . "\n" . "\nCompany Registered Address: \n" . 'Address: ' . $request->getParam('registered_address') . "\n" . 'Postcode: ' . $request->getParam('registered_postcode') . "\n" . 'Period at Address: ' . $request->getParam('registered_years') . " years, " . $request->getParam('registered_months') . " months\n" . "\nCompany Trading Address: \n" . 'Address: ' . $request->getParam('trading_address') . "\n" . 'Postcode: ' . $request->getParam('trading_postcode') . "\n" . 'Period at Address: ' . $request->getParam('trading_years') . " years, " . $request->getParam('trading_months') . " months\n" . "\nAdditional Info: \n" . $request->getParam('additional_info') . "\n" . "\nCompany Signature Details: \n" . 'Name: ' . $request->getParam('representive_name') . "\n" . 'Position: ' . $request->getParam('representive_position') . "\n" . 'Date: ' . $request->getParam('application_date') . "\n";
             // Instantiate mailer manager
             $mailManager = new Application_Core_Mail();
             $mailManager->setTo($this->_params->connect->companyapps->emailToAddress, $this->_params->connect->companyapps->emailToName)->setFrom($this->_params->connect->companyapps->emailFromAddress, $this->_params->connect->companyapps->emailFromName)->setSubject($this->_params->connect->companyapps->emailSubject)->setBodyText($message);
             // Check for uploaded file and persist it if so
             list($fileResult, $fileData) = $this->_uploadPersistentCompanyApplicationFile();
             if ($fileResult === true) {
                 $this->view->fileUploaded = $fileData;
                 // If there's a file, attach it
                 if (isset($fileData['pathToFile'])) {
                     $mailManager->addAttachment($fileData['pathToFile'], $fileData['originalName']);
                 }
                 $mailManager->send();
                 // Clean up uploaded file
                 $this->_deleteCompanyApplicationFile();
                 // Show user confirmation that form submission has been successful
                 $this->_helper->viewRenderer('company-confirmation');
             } else {
                 $this->_helper->flashmessages->addMessage('Problem(s) uploading file:');
                 $this->_helper->flashmessages->addMessage($fileData);
             }
         } else {
             // Tell user there are problems
             $this->_helper->flashmessages->addMessage('Problem(s) in form data:');
             $this->_helper->flashmessages->addMessage($pageForm->getMessagesFlattened(true));
             // Check for uploaded file and persist it if so
             list($fileResult, $fileData) = $this->_uploadPersistentCompanyApplicationFile();
             if ($fileResult === true) {
                 $this->view->fileUploaded = $fileData;
             } else {
                 $this->_helper->flashmessages->addMessage('Problem(s) uploading file:');
                 $this->_helper->flashmessages->addMessage($fileData);
             }
         }
     } else {
         // Form first shown, set a couple of default values
         $pageForm->subform_additional->getElement('additional_info')->setValue('Use this space to provide any additional information that may help us when processing your application.');
         $pageForm->subform_declaration->getElement('application_date')->setValue(date('d/m/Y'));
         // Ensure any previously uploaded file is deleted
         $this->_deleteCompanyApplicationFile();
     }
     $this->view->flashMessages = $this->_helper->flashmessages->getCurrentMessages();
     $this->view->form = $pageForm;
 }
Exemplo n.º 17
0
 /**
  * Send a notification email to all agents for the required reporting month/year
  *
  * @param int $agentSchemeNumber
  * @param string $email_address
  * @param string $month
  * @param string $year
  * @return bool
  */
 public function sendEmailNotification($agentSchemeNumber, $email_address, $month, $year)
 {
     echo "Send email to agent {$agentSchemeNumber} - {$email_address}\n";
     $params = Zend_Registry::get('params');
     $mail = new Application_Core_Mail();
     $mail->setTo($email_address, null);
     $mail->setFrom('*****@*****.**', 'HomeLet');
     $mail->setSubject('Your statement is ready for you');
     // Apply template
     $mail->applyTemplate('core/invoice-notification', array('asn' => $agentSchemeNumber, 'year' => $year, 'month' => $month, 'heading' => 'STATEMENT NOTIFICATION', 'templateId' => '', 'homeletWebsite' => $params->homelet->domain, 'connectURL' => $params->connectUrl->connectRootUrl, 'imageBaseUrl' => $params->weblead->mailer->imageBaseUrl), false, '/email-templates/core/footer.phtml', '/email-templates/core/header.phtml');
     // Send email
     if (!$mail->send()) {
         echo 'Message could not be sent to ' . $email_address - 'Mailer Error: ' . $mail->ErrorInfo;
     }
     return true;
 }
Exemplo n.º 18
0
 /**
  * Initialise the step 3 form [Important Information Form]
  *
  * @return void
  */
 public function step3Action()
 {
     $pageForm = new TenantsInsuranceQuoteB_Form_Step3();
     // Tell page to use AJAX validation as we go
     $this->view->headScript()->appendScript('var ajaxValidate = true; var ajaxValidatePage = 3;');
     // Get customer details
     $customerManager = new Manager_Core_Customer();
     $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber);
     // Hydrate registration form
     if (isset($pageForm->subform_register) || isset($pageForm->subform_login)) {
         // Grab a new customer to populate the form
         $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
         $newCust = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $pageSession->CustomerID);
         if (isset($pageForm->subform_register)) {
             if ($newCust) {
                 $pageForm->subform_register->email->setValue($newCust->getEmailAddress());
                 $pageForm->subform_register->security_question->setValue($newCust->getSecurityQuestion());
                 $pageForm->subform_register->security_answer->setValue($newCust->getSecurityAnswer());
                 $emailAddress = $newCust->getEmailAddress();
             } else {
                 $pageForm->subform_register->email->setValue($customer->getEmailAddress());
                 $emailAddress = $customer->getEmailAddress();
             }
             if (!$emailAddress) {
                 $emailAddress = $newCust->getEmailAddress();
             }
         } else {
             if ($newCust) {
                 $pageForm->subform_login->email->setValue($newCust->getEmailAddress());
             }
         }
     }
     if ($this->getRequest()->isPost()) {
         $valid = $this->_formStepCommonValidate($pageForm, 3);
         if (isset($pageForm->subform_register)) {
             $pageForm->subform_register->getElement('email')->setValue($emailAddress);
         }
         if ($valid) {
             $pageSession = new Zend_Session_Namespace('tenants_insurance_quote');
             $pageSession->IsNewCustomer = false;
             $data = $pageForm->getValues();
             //Update the WebLead summary and create a STEP3 blob.
             $webLeadManager = new Manager_Core_WebLead();
             $webLeadSummary = $webLeadManager->getSummary($this->_webLeadSummaryId);
             $webLeadSummary->lastUpdatedTime = $this->_offsetDate();
             $webLeadSummary->promotionCode = $data["subform_howhear"]['campaign_code'];
             $webLeadManager->updateSummary($webLeadSummary);
             //Determine if a new STEP3 blob needs to be created, or an existing one retrieved.
             if ($webLeadManager->getBlobExists($this->_webLeadSummaryId, Model_Core_WebLeadStep::STEP3)) {
                 $webLeadBlob = $webLeadManager->getBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP3);
             } else {
                 $webLeadBlob = $webLeadManager->createNewBlob($webLeadSummary->webLeadSummaryId, Model_Core_WebLeadStep::STEP3);
             }
             //Update the blob and store
             $webLeadBlob->blob = Zend_Json::encode($_POST);
             $webLeadBlob->blobChecksum = crc32($webLeadBlob->blob);
             $webLeadManager->updateBlob($webLeadBlob);
             // Instantiate the quote manager
             $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $this->_policyNumber);
             // Save new ASN if there is one
             // Create a postcode model
             $postcode = new Manager_Core_Postcode();
             // Get the address as array for Insured and correspondance address
             $insuredAddress = $postcode->getPropertyByID($data['subform_insuredaddress']['ins_address'], false);
             $correspondenceAddress = $postcode->getPropertyByID($data['subform_correspondencedetails']['cor_address'], false);
             // Update the property address in the quote
             $quoteManager->setPropertyAddress(($insuredAddress['organisation'] != '' ? "{$insuredAddress['organisation']}, " : '') . ($insuredAddress['buildingName'] != '' ? "{$insuredAddress['buildingName']}, " : '') . ($insuredAddress['houseNumber'] != '' ? "{$insuredAddress['houseNumber']} " : '') . $insuredAddress['address2'], $insuredAddress['address4'], $insuredAddress['address5'], $insuredAddress['postcode']);
             // Update start and end dates
             $startDate = $data['subform_policydetails']['policy_start'];
             $startDate = substr($startDate, 6, 4) . '-' . substr($startDate, 3, 2) . '-' . substr($startDate, 0, 2);
             $endDate = date('Y-m-d', strtotime(date('Y-m-d', strtotime($startDate)) . ' +1 year -1 day'));
             $quoteManager->setStartAndEndDates($startDate, $endDate);
             //Update the customer in the DataStore and the LegacyDataStore. Use the CustomerManager
             //to do this.
             //$customerManager = new Manager_Core_Customer();
             //First get the existing customer details.
             //$customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber);
             //Now modify the details.
             $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, ($correspondenceAddress['organisation'] != '' ? "{$correspondenceAddress['organisation']}, " : '') . ($correspondenceAddress['houseNumber'] != '' ? "{$correspondenceAddress['houseNumber']} " : '') . ($correspondenceAddress['buildingName'] != '' ? "{$correspondenceAddress['buildingName']}, " : '') . $correspondenceAddress['address2']);
             $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $correspondenceAddress['address4']);
             $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $correspondenceAddress['address5']);
             $customer->setPostCode($correspondenceAddress['postcode']);
             $customer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob));
             //Finally, save the details back to both DataStores.
             $customerManager->updateCustomer($customer);
             $premiums = $quoteManager->calculatePremiums();
             // Save MI information - how did you hear about us
             $marketQuestion = new Manager_Core_ManagementInformation();
             $marketQuestion->saveMarketingAnswers($this->_policyNumber, $this->_customerReferenceNumber, $data["subform_howhear"]["how_hear"]);
             // Perform login/register procedure
             $auth = Zend_Auth::getInstance();
             $auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
             if (isset($data['subform_register'])) {
                 // Process registration
                 $params = Zend_Registry::get('params');
                 $newCustomer = $customerManager->getCustomerByEmailAddress($data['subform_register']['email']);
                 if (!$newCustomer) {
                     $newCustomer = $customerManager->createCustomerFromLegacy($data['subform_register']['email'], $this->_customerReferenceNumber);
                 }
                 // Update customer with password and security data
                 $newCustomer->setTitle($customer->getTitle());
                 $newCustomer->setFirstName($customer->getFirstName());
                 $newCustomer->setLastName($customer->getLastName());
                 $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, ($correspondenceAddress['organisation'] != '' ? "{$correspondenceAddress['organisation']}, " : '') . ($correspondenceAddress['houseNumber'] != '' ? "{$correspondenceAddress['houseNumber']} " : '') . ($correspondenceAddress['buildingName'] != '' ? "{$correspondenceAddress['buildingName']}, " : '') . $correspondenceAddress['address2']);
                 $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $correspondenceAddress['address4']);
                 $newCustomer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $correspondenceAddress['address5']);
                 $newCustomer->setPostCode($correspondenceAddress['postcode']);
                 $newCustomer->setDateOfBirthAt(Application_Core_Utilities::ukDateToMysql($pageSession->CustomerDob));
                 //                    assuming that the email is already set and so won't require setting again.
                 //                    $newCustomer->setEmailAddress($data['subform_register']['email']);
                 $newCustomer->setSecurityQuestion($data['subform_register']['security_question']);
                 $newCustomer->setSecurityAnswer($data['subform_register']['security_answer']);
                 $newCustomer->setPassword($data['subform_register']['password']);
                 $newCustomer->setAccountLoadComplete(true);
                 $newCustomer->typeID = Model_Core_Customer::CUSTOMER;
                 $customerManager->updateCustomer($newCustomer);
                 // Create sign-up completion email
                 $mail = new Application_Core_Mail();
                 $mail->setTo($data['subform_register']['email'], null);
                 $mail->setFrom('*****@*****.**', 'HomeLet');
                 $mail->setSubject('My HomeLet account validation');
                 //  Generate activation link
                 $mac = new Application_Core_Security($params->myhomelet->activation_mac_secret, false);
                 $digest = $mac->generate(array('email' => $data['subform_register']['email']));
                 $activationLink = 'email=' . $data['subform_register']['email'] . '&' . 'mac=' . $digest;
                 // Apply template
                 $mail->applyTemplate('core/account-validation', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $newCustomer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer.phtml', '/email-branding/homelet/portal-header.phtml');
                 $mail->applyTextTemplate('core/account-validationtxt', array('activationLink' => $activationLink, 'homeletWebsite' => $params->homelet->domain, 'firstname' => $newCustomer->getFirstName(), 'templateId' => 'HL2442 12-12', 'heading' => 'Validating your My HomeLet account'), false, '/email-branding/homelet/portal-footer-txt.phtml', '/email-branding/homelet/portal-header-txt.phtml');
                 // Send email
                 $mail->send();
                 // Everything has been saved ok so navigate to next step
                 $this->_formStepCommonNavigate(3);
             } elseif ($auth->hasIdentity()) {
                 $this->_formStepCommonNavigate(3);
             }
             //return;
         } elseif (isset($_POST['back'])) {
             $this->_formStepCommonNavigate(3);
             return;
         }
     }
     // Load the element data from the database if we can
     if ($this->_formStepCommonPopulate($pageForm, 3)) {
         // Render the page unless we have been redirected
         $this->view->form = $pageForm;
         $this->render('step');
     }
 }
Exemplo n.º 19
0
 /**
  * This function handles the referred underwriting state, including unsetting the session
  *
  * @return void
  */
 public function referredAction()
 {
     // Show the policy number to the end user
     $session = new Zend_Session_Namespace('landlords_insurance_quote');
     $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($session->quoteID);
     $this->view->policyNumber = $quoteManager->getLegacyID();
     // Pop an e-mail to the end user
     $params = Zend_Registry::get('params');
     $customerManager = new Manager_Core_Customer();
     $customer = $customerManager->getCustomer(Model_Core_Customer::LEGACY_IDENTIFIER, $this->_customerReferenceNumber);
     $replacements = array('title' => $customer->getTitle(), 'firstName' => $customer->getFirstName(), 'lastName' => $customer->getLastName(), 'fullName' => $customer->getTitle() . ' ' . $customer->getFirstName() . ' ' . $customer->getLastName(), 'quoteNumber' => $this->view->policyNumber, 'imageBaseUrl' => $this->_params->weblead->mailer->imageBaseUrl);
     $subjectLine = $params->weblead->mailer->landlord->referredQuote->subject;
     foreach ($replacements as $key => $val) {
         $subjectLine = str_replace("[{$key}]", $val, $subjectLine);
     }
     $replacements['pageTitle'] = $subjectLine;
     $template = $params->weblead->mailer->landlord->referredQuote->template;
     $mail = new Application_Core_Mail();
     $mail->setTo($customer->getEmailAddress(), $replacements['fullName'])->setFrom($params->weblead->mailer->fromAddress, $params->weblead->mailer->fromName)->setSubject($subjectLine)->applyTemplate($template, $replacements, true);
     $mail->send();
     // Tag quote as mailer sent, stops abandone quote mailer cron from sending a continue mailer
     $webLeadManager = new Manager_Core_WebLead();
     $webLeadManager->setIsMailerSent($quoteManager->getLegacyID(), true);
     // Unset the session to prevent navigation to other steps
     Zend_Session::namespaceUnset('landlords_insurance_quote');
 }
Exemplo n.º 20
0
 /**
  * This method is called when the Reference Subject completes an email link.
  */
 public function emailLinkEndAction()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $params = Zend_Registry::get('params');
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($session->referenceId);
     $customerId = $reference->customer->customerId;
     $customerManager = new Manager_Core_Customer();
     $customer = $customerManager->getCustomer(Model_Core_Customer::IDENTIFIER, $customerId);
     $customerEmail = $customer->getEmailAddress();
     $recipientName = $customer->getFirstName() . ' ' . $customer->getLastName();
     //Generate the security token to be appended to the URL.
     $hashingString = $params->pll->emailLink->security->securityString;
     $securityManager = new Manager_Core_Security($hashingString);
     $customerToken = $securityManager->generate(array('refNo' => $reference->externalId, 'customerId' => $customerId));
     //Prepare the meta data.
     $metaData = array();
     $metaData['firstName'] = $customer->getFirstName();
     $metaData['lastName'] = $customer->getLastName();
     $metaData['linkUrl'] = $params->pll->emailLink->email->linkEndUrl;
     $metaData['linkUrl'] .= '?';
     $metaData['linkUrl'] .= "refNo={$reference->externalId}";
     $metaData['linkUrl'] .= '&';
     $metaData['linkUrl'] .= "customerToken={$customerToken}";
     //Send email to landlords
     $emailer = new Application_Core_Mail();
     $emailer->setTo($customerEmail, $recipientName);
     //Set the email from details.
     $emailFrom = $params->pll->emailLink->email->from;
     $emailFromName = $params->pll->emailLink->email->fromname;
     $emailer->setFrom($emailFrom, $emailFromName);
     //Set the subject line
     $addressLine1 = $reference->propertyLease->address->addressLine1;
     $town = $reference->propertyLease->address->town;
     $postCode = $reference->propertyLease->address->postCode;
     $emailer->setSubject("Re: {$addressLine1}, {$town}, {$postCode}");
     //Apply template and send.
     $emailer->applyTemplate('landlordsreferencing_emaillinkend', $metaData, false);
     $emailer->send();
     //Delete session
     unset($session->userType);
     unset($session->referenceId);
     $this->view->fractionComplete = 95;
 }
Exemplo n.º 21
0
 /**
  *   To send a confirmation email after the completion of step4
  *
  *   @return void
  */
 public function sendConfirmationEmail($refNumber, $khClaimNumber)
 {
     // get agent name and claim number to send an confirmation email
     $claimData = $this->getClaim($refNumber);
     $emailer = new Application_Core_Mail();
     $emailer->setTo($claimData->getAgentEmail(), $claimData->getAgentName());
     $emailer->setFrom('*****@*****.**', 'Homelet Claim Submission');
     $emailer->setSubject('ASN: ' . $claimData->getAgentSchemeNumber() . '; Claim Ref: ' . $khClaimNumber);
     $metaData = array('agentname' => $claimData->getAgentName(), 'propertyAddress' => $claimData->getTenancyAddress(), 'claimNumber' => $khClaimNumber);
     $emailer->applyTemplate('connect_claimSubmitConfirmation', $metaData, false, '/email-branding/homelet/generic-with-signature-footer.phtml');
     return $emailer->send();
 }
Exemplo n.º 22
0
 /**
  * Sends an email to 'The Campaign Team' who are responsible for calling back the reference subject.
  *
  * Does not provide support for attachments, so should be used where the reference
  * subject (tenant or guarantor) has not provided one.
  * 
  * @param mixed $enquiryId
  * The unique Enquiry identifier (internal or external). May be integer or string.
  *
  * @param string $content
  * The content of the message sent by the reference subject.
  *
  * @return boolean
  * Returns true on successful send, false otherwise.
  */
 public function notifyCampaignTeam($content)
 {
     $emailer = new Application_Core_Mail();
     $emailer->setTo('*****@*****.**', 'Campaign Team');
     $emailer->setFrom('*****@*****.**', 'Tenant Tracker');
     $emailer->setSubject('Tenant Tracker Quote');
     $emailer->setBodyText($content);
     //Send and return
     $success = $emailer->send();
     if ($success) {
         $returnVal = true;
     } else {
         $returnVal = false;
     }
     return $returnVal;
 }