/** * Advises if specific informations are still missing on a reference. * * @param Model_Referencing_Reference $reference * Represents the reference to check. * * @param string $missingElement * Indicates what missing information to search for. * * @return boolean * Returns true if the $missingElement is still missing, false otherwise. * * @todo * Bank account details for foreign nationals not yet implemented. */ protected function _isStillMissing($reference, $missingElement) { $isStillMissing = false; try { if (preg_match("/Property street/", $missingElement) == 1) { if (empty($reference->propertyLease->property->address->addressLine1)) { $isStillMissing = true; } } else { if (preg_match("/Property town/", $missingElement) == 1) { if (empty($reference->propertyLease->property->address->town)) { $isStillMissing = true; } } else { if (preg_match("/Property total rent/", $missingElement) == 1) { if (empty($reference->propertyLease->rentPerMonth)) { $isStillMissing = true; } else { if ($reference->propertyLease->rentPerMonth->getValue() == 0) { $isStillMissing = true; } } } else { if (preg_match("/Tenant christian name/", $missingElement) == 1) { if (empty($reference->referenceSubject->name->firstName)) { $isStillMissing = true; } } else { if (preg_match("/Tenant last name/", $missingElement) == 1) { if (empty($reference->referenceSubject->name->lastName)) { $isStillMissing = true; } } else { if (preg_match("/Invalid date of birth/", $missingElement) == 1) { if (empty($reference->referenceSubject->dob)) { $isStillMissing = true; } } else { if (preg_match("/total annual income/", $missingElement) == 1) { //The legacy datasources are crap and store the total annual income in the Tenant table //rather than distributing this across the occupational records in the badly-named employment //table. Test this. $referenceSubjectDatasource = new Datasource_ReferencingLegacy_ReferenceSubject(); $totalAnnualIncome = $referenceSubjectDatasource->getLegacyTotalAnnualIncome($reference->externalId); if (empty($totalAnnualIncome)) { $isStillMissing = true; } else { if ($totalAnnualIncome->getValue() == 0) { $isStillMissing = true; } } } else { if (preg_match("/The tenants rent share is missing/", $missingElement) == 1) { if (empty($reference->referenceSubject->shareOfRent)) { $isStillMissing = true; } else { if ($reference->referenceSubject->shareOfRent->getValue() == 0) { $isStillMissing = true; } } } else { if (preg_match("/Application form - The Bank Account/", $missingElement) == 1) { //Full string is: Application form - The Bank Account/Passport No/Nationality Details was missing } else { if (preg_match("/Current address - months at address/", $missingElement) == 1) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) { if (empty($residence->duration)) { $isStillMissing = true; } } } } else { if (preg_match("/Current address - street was blank/", $missingElement) == 1) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) { if (empty($residence->address->addressLine1)) { $isStillMissing = true; } } } } else { if (preg_match("/Current address - postcode was blank/", $missingElement) == 1) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) { if (empty($residence->address->postCode)) { $isStillMissing = true; } } } } else { if (preg_match("/1st Previous address - street was blank/", $missingElement) == 1) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::FIRST_PREVIOUS) { if (empty($residence->address->addressLine1)) { $isStillMissing = true; } } } } else { if (preg_match("/1st Previous address - postcode was blank/", $missingElement) == 1) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::FIRST_PREVIOUS) { if (empty($residence->address->postCode)) { $isStillMissing = true; } } } } else { if (preg_match("/1st previous address - months at address/", $missingElement) == 1) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::FIRST_PREVIOUS) { if (empty($residence->duration)) { $isStillMissing = true; } } } } else { if (preg_match("/2nd Previous address - street was blank/", $missingElement) == 1) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::SECOND_PREVIOUS) { if (empty($residence->address->addressLine1)) { $isStillMissing = true; } } } } else { if (preg_match("/2nd Previous address - postcode was blank/", $missingElement) == 1) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::SECOND_PREVIOUS) { if (empty($residence->address->postCode)) { $isStillMissing = true; } } } } else { if (preg_match("/No Property Landlord name given/", $missingElement) == 1) { if (empty($reference->propertyLease->prospectiveLandlord->name->firstName)) { if (empty($reference->propertyLease->prospectiveLandlord->name->lastName)) { $isStillMissing = true; } } } else { if (preg_match("/No Property Landlord street address given/", $missingElement) == 1) { if (empty($reference->propertyLease->prospectiveLandlord->address->addressLine1)) { $isStillMissing = true; } } else { if (preg_match("/No Property Landlord town address given/", $missingElement) == 1) { if (empty($reference->propertyLease->prospectiveLandlord->address->town)) { $isStillMissing = true; } } else { if (preg_match("/No Property Landlord telephone number given/", $missingElement) == 1) { if (empty($reference->propertyLease->prospectiveLandlord->contactDetails->telephone1)) { if (empty($reference->propertyLease->prospectiveLandlord->contactDetails->telephone2)) { $isStillMissing = true; } } } else { if (preg_match("/No Property Landlord telephone, email/", $missingElement) == 1) { if (empty($reference->propertyLease->prospectiveLandlord->contactDetails->telephone1)) { if (empty($reference->propertyLease->prospectiveLandlord->contactDetails->telephone2)) { if (empty($reference->propertyLease->prospectiveLandlord->contactDetails->email1)) { if (empty($reference->propertyLease->prospectiveLandlord->contactDetails->email2)) { if (empty($reference->propertyLease->prospectiveLandlord->contactDetails->fax1)) { if (empty($reference->propertyLease->prospectiveLandlord->contactDetails->fax2)) { $isStillMissing = true; } } } } } } } else { if (preg_match("/No Property Landlord postcode given/", $missingElement) == 1) { if (empty($reference->propertyLease->prospectiveLandlord->address->postCode)) { $isStillMissing = true; } } else { if (preg_match("/No Landlord telephone, email or fax/", $missingElement) == 1) { //Current landlord foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) { if (empty($residence->refereeDetails->contactDetails->telephone1)) { if (empty($residence->refereeDetails->contactDetails->telephone2)) { if (empty($residence->refereeDetails->contactDetails->email1)) { if (empty($residence->refereeDetails->contactDetails->email2)) { if (empty($residence->refereeDetails->contactDetails->fax1)) { if (empty($residence->refereeDetails->contactDetails->fax2)) { $isStillMissing = true; } } } } } } break; } } } else { if (preg_match("/current employer start date invalid/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) { if (empty($occupation->startDate)) { $isStillMissing = true; } break; } } } else { if (preg_match("/current employer end date invalid/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) { if (empty($occupation->endDate)) { $isStillMissing = true; } break; } } } else { if (preg_match("/current employer gross salary not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) { if (empty($occupation->income)) { $isStillMissing = true; } break; } } } else { if (preg_match("/current employer company name not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) { if (empty($occupation->refereeDetails->organisationName)) { $isStillMissing = true; } break; } } } else { if (preg_match("/current employer company address and postcode not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) { if (empty($occupation->refereeDetails->organisationAddress->addressLine1)) { if (empty($occupation->refereeDetails->organisationAddress->postCode)) { $isStillMissing = true; } } break; } } } else { if (preg_match("/current employer telephone number not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) { if (empty($occupation->refereeDetails->contactDetails->telephone1)) { if (empty($occupation->refereeDetails->contactDetails->telephone2)) { $isStillMissing = true; } } break; } } } else { if (preg_match("/second employer start date invalid/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->classification == Model_Referencing_OccupationImportance::SECONDARY) { if (empty($occupation->startDate)) { $isStillMissing = true; } break; } } } else { if (preg_match("/second employer gross salary not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->classification == Model_Referencing_OccupationImportance::SECONDARY) { if (empty($occupation->income)) { $isStillMissing = true; } break; } } } else { if (preg_match("/second employer company name not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->classification == Model_Referencing_OccupationImportance::SECONDARY) { if (empty($occupation->refereeDetails->organisationName)) { $isStillMissing = true; } break; } } } else { if (preg_match("/second employer company address and/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->classification == Model_Referencing_OccupationImportance::SECONDARY) { if (empty($occupation->refereeDetails->organisationAddress->addressLine1)) { if (empty($occupation->refereeDetails->organisationAddress->postCode)) { $isStillMissing = true; } } break; } } } else { if (preg_match("/second employer telephone number not/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->classification == Model_Referencing_OccupationImportance::SECONDARY) { if (empty($occupation->refereeDetails->contactDetails->telephone1)) { if (empty($occupation->refereeDetails->contactDetails->telephone2)) { $isStillMissing = true; } } break; } } } else { if (preg_match("/Application form - no product selected/", $missingElement) == 1) { if (is_null($reference->productSelection->product->name)) { $isStillMissing = true; } } else { if (preg_match("/future employer start date invalid/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::FUTURE) { if (empty($occupation->startDate)) { $isStillMissing = true; } break; } } } else { if (preg_match("/future employer gross salary not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::FUTURE) { if (empty($occupation->income)) { $isStillMissing = true; } break; } } } else { if (preg_match("/future employer company name not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::FUTURE) { if (empty($occupation->refereeDetails->organisationName)) { $isStillMissing = true; } break; } } } else { if (preg_match("/future employer company address/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::FUTURE) { if (empty($occupation->refereeDetails->organisationAddress->addressLine1)) { if (empty($occupation->refereeDetails->organisationAddress->postCode)) { $isStillMissing = true; } } break; } } } else { if (preg_match("/future employer telephone number not provided/", $missingElement) == 1) { foreach ($reference->referenceSubject->occupations as $occupation) { if ($occupation->chronology == Model_Referencing_OccupationChronology::FUTURE) { if (empty($occupation->refereeDetails->contactDetails->telephone1)) { if (empty($occupation->refereeDetails->contactDetails->telephone2)) { $isStillMissing = true; } } break; } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } catch (Exception $e) { $isStillMissing = true; } return $isStillMissing; }
/** * Retrieves the specified Reference. * * @param mixed $referenceId * The unique Reference identifier. May be the IRN (internal refno) or the ERN (external * refno). * * @return mixed * The Reference details, encapsulated in a Model_Referencing_Reference object, * or null if the Reference cannot be found. */ public function getEnquiry($referenceId) { $enquiryRow = $this->_getEnquiryRow($referenceId); if (empty($enquiryRow)) { Application_Core_Logger::log(get_class() . '::' . __FUNCTION__ . ':Unable to find Enquiry.'); $returnVal = null; } else { //Populate the details into a Customer object. $reference = new Model_Referencing_Reference(); $reference->internalId = $enquiryRow->ID; $reference->externalId = $enquiryRow->RefNo; $reference->declarationVersion = $enquiryRow->declaration_version; $productDatasource = new Datasource_ReferencingLegacy_Product(); $product = $productDatasource->getProductByID($enquiryRow->ProductID); if (!empty($product)) { $reference->productSelection = new Model_Referencing_ProductSelection(); $reference->productSelection->referenceId = $enquiryRow->ID; $reference->productSelection->product = $product; switch ($enquiryRow->PolicyLength) { case 0: $reference->productSelection->duration = 0; break; case 6: $reference->productSelection->duration = 6; break; case 12: $reference->productSelection->duration = 12; break; default: $reference->productSelection->duration = 0; } } $progressDatasource = new Datasource_ReferencingLegacy_Progress(); $reference->progress = $progressDatasource->getByEnquiry($enquiryRow->RefNo); $propertyLeaseDatasource = new Datasource_ReferencingLegacy_PropertyLease(); $reference->propertyLease = $propertyLeaseDatasource->getPropertyLease($enquiryRow->proprefno, $enquiryRow->RefNo); $referenceSubjectDatasource = new Datasource_ReferencingLegacy_ReferenceSubject(); $reference->referenceSubject = $referenceSubjectDatasource->getReferenceSubject($enquiryRow->TenantID, $enquiryRow->RefNo); //Build the reference status. $referenceStatus = new Model_Referencing_ReferenceStatus(); $referenceStatus->referenceId = $enquiryRow->ID; if ($enquiryRow->nochange == 'cancelled') { $referenceStatus->state = Model_Referencing_ReferenceStates::CANCELLED; } else { $progressManager = new Manager_Referencing_Progress(); $progressItem = $progressManager->findSpecificProgressItem($reference->progress, Model_Referencing_ProgressItemVariables::FINAL_REPORT_BUILT); if ($progressItem == null || $progressItem->itemState == Model_Referencing_ProgressItemStates::INCOMPLETE) { $referenceStatus->state = Model_Referencing_ReferenceStates::INPROGRESS; } else { if (strcasecmp("Incomplete - Awaiting further information", $enquiryRow->conclusion) == 0) { $referenceStatus->state = Model_Referencing_ReferenceStates::INCOMPLETE; $referenceStatus->reasonForState = Model_Referencing_ReferenceStateReasons::AWAITING_FURTHER_INFORMATION; } else { if (strcasecmp("Incomplete - Awaiting Completion of Tenant", $enquiryRow->conclusion) == 0) { $referenceStatus->state = Model_Referencing_ReferenceStates::INCOMPLETE; $referenceStatus->reasonForState = Model_Referencing_ReferenceStateReasons::AWAITING_TENANT_COMPLETION; } else { $referenceStatus->state = Model_Referencing_ReferenceStates::COMPLETE; } } } } $reference->status = $referenceStatus; //Build the reference decision if ($enquiryRow->conclusion == '' || preg_match("/incomplete/i", $enquiryRow->conclusion)) { $reference->decision = null; } else { $decision = new Model_Referencing_Decision(); $decision->referenceId = $enquiryRow->ID; if (preg_match("/not acceptable/i", $enquiryRow->conclusion)) { $decision->decision = Model_Referencing_Decisions::NOT_ACCEPTABLE; $decision->decisionReasons = ''; //TO DO HERE } else { $decision->decision = Model_Referencing_Decisions::ACCEPTABLE; //Add caveats, if applicable $caveats = array(); if (preg_match("/guarantor/i", $enquiryRow->conclusion)) { $decisionCaveat = new Model_Referencing_DecisionCaveat(); $decisionCaveat->caveat = Model_Referencing_DecisionCaveats::WITH_GUARANTOR; //Identify the caveat reasons. $decisionCaveat->caveatReason = null; $caveats[] = $decisionCaveat; } if (preg_match("/condition/i", $enquiryRow->conclusion)) { $decisionCaveat = new Model_Referencing_DecisionCaveat(); $decisionCaveat->caveat = Model_Referencing_DecisionCaveats::WITH_CONDITION; //Identify the caveat reasons. $decisionCaveat->caveatReason = null; $caveats[] = $decisionCaveat; } if (!empty($caveats)) { //Attach the array of caveat(s) to the Decision object. $decision->caveats = $caveats; } } //Attach the Decision object to the Reference object. $reference->decision = $decision; } /* $reference->termsAgreedBy = $enquiryRow->termsagreedby; */ if ($enquiryRow->termsagreedby == 'Tenant') { $reference->completionMethod = Model_Referencing_ReferenceCompletionMethods::TWO_STEP; } else { $reference->completionMethod = Model_Referencing_ReferenceCompletionMethods::ONE_STEP; } //Set the customer details. If the agent is HomeLet Direct, then the customer is a PLL. $agentDatasource = new Datasource_Core_Agents(); $lettingAgent = $agentDatasource->getAgent($enquiryRow->AgentID); $params = Zend_Registry::get('params'); if ($lettingAgent->agentSchemeNumber != $params->homelet->defaultAgent) { $reference->customer = new Model_Referencing_CustomerMap(); $reference->customer->customerType = Model_Referencing_CustomerTypes::AGENT; $reference->customer->customerId = $lettingAgent->agentSchemeNumber; $reference->customer->legacyCustomerId = null; } else { $reference->customer = new Model_Referencing_CustomerMap(); $reference->customer->customerType = Model_Referencing_CustomerTypes::LANDLORD; if ($enquiryRow->landrefno != 0) { $reference->customer->legacyCustomerId = $enquiryRow->landrefno; } } $returnVal = $reference; } return $returnVal; }
/** * Retrieves all residence details against a specific Enquiry. * * @param string $enquiryId * The unique external Enquiry identifier. * * @return mixed * An array of Model_Referencing_Residence objects, or null if no * residences found. * * @todo * The residence referencing details are not yet captured by this method. */ public function getByEnquiry($enquiryId) { $returnArray = array(); //Use the Enquiry datasource to retrieve the identifiers to the reference subject's //residences. $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); $currentResidenceId = $enquiryDatasource->getResidenceId($enquiryId, Model_Referencing_ResidenceChronology::CURRENT); $firstPreviousResidenceId = $enquiryDatasource->getResidenceId($enquiryId, Model_Referencing_ResidenceChronology::FIRST_PREVIOUS); $secondPreviousResidenceId = $enquiryDatasource->getResidenceId($enquiryId, Model_Referencing_ResidenceChronology::SECOND_PREVIOUS); //Now identify the residences recorded in the tenant_address table. for ($i = 0; $i < 3; $i++) { switch ($i) { case 0: $residenceId = $currentResidenceId; break; case 1: $residenceId = $firstPreviousResidenceId; break; case 2: $residenceId = $secondPreviousResidenceId; break; } if (empty($residenceId)) { continue; } $select = $this->select(); $select->where('refno = ?', $residenceId); $residenceRow = $this->fetchRow($select); if (!empty($residenceRow)) { $residence = new Model_Referencing_Residence(); //Set the ID. $residence->id = $residenceRow->refno; //Set the address. $address = new Model_Core_Address(); $address->flatNumber = $residenceRow->flat; $address->houseName = $residenceRow->house; $address->addressLine1 = $residenceRow->address1; $address->addressLine2 = $residenceRow->address2; $address->town = $residenceRow->town; $address->postCode = $residenceRow->postcode; $address->country = $residenceRow->country; $residence->address = $address; //Set the chronology. switch ($i) { case 0: $residence->chronology = Model_Referencing_ResidenceChronology::CURRENT; break; case 1: $residence->chronology = Model_Referencing_ResidenceChronology::FIRST_PREVIOUS; break; case 2: $residence->chronology = Model_Referencing_ResidenceChronology::SECOND_PREVIOUS; break; } //Set the duration of occupancy. $residence->durationAtAddress = $residenceRow->monthshere; //Set the residential status (owner, tenant, living with relatives). if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) { $referenceSubjectDatasource = new Datasource_ReferencingLegacy_ReferenceSubject(); $residentialStatus = $referenceSubjectDatasource->getLegacyResidentialStatus($enquiryId); switch ($residentialStatus) { case 'Owner': $residence->status = Model_Referencing_ResidenceStatus::OWNER; break; case 'Tenant': $residence->status = Model_Referencing_ResidenceStatus::TENANT; break; case 'Living with Relative': $residence->status = Model_Referencing_ResidenceStatus::LIVING_WITH_RELATIVES; break; default: $residence->status = null; break; } } else { $residence->status = null; } //Set the referee and referencing details, if applicable. We only obtain a referee and //reference against the current residence, and even then only if the applicant is a //tenant at the current residence. $residence->refereeDetails = null; $residence->referencingDetails = null; if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) { if ($residence->status == Model_Referencing_ResidenceStatus::TENANT) { $refereeDatasource = new Datasource_ReferencingLegacy_ResidentialReferees(); $residence->refereeDetails = $refereeDatasource->getByEnquiry($enquiryId); $residentialReferenceDatasource = new Datasource_ReferencingLegacy_ResidentialReferences(); $residence->referencingDetails = $residentialReferenceDatasource->getByEnquiry($enquiryId); } } $returnArray[] = $residence; } } //Finalize if (empty($returnArray)) { $returnVal = null; } else { $returnVal = $returnArray; } return $returnVal; }
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(); }
/** * Copies the referencing data from the new datasources to the old. * * Allows newly entered references visibility on the HRT. * * @param Model_Referencing_Reference $reference * The Reference to muntify. * * @return void */ public function updateReference($reference) { if (!empty($reference->propertyLease->prospectiveLandlord)) { // The Enquiry.newllrefno is the prospective landord details stored in // the landlordref table. $name = $reference->propertyLease->prospectiveLandlord->name; $address = $reference->propertyLease->prospectiveLandlord->address; $contactDetails = $reference->propertyLease->prospectiveLandlord->contactDetails; $landlordRefDatasource = new Datasource_ReferencingLegacy_LandlordRef(); $muntingEnquiryFields['newllrefno'] = $landlordRefDatasource->insertLandlordRef($name, $address, $contactDetails); } // The Enquiry.lrefrefno is the current landlord details. $muntingEnquiryFields['lrefrefno'] = ''; if (!empty($reference->referenceSubject->residences)) { foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) { if ($residence->status == Model_Referencing_ResidenceStatus::TENANT) { //If product is a full reference, then record the landlord reference details if ($reference->productSelection->product->variables[Model_Referencing_ProductVariables::FULL_REFERENCE] == 1) { $name = $residence->refereeDetails->name; $address = $residence->refereeDetails->address; $contactDetails = $residence->refereeDetails->contactDetails; $muntingEnquiryFields['lrefrefno'] = $landlordRefDatasource->insertLandlordRef($name, $address, $contactDetails); } } break; } } } //The Enquiry.proprefno holds the property lease details. $propertyLeaseDatasource = new Datasource_ReferencingLegacy_PropertyLease(); $muntingEnquiryFields['proprefno'] = $propertyLeaseDatasource->insertPropertyLease($reference->propertyLease); //The Enquiry.TenantID holds the ReferenceSubject details. $referenceSubjectDatasource = new Datasource_ReferencingLegacy_ReferenceSubject(); $muntingEnquiryFields['TenantID'] = $referenceSubjectDatasource->insertReferenceSubject($reference->referenceSubject); //The Enquiry.ta[1-3]refno hold indexes to the tenant_address table, which holds up to //three of the reference subject addresses. $currentResidence = 0; $firstPreviousResidence = 0; $secondPreviousResidence = 0; foreach ($reference->referenceSubject->residences as $residence) { switch ($residence->chronology) { case Model_Referencing_ResidenceChronology::CURRENT: $currentResidence = $residence; break; case Model_Referencing_ResidenceChronology::FIRST_PREVIOUS: $firstPreviousResidence = $residence; break; case Model_Referencing_ResidenceChronology::SECOND_PREVIOUS: $secondPreviousResidence = $residence; break; } } //Initial settings for the ta[1-3]refnos $muntingEnquiryFields['ta1refno'] = 0; $muntingEnquiryFields['ta2refno'] = 0; $muntingEnquiryFields['ta3refno'] = 0; //Cycle through the residences and save each. $residenceDatasource = new Datasource_ReferencingLegacy_Residences(); for ($i = 0; $i < count($reference->referenceSubject->residences); $i++) { if (count($reference->referenceSubject->residences) == $i + 1) { $isLast = true; } else { $isLast = false; } switch ($i) { case 0: $muntingEnquiryFields['ta1refno'] = $residenceDatasource->insertResidence($currentResidence, $isLast); break; case 1: $muntingEnquiryFields['ta2refno'] = $residenceDatasource->insertResidence($firstPreviousResidence, $isLast); break; case 2: $muntingEnquiryFields['ta3refno'] = $residenceDatasource->insertResidence($secondPreviousResidence, $isLast); break; } } //If the first residence is overseas, then ensure its ID is stored the Enquiry.foreignaddress //field. $muntingEnquiryFields['foreignaddress'] = 0; if ($currentResidence->address->isOverseasAddress) { $muntingEnquiryFields['foreignaddress'] = $muntingEnquiryFields['ta1refno']; $muntingEnquiryFields['ta1refno'] = 0; } //Update the Enquiry record. $this->_pushToEnquiryMunt($reference, $muntingEnquiryFields); //Insert the Occupation records $this->_pushToEmploymentMunt($reference); //Update the progress record $progressDatasource = new Datasource_ReferencingLegacy_Progress(); $progressDatasource->updateProgress($reference); }