コード例 #1
0
 /**
  * Helper function for generating sent email history HTML fragment
  *
  * @return string
  */
 public function showEmailHistory()
 {
     // Fetch e-mails
     $pageSession = new Zend_Session_Namespace('tenants_referencing_tracker');
     if (isset($pageSession->enquiryId)) {
         $tatManager = new Manager_Referencing_Tat($pageSession->enquiryId);
         $tat = $tatManager->getTat();
         $tatNotificationArray = $tat->tatNotifications;
         $outputData = array();
         if (!empty($tatNotificationArray)) {
             foreach ($tatNotificationArray as $currentNotification) {
                 $outputData[] = array('date' => $currentNotification->sendDate->toString(), 'content' => $currentNotification->content);
             }
         }
         if (count($outputData) > 0) {
             // Return partial view HTML for when e-mails have been sent
             return $this->view->partial('tenants-referencing-tracker/partials/show-email-history.phtml', array('emails' => $outputData));
         } else {
             // Return partial view HTML for when no e-mails have been sent
             return $this->view->partial('tenants-referencing-tracker/partials/show-email-history-empty.phtml');
         }
     }
 }
 /**
  * Send e-mail to HomeLet screen
  *
  * @return void
  */
 public function emailAction()
 {
     if ($this->_enquiryId == null) {
         return;
     }
     $pageForm = new Form_TenantsReferencingTracker_Email();
     $request = $this->getRequest();
     $formData = $request->getPost();
     $pageForm->populate($formData);
     $tatManager = new Manager_Referencing_Tat($this->_enquiryId);
     $tat = $tatManager->getTat();
     $tatMailManager = new Manager_Referencing_TatMail($tatManager->_reference);
     if ($request->isPost()) {
         // Check if user's going back to the TAT index, or is submitting the form
         if (isset($formData['back'])) {
             // Redirect to index page
             $this->_helper->redirector->gotoUrl('/tenants/reference-tracker');
             return;
         } else {
             // Check if this is to add/remove attachments, or is a full submit
             // TODO: It'd be nice to handle this by separating it out into a smooth non-page-refreshing AJAX method
             if (isset($formData['attachButton']) || isset($formData['deleteButton'])) {
                 // Handle attachments
                 if (isset($formData['attachButton'])) {
                     $tatMailManager->addAttachments();
                 } else {
                     $tatMailManager->deleteAttachments();
                 }
             } else {
                 if ($pageForm->isValid($formData)) {
                     // Successful set of data, send e-mail and show message to user
                     $data = $pageForm->getValues();
                     $content = '';
                     $content .= "Enquiry ID: {$this->_enquiryId}\r\n\r\n";
                     $content .= "Name: {$data['name']}\r\n\r\n";
                     $content .= "Contact number or e-mail address: {$data['contact_info']}\r\n\r\n";
                     $content .= "Message to assessor:\r\n{$data['message']}\r\n\r\n";
                     $attachmentInfo = $tatMailManager->detailAttachments();
                     if (count($attachmentInfo) > 0) {
                         $tatMailManager->notifyAssessorWithAttachments($content);
                         $tatMailManager->deleteAttachments();
                     } else {
                         $tatMailManager->notifyAssessor($content);
                     }
                     // Log MI event
                     Application_Core_ActivityLogger::log('TAT Email HomeLet', 'complete', 'TAT', null, "IRN: {$this->_enquiryId}");
                     // Redirect to confirmation page, the redirect prevents
                     //   multiple submissions if user refreshes browser
                     $this->_helper->redirector->gotoUrl('/tenants/reference-tracker/emailsent');
                     return;
                 }
             }
         }
     }
     $this->view->reference = $tatManager->_reference;
     $this->view->form = $pageForm;
 }