/** * Indicates if the residential reference is applicable. * * @param string $enquiryId * The unique external Enquiry identifier. * * @return boolean * True if the reference is applicable, false otherwise. */ public function getIsReferenceApplicable($enquiryId) { $enquiry = new Datasource_ReferencingLegacy_Enquiry(); $legacyLandlordKey = $enquiry->getCurrentLandlordId($enquiryId); if (empty($legacyLandlordKey)) { $returnVal = false; } else { $returnVal = true; } return $returnVal; }
public function NotificationHistoryPanel($agentSchemeNumber) { $params = Zend_Registry::get('params'); $baseReferencingUrl = $params->connect->baseUrl->referencing; // Instantiate security manager for generating MAC $securityManager = new Application_Core_Security($params->connect->ref->security->securityString->agent); $agentId = $this->view->agentId; $macToken = $securityManager->generate(array($agentSchemeNumber, $agentId)); // Zend_Debug::dump($this->view->agentId);die(); $rs = new Datasource_Referencing_NotificationHistory(); $dataToDisplay = $rs->getHistoryByASN($agentSchemeNumber); $enquiry = new Datasource_ReferencingLegacy_Enquiry(); //Zend_Debug::dump($enquiry); $partialArray = array(); $x = 0; foreach ($dataToDisplay as $d) { //Zend_Debug::dump($d); $refno = $d['refno']; $ds = $enquiry->getEnquiry($refno); $retrieveReportString = "/reports/view-report-pdf?refno={$refno}&repType=&contentDisposition=attachment"; $partialArray[$x]['refno'] = $refno; $partialArray[$x]['line'] = ''; $partialArray[$x]['viewReportURL'] = $retrieveReportString; $name = trim("{$ds->referenceSubject->name->firstName} {$ds->referenceSubject->name->lastName}"); if ($name != '') { $partialArray[$x]['line'] .= "{$name}, "; } if (isset($ds->propertyLease->address->addressLine1)) { $partialArray[$x]['line'] .= $ds->propertyLease->address->addressLine1 . ', '; } /*if(isset($ds->propertyLease->address->addressLine2) && $ds->propertyLease->address->addressLine2 != ""){ $partialArray[$x]['line'] .= $ds->propertyLease->address->addressLine2 . ', '; } if(isset($ds->propertyLease->address->postCode)){ $partialArray[$x]['line'] .= $ds->propertyLease->address->postCode . ', '; }*/ $partialArray[$x]['line'] = preg_replace('/, $/', ' ', $partialArray[$x]['line']); //$partialArray[$x]['line'] .= "<em>(Reference number: {$refno})</em>"; $x++; } //Zend_Debug::dump($partialArray);die(); return array($this->view->partialLoop('partials/notificationhistorypanel.phtml', $partialArray), $x); }
/** * Returns the property aspect items relating to a reference. * * @param string $enquiryId * The unique external Enquiry identifier. * * @return mixed * An array of Model_Referencing_PropertyAspects_PropertyAspectItem objects, * or null if none found. */ public function getAspects($enquiryId) { //Convert the external enquiry identifier to internal. $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); $id = $enquiryDatasource->getInternalIdentifier($enquiryId); $select = $this->select(); $select->where('enquiry_id = ? ', $id); $rows = $this->fetchAll($select); $returnVal = null; if (count($rows) != 0) { $returnVal = array(); foreach ($rows as $currentRow) { $aspectItem = new Model_Referencing_PropertyAspects_PropertyAspectItem(); $aspectItem->referenceId = $id; $aspectItem->propertyAspectId = $currentRow->property_aspect_id; $aspectItem->value = $currentRow->value; $returnVal[] = $aspectItem; } } return $returnVal; }
/** * Unsubscribes a reference from any further marketing. * * @param string $enquiryId * The external enquiry identifier. * * @return boolean * True on successful update, false otherwise. */ public function unsubscribe($enquiryId) { $enquiry = new Datasource_ReferencingLegacy_Enquiry(); $enquiryId = $enquiry->getInternalIdentifier($enquiryId); if (empty($enquiryId)) { return false; } //Update. $data = array('is_allowed' => 0); $where = $this->quoteInto('enquiry_id = ? AND data_protection_id = 1', $enquiryId); if ($this->update($data, $where) > 0) { $isPhonePostChanged = true; } else { $isPhonePostChanged = false; } $where = $this->getAdapter()->quoteInto('enquiry_id = ? AND data_protection_id = 3', $enquiryId); if ($this->update($data, $where) > 0) { $isSmsEmailChanged = true; } else { $isSmsEmailChanged = false; } $where = $this->getAdapter()->quoteInto('enquiry_id = ? AND data_protection_id = 4', $enquiryId); if ($this->update($data, $where) > 0) { $isNonDigitalPreferencehanged = true; } else { $isNonDigitalPreferencehanged = false; } $where = $this->getAdapter()->quoteInto('enquiry_id = ? AND data_protection_id = 5', $enquiryId); if ($this->update($data, $where) > 0) { $isDigitalPreferencehanged = true; } else { $isDigitalPreferencehanged = false; } //Insertion was successful. Make a note of this in the data protection //audit table. $audit = new Datasource_ReferencingLegacy_DataProtectionAudits(); $audit->unsubscribeFromTenantMailer($enquiryId, $isPhonePostChanged, $isSmsEmailChanged, $isNonDigitalPreferencehanged, $isDigitalPreferencehanged); return true; }
/** * Login screen * * @return void */ public function loginAction() { $this->view->pageTitle = 'Login | HomeLet Tenant Referencing Application Tracker'; $pageForm = new Form_TenantsReferencingTracker_Login(); $request = $this->getRequest(); $formData = $request->getPost(); $pageForm->populate($formData); if ($request->isPost()) { // If this is a valid IRIS login, store credentials in session and redirect to new IRIS TAT section if (Form_TenantsReferencingTracker_Login::IRIS_LOGIN === $pageForm->isValid($formData)) { $globalSession = new Zend_Session_Namespace('homelet_global'); $globalSession->legacy_tat_login = $formData; $this->_helper->redirector->gotoUrl('/tenant-application-tracker/login'); return; } // Legacy HRT TAT login if ($pageForm->isValid($formData)) { // Log in successful // TODO: Use Zend_Auth $data = $pageForm->getValues(); $this->_enquiryId = $this->_pageSession->enquiryId = $data['tenant_reference_number']; // Get the ASN from the enquiry number // TODO: Requires a manager rather than using direct access to data source $enquiryDS = new Datasource_ReferencingLegacy_Enquiry(); $enquiry = $enquiryDS->getEnquiry($this->_enquiryId); $this->_asn = $this->_pageSession->asn = $enquiry->customer->customerId; // Set the ASN for the "Get a Quote" links - note these links do not directly go to the TCI+ process since OBC 1051 - Tenancy Liability // Put the ASN into the global session for insurance products that lay below the new insurance product selection page to pick up. $globalSession = new Zend_Session_Namespace('homelet_global'); $globalSession->agentSchemeNumber = $this->_asn; // Log Activity Application_Core_ActivityLogger::log('TAT Login', 'complete', 'TAT', null, "IRN: {$this->_enquiryId}"); // Redirect user to index page $this->_helper->redirector->gotoUrl('/tenants/reference-tracker'); return; } else { // Unable to log in, pass form-level errors to view $this->view->errors = $pageForm->getErrorMessages(); // Decrement log in attempt counter $this->_logInAttempts = $this->_pageSession->logInAttempts = --$this->_logInAttempts; // Log MI event Application_Core_ActivityLogger::log('TAT Login', 'failure', 'TAT', null, print_r($this->view->errors, true)); } } $this->view->form = $pageForm; }
/** * Retrieves the specified prospective landlord using the Enquiry identifier. * * @param string $enquiryId * The unique external Enquiry identifier. * * @return mixed * The prospective landlord details encapsulated in a * Model_Referencing_ProspectiveLandlord object, or null if the prospective * landlord cannot be found. */ public function getByEnquiry($enquiryId) { $enquiryDataSource = new Datasource_ReferencingLegacy_Enquiry(); $prospectiveLandlordId = $enquiryDataSource->getProspectiveLandlordId($enquiryId); return $this->getLandlord($prospectiveLandlordId); }
/** * Retrieves all occupation details against a specific Enquiry. * * @param string $enquiryId * The unique external Enquiry identifier. * * @return mixed * An array of Model_Referencing_Occupation objects, or null if no * occuapations are found. * * @todo * Occupation referee details are not yet captured and stored. */ public function getAllByEnquiry($enquiryId) { $returnArray = array(); //First check if the reference subject is a student or unemployed - neither of these //occupations are stored in the employment table. $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); $legacyEmploymentType = $enquiryDatasource->getLegacyEmploymentType($enquiryId); if ($enquiryDatasource->getIdentifierType($enquiryId) == Model_Referencing_ReferenceKeyTypes::EXTERNAL) { $referenceId = $enquiryDatasource->getInternalIdentifier($enquiryId); } else { $referenceId = $enquiryId; } if ($legacyEmploymentType == 'Unemployed') { $occupation = new Model_Referencing_Occupation(); $occupation->referenceId = $referenceId; $occupation->importance = Model_Referencing_OccupationImportance::FIRST; $occupation->chronology = Model_Referencing_OccupationChronology::CURRENT; $occupation->type = Model_Referencing_OccupationTypes::UNEMPLOYMENT; $occupation->isPermanent = true; $occupation->income = new Zend_Currency(array('precision' => 0, 'value' => 0)); //Referees and referencing are not applicable for this occupation status. $occupation->refereeDetails = null; $occupation->referencingDetails = null; $returnArray[] = $occupation; } else { if ($legacyEmploymentType == 'Student') { $occupation = new Model_Referencing_Occupation(); $occupation->referenceId = $referenceId; $occupation->importance = Model_Referencing_OccupationImportance::FIRST; $occupation->chronology = Model_Referencing_OccupationChronology::CURRENT; $occupation->type = Model_Referencing_OccupationTypes::STUDENT; $occupation->isPermanent = true; $occupation->income = new Zend_Currency(array('precision' => 0, 'value' => 0)); //Referees and referencing are not applicable for this occupation status. $occupation->refereeDetails = null; $occupation->referencingDetails = null; $returnArray[] = $occupation; } } //Now identify the occupations recorded in the employment table. $select = $this->select(); $select->where('enquiryRefno = ? ', (string) $enquiryId); $occupationsArray = $this->fetchAll($select); if (!empty($occupationsArray)) { foreach ($occupationsArray as $occupationRow) { $occupation = new Model_Referencing_Occupation(); $occupation->id = $occupationRow->refno; $occupation->referenceId = $referenceId; $occupation->importance = $this->_getOccupationimportance($occupationRow->Jobstatus); $occupation->chronology = $this->_getOccupationalChronology($occupationRow->Jobstatus); //The $occupationRow->type refers to the occupational confirmation type, i.e. the //person or means by which the reference will be provided. Therefore it needs to be //translated into a type. $occupation->type = $this->_getOccupationType($occupationRow->type); if ($occupationRow->permanent == 'Yes') { $occupation->isPermanent = true; } else { $occupation->isPermanent = false; } if (!empty($occupationRow->salary)) { $occupation->income = new Zend_Currency(array('precision' => 0, 'value' => $occupationRow->salary)); } if ($occupationRow->startdate != '0000-00-00') { $occupation->startDate = new Zend_Date($occupationRow->startdate, Zend_Date::ISO_8601); } if ($occupationRow->complete == 1) { $occupation->isComplete = true; } else { $occupation->isComplete = false; } //Assign the occupation variables, if applicable. $variables = array(); if ($occupationRow->enddate != '0000-00-00') { $endDate = new Zend_Date($occupationRow->enddate, Zend_Date::ISO_8601); $variables[Model_Referencing_OccupationVariables::ENDDATE] = $endDate; } $position = $occupationRow->positionheld; if (!empty($position)) { $variables[Model_Referencing_OccupationVariables::POSITION] = $position; } $payrollNo = $occupationRow->payrollno; if (!empty($payrollNo)) { $variables[Model_Referencing_OccupationVariables::PAYROLL_NUMBER] = $payrollNo; $variables[Model_Referencing_OccupationVariables::PENSION_NUMBER] = $payrollNo; } if (!empty($variables)) { $occupation->variables = $variables; } //Add the referee details and reference details. $occupationalReferees = new Datasource_ReferencingLegacy_OccupationalReferees(); $occupation->refereeDetails = $occupationalReferees->getOccupationalReferee($occupationRow->refno); $occupationalReferences = new Datasource_ReferencingLegacy_OccupationalReferences(); $occupation->referencingDetails = $occupationalReferences->getByEnquiry($enquiryId, $occupation->chronology, $occupation->importance); $returnArray[] = $occupation; } } return $returnArray; }
/** * Gets the current reference Enquiry declaration version * * @return int */ private function _getDeclarationVersion() { $session = new Zend_Session_Namespace('referencing_global'); $referencingLegacyEnquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); $reference = $referencingLegacyEnquiryDatasource->getEnquiry($session->referenceId); return (int) $reference->declarationVersion; }
/** * Search references in the legacy datasource. * * @param mixed $agentschemeno * The agent scheme number. * * @param array $criteria * The array of search criteria. * * @param string $orderBy * Must correspond to one of the consts exposed by the Model_Referencing_SearchResult class. * * @param integer $pageNumber * The current search result page number. * * @param integer $rowLimit * The number of results to display on each page. * * @return Model_Referencing_SearchResult * Encapsulates the search results. */ public function searchReferences($agentschemeno, $criteria, $orderBy, $pageNumber, $rowLimit, $offset = null) { $select = $this->select(); $select->setIntegrityCheck(false); $select->from($this->_name); $select->joinLeft('Tenant', 'Tenant.id = Enquiry.TenantID'); $select->joinLeft('progress', 'progress.refno = Enquiry.RefNo'); $select->joinLeft('Product', 'Product.ID = Enquiry.ProductID'); $select->joinLeft('property', 'property.refno = Enquiry.proprefno'); //Mandatory search items. $select->where('AgentID = ? ', $agentschemeno); $select->where('nochange != ? ', 'cancelled'); $select->where('proprefno != ? ', ''); // Don't look up any duplicates that may have been pushed in by Finance or MI events $select->where('Enquiry.RefNo NOT LIKE ?', 'HLT%'); // Added during dev build and testing to remove orphan records todo: Remove for non-dev: //$select->where('progress.start_time IS NOT NULL', ''); if (empty($criteria['refno'])) { //Optional search items. if (!empty($criteria['proprefno'])) { $where = $this->quoteInto('Enquiry.proprefno = ? ', $criteria['proprefno']); $select->where($where); } if (!empty($criteria['firstname']) || !empty($criteria['lastname'])) { // Use a sub select for the join to the tenants table - approximately 1000% quicker if (!empty($criteria['firstname']) && !empty($criteria['lastname'])) { $where = $this->quoteInto('firstname LIKE ? AND lastname LIKE ?', $criteria['firstname'] . '%', $criteria['lastname'] . '%'); } elseif (!empty($criteria['firstname'])) { $where = $this->quoteInto('firstname LIKE ? ', $criteria['firstname'] . '%'); } else { $where = $this->quoteInto('lastname LIKE ?', $criteria['lastname'] . '%'); } $select->where($where); } if (!empty($criteria['address'])) { $like = '%' . $criteria['address'] . '%'; $where = $this->quoteInto('property.address1 LIKE ? ', $like); $select->where($where); } if (!empty($criteria['town'])) { $like = '%' . $criteria['town'] . '%'; $where = $this->quoteInto('property.town LIKE ? ', $like); $select->where($where); } if (!empty($criteria['postcode'])) { $like = '%' . $criteria['postcode'] . '%'; $where = $this->quoteInto('property.postcode LIKE ? ', $like); $select->where($where); } if (!empty($criteria['state']) && preg_match("/complete|incomplete/i", $criteria['state'])) { $select->where('progress.resulttx = ? ', $criteria['state']); } if (!empty($criteria['type'])) { //Add product type(s) to the query. $expandedSearchTerms = $this->_expandProductTypes($criteria['type']); if (count($expandedSearchTerms) == 1) { //The search term has not been expanded, so use it 'as-is'. $where = $this->quoteInto('Product.Name = ? ', $criteria['type']); } else { //The search term is now two or more terms, so accommodate this. $placeHolderString = ''; for ($i = 0; $i < count($expandedSearchTerms); $i++) { if (empty($placeHolderString)) { $placeHolderString = '?'; } else { $placeHolderString .= ',?'; } } $where = $this->quoteInto("Product.Name IN ({$placeHolderString}) ", $expandedSearchTerms); } $select->where($where); } //Order by. if (empty($orderBy)) { //Apply the default orderby clause. $select->order(array('progress.start_time DESC', 'Tenant.lastname ASC')); } else { //Apply the user-selected orderby clause. switch ($orderBy) { case Model_Referencing_SearchResult::REFNO_ASC: $select->order('Enquiry.Refno ASC'); break; case Model_Referencing_SearchResult::REFNO_DESC: $select->order('Enquiry.Refno DESC'); break; case Model_Referencing_SearchResult::FIRSTNAME_ASC: $select->order('Tenant.firstname ASC'); break; case Model_Referencing_SearchResult::FIRSTNAME_DESC: $select->order('Tenant.firstname DESC'); break; case Model_Referencing_SearchResult::LASTNAME_ASC: $select->order('Tenant.lastname ASC'); break; case Model_Referencing_SearchResult::LASTNAME_DESC: $select->order('Tenant.lastname DESC'); break; case Model_Referencing_SearchResult::ADDRESS1_ASC: $select->order('property.address1 ASC'); break; case Model_Referencing_SearchResult::ADDRESS1_DESC: $select->order('property.address1 DESC'); break; case Model_Referencing_SearchResult::STARTDATE_ASC: $select->order('progress.start_time ASC'); break; case Model_Referencing_SearchResult::STARTDATE_DESC: $select->order('progress.start_time DESC'); break; } } } else { //Prepare the query based on the reference identifier only. $eds = new Datasource_ReferencingLegacy_Enquiry(); switch ($eds->getIdentifierType($criteria['refno'])) { case Model_Referencing_ReferenceKeyTypes::EXTERNAL: $select->where('Enquiry.RefNo = ? ', (string) $criteria['refno']); break; case Model_Referencing_ReferenceKeyTypes::INTERNAL: $select->where('Enquiry.ID = ? ', $criteria['refno']); break; } } // If offset supplied, add to SQL if (null !== $offset) { // If the offset is zero and row limit is zero, present only count if (0 == $offset && 0 == $rowLimit) { $select->reset(Zend_Db_Select::COLUMNS); $select->columns('COUNT(`Enquiry`.`ID`) AS enquiryCount'); $select->limit($rowLimit, $offset); $rowSet = $this->fetchAll($select); //Encapsulate the results and return. $searchResult = new Model_Referencing_SearchResult(); $searchResult->results = array(); $searchResult->totalNumberOfResults = $rowSet[0]['enquiryCount']; return $searchResult; } else { $select->limit($rowLimit, $offset); $rowSet = $this->fetchAll($select); //Encapsulate the results and return. $searchResult = new Model_Referencing_SearchResult(); $searchResult->results = $rowSet->toArray(); return $searchResult; } } //Grouping $select->group('Enquiry.RefNo'); //Run the query. $rowSet = $this->fetchAll($select); $totalNoOfResults = $rowSet->count(); //Apply resultset limits. switch ($rowLimit) { case Model_Referencing_SearchResult::TEN_ROWS: case Model_Referencing_SearchResult::TWENTY_FIVE_ROWS: case Model_Referencing_SearchResult::FIFTY_ROWS: case Model_Referencing_SearchResult::ONE_HUNDRED_ROWS: case Model_Referencing_SearchResult::ALL_ROWS: if ($rowLimit == Model_Referencing_SearchResult::ALL_ROWS) { $rowLimit = Model_Referencing_SearchResult::ONE_HUNDRED_ROWS; } //Calculate the offset. if ($pageNumber == 1) { $offset = 0; } else { $offset = $pageNumber - 1; $offset *= $rowLimit; } break; default: throw new Zend_Exception('Invalid row limit specified.'); } //Prepare the resultset. $results = array(); $loopCounter = 0; for ($i = 0; $i < $totalNoOfResults; $i++) { if ($i < $offset) { continue; } $currentRow = $rowSet->getRow($i); $results[$loopCounter] = $currentRow->toArray(); //The following are used on the reference summary page $results[$loopCounter]['applicantType'] = $this->_getApplicantTypeString($currentRow); $results[$loopCounter]['refStatus'] = $this->_getReferenceStatusString($currentRow); $loopCounter++; if ($loopCounter == $rowLimit) { break; } } //Prepare the SearchResult object. if ($pageNumber > 1) { $previousPageNumber = $pageNumber - 1; } else { $previousPageNumber = null; } if ($totalNoOfResults > $pageNumber * $rowLimit) { $nextPageNumber = $pageNumber + 1; } else { $nextPageNumber = null; } //Encapsulate the results and return. $searchResult = new Model_Referencing_SearchResult(); $searchResult->results = $results; $searchResult->resultsPerPage = $rowLimit; $searchResult->previousPageNumber = $previousPageNumber; $searchResult->currentPageNumber = $pageNumber; $searchResult->nextPageNumber = $nextPageNumber; $searchResult->maxPageNumber = ceil($totalNoOfResults / $rowLimit); $searchResult->totalNumberOfResults = $totalNoOfResults; return $searchResult; }
/** * This function handles a login attempt and validates the credentials * * @return void */ public function loginAction() { // Force user over to SSL if not already # if ($_SERVER['SERVER_PORT'] != 443) { # $this->_redirect($this->_params->url->connectLogin); # } $this->_helper->layout->setLayout('login'); $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('hl_connect')); if ($auth->hasIdentity()) { // User is already logged in so just push them into the system $this->_redirect('/'); } // Intantiate form definition $pageForm = new Connect_Form_Login(); // If we have a refno, try to prepopulate the form with ASN if (preg_match('/^([0-9]+\\.[0-9]+)$/', $this->getRequest()->getParam('refno'), $matches)) { if (isset($matches[1])) { $refno = $matches[1]; $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); $agentID = $enquiryDatasource->getReferenceAgentID($this->getRequest()->getParam('refno')); if ($agentID) { $pageForm->agentschemeno->setValue($agentID); } } } $request = $this->getRequest(); if ($request->isPost()) { if ($this->_helper->auth->attemptLogin($pageForm)) { $this->_redirect($this->getRequest()->getRequestUri()); } else { $this->view->loginErrorMessage = "Invalid user or password"; } } $params = Zend_Registry::get('params'); $this->view->pageTitle = 'Log In'; $this->view->homePage = $params->homelet->get('domain'); $this->view->form = $pageForm; }
/** * Retrieves the specified reference subject. * * @param string $referenceSubjectId * The unique reference subject identifier. * * @param string $enquiryId * The unique external Enquiry identifier. * * @return mixed * The reference subject details encapsulated in a Model_Referencing_ReferenceSubject * object, or null if the reference subject cannot be found. */ public function getReferenceSubject($referenceSubjectId, $enquiryId) { if (empty($referenceSubjectId)) { return null; } $select = $this->select(); $select->where('ID = ?', $referenceSubjectId); $referenceSubjectRow = $this->fetchRow($select); if (empty($referenceSubjectRow)) { $returnVal = null; } else { $referenceSubject = new Model_Referencing_ReferenceSubject(); $referenceSubject->referenceId = $referenceSubjectRow->ID; //Load up the bank account details. $bankAccount = new Model_Referencing_BankAccount(); $bankAccount->referenceId = $referenceSubjectRow->ID; $bankAccount->accountNumber = $referenceSubjectRow->accountNo; $bankAccount->sortCode = $referenceSubjectRow->sortcodeNo; switch ($referenceSubjectRow->bankValidationCheckStatus) { case 'N/A': case 'No': case '': $bankAccount->isValidated = false; break; default: $bankAccount->isValidated = true; } $referenceSubject->bankAccount = $bankAccount; //Load the name details. $name = new Model_Core_Name(); $name->title = $referenceSubjectRow->title; $name->firstName = $referenceSubjectRow->firstname; $name->middleName = $referenceSubjectRow->middlename; $name->lastName = $referenceSubjectRow->lastname; $name->maidenName = $referenceSubjectRow->maidenname; $referenceSubject->name = $name; $contactDetails = new Model_Core_ContactDetails(); $contactDetails->telephone1 = $referenceSubjectRow->tel; $contactDetails->telephone2 = $referenceSubjectRow->mobile; $contactDetails->email1 = $referenceSubjectRow->email; $referenceSubject->contactDetails = $contactDetails; if ($referenceSubjectRow->dob != '0000-00-00') { $referenceSubject->dob = new Zend_Date($referenceSubjectRow->dob, Zend_Date::ISO_8601); } $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); if ($enquiryDatasource->getLegacyReferenceSubjectType($enquiryId) == Model_Referencing_ReferenceSubjectTypes::TENANT) { $referenceSubject->type = Model_Referencing_ReferenceSubjectTypes::TENANT; } else { $referenceSubject->type = Model_Referencing_ReferenceSubjectTypes::GUARANTOR; } $residenceDatasource = new Datasource_ReferencingLegacy_Residences(); $referenceSubject->residences = $residenceDatasource->getByEnquiry($enquiryId); $occupationDatasource = new Datasource_ReferencingLegacy_Occupations(); $referenceSubject->occupations = $occupationDatasource->getAllByEnquiry($enquiryId); if (!empty($referenceSubjectRow->hasCCJs)) { if ($referenceSubjectRow->hasCCJs == 'Yes') { $referenceSubject->hasAdverseCredit = true; } else { $referenceSubject->hasAdverseCredit = false; } } if ($referenceSubjectRow->RentShare >= 0) { $referenceSubject->shareOfRent = new Zend_Currency(array('value' => $referenceSubjectRow->RentShare, 'precision' => 0)); } $returnVal = $referenceSubject; } return $returnVal; }
/** * Check this reference against an ASN to check for ownership * * @param int $ownerAgentId Agent ID of the agent we're checking for ownership * @param string $refno Reference number of the reference to check * @return boolean */ private function _isReferenceOwnedBy($refno, $ownerAgentId) { // Find the ASN of the reference $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); $agentID = $enquiryDatasource->getReferenceAgentID($refno); return $agentID == $ownerAgentId; }
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(); }
/** * Get product premiums for month term size, linked to reference and agent * * @param int $months Months to retrieve premium for, should be 6 or 12. * @param int $irn Enquiry internal ID number to link pricing deals to to get product premiums * @return float Premium */ public function getRenewalPremium($months, $irn) { return $this->_enquiryModel->getRenewalPremium($months, $irn); }
/** * Retrieves the residential referee for a specific residence. * * @param string $enquiryId * The unique external Enquiry identifier. * * @return mixed * Returns a Model_Referencing_ResidentialReferee object, or null if no * referee is found. */ public function getByEnquiry($enquiryId) { $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); return $this->getResidentialReferee($enquiryDatasource->getCurrentLandlordId($enquiryId)); }
/** * 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; }
/** * Get all references for the selected reference numbers * * @param array $referenceIds Reference numbers * @param string $refnoSearch Refno search restriction * @param array $orderby Array of order by columns * @return array List of references */ public function getAllReferences($referenceIds, $refnoSearch, $orderby) { $legacyEnquiry = new Datasource_ReferencingLegacy_Enquiry(); return $legacyEnquiry->getAllReferences($referenceIds, $refnoSearch, $orderby); }