コード例 #1
0
 /**
  * The legacy datasource stores the total annual income in the Tenant table.
  *
  * @param string $enquiryId
  * The unique, external enquiry identifier.
  *
  * @return mixed
  * Returns a Zend_Currency if the income is known, else returns null.
  */
 public function getLegacyTotalAnnualIncome($enquiryId)
 {
     $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry();
     $referenceSubjectId = $enquiryDatasource->getTenantId($enquiryId);
     $select = $this->select();
     $select->where('ID = ?', $referenceSubjectId);
     $referenceSubjectRow = $this->fetchRow($select);
     if ($referenceSubjectRow->income >= 0) {
         $returnVal = new Zend_Currency(array('value' => $referenceSubjectRow->income, 'precision' => 0));
     } else {
         $returnVal = null;
     }
     return $returnVal;
 }
コード例 #2
0
 public function resendEmailAction()
 {
     // Pop-up results need pop-up layout
     $this->_helper->layout->setLayout('popup');
     // Get refno from GET var, look up applicant details
     $refno = isset($_GET['refno']) ? $_GET['refno'] : '';
     $refMuntManager = new Manager_ReferencingLegacy_Munt();
     $reference = $refMuntManager->getReference($refno);
     $applicantTypes = array_flip(Model_Referencing_ReferenceSubjectTypes::iterableKeys());
     $applicantType = ucwords(strtolower($applicantTypes[$reference->referenceSubject->type]));
     $applicantType = $applicantType == 'Tenant' ? 'Applicant' : $applicantType;
     // Intantiate form definition
     $pageForm = new Connect_Form_ReferencingResendEmail();
     // Validate form if POSTed
     $request = $this->getRequest();
     if ($request->isPost() && !is_null($request->getParam('fromForm')) && $request->getParam('fromForm') == '1') {
         $postData = $request->getPost();
         if ($pageForm->isValid($postData)) {
             // Instantiate security manager for generating MAC
             $securityManager = new Application_Core_Security($this->_params->connect->ref->security->securityString->user);
             $macToken = $securityManager->generate(array($this->_agentSchemeNumber, $this->_agentId));
             // cURL original page in old ref system, bleurgh
             $baseReferencingUrl = $this->_params->connect->baseUrl->referencing;
             $to = $pageForm->getElement('email')->getValue();
             $url = "{$baseReferencingUrl}frontEnd/emailtenantlink.php?refno={$refno}&tempemail={$to}&brand=default&agentToken={$macToken}";
             // TODO: Use Zend_Http_Client and Zend_Http_Client_Adapter_Curl
             $ch = curl_init($url);
             curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
             curl_setopt($ch, CURLOPT_AUTOREFERER, true);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
             curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
             curl_setopt($ch, CURLOPT_AUTOREFERER, true);
             curl_setopt($ch, CURLOPT_TIMEOUT, 60);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_exec($ch);
             $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
             if ($status != 200) {
                 // Show user there was a problem
                 $this->view->error = "({$status}): " . curl_error($ch);
                 $this->_helper->viewRenderer('resend-email-failed');
             } else {
                 curl_close($ch);
                 // TODO: Check for error being returned
                 if (false) {
                     // Show user there was a fatal problem
                     $this->_helper->viewRenderer('resend-email-failed');
                 } else {
                     //Update e-mail address.
                     if ($pageForm->getElement('replace')->getValue() == '1') {
                         //Get the legacy Tenant ID, then use that to identify the
                         //Tenant record to update in the legacy Tenant table.
                         $legacyEnquiryDatasource = new Datasource_ReferencingLegacy_Enquiry();
                         $legacyTenantId = $legacyEnquiryDatasource->getTenantId($reference->externalId);
                         $rsds = new Datasource_ReferencingLegacy_ReferenceSubject();
                         $rsds->updateField($legacyTenantId, Datasource_ReferencingLegacy_ReferenceSubject::FIELD_EMAIL, $to);
                     }
                     // Show user all was successful
                     $this->_helper->viewRenderer('resend-email-confirmation');
                 }
             }
         } else {
             // Show errors back to user
             $allErrors = $pageForm->getMessages();
             foreach ($allErrors as $field => $errors) {
                 foreach ($errors as $errorType => $errorMessage) {
                     $this->_helper->flashmessages->addMessage($errorMessage);
                 }
             }
         }
     } else {
         // Pre-fill in refno, e-mail address and replacement checkbox
         $pageForm->getElement('email')->setValue($reference->referenceSubject->contactDetails->email1);
         $pageForm->getElement('replace')->setValue(1);
     }
     $this->view->refno = $refno;
     $this->view->applicantName = "{$reference->referenceSubject->name->title} {$reference->referenceSubject->name->firstName} {$reference->referenceSubject->name->lastName}";
     $this->view->applicantType = $applicantType;
     $this->view->form = $pageForm;
     $this->view->flashMessages = $this->_helper->flashmessages->getCurrentMessages();
 }