Пример #1
0
 /**
  * Internal method, upserts progress records.
  *
  * @param Model_Referencing_Reference $reference
  */
 protected function _upsertProgress($reference, $upsertType)
 {
     //Capture the bank details progress.
     if (!empty($reference->referenceSubject->bankAccount)) {
         $accountNumber = $reference->referenceSubject->bankAccount->accountNumber;
         $sortCode = $reference->referenceSubject->bankAccount->sortCode;
         if (!empty($accountNumber) && !empty($sortCode)) {
             $bankDetails = 'Complete';
         } else {
             $bankDetails = 'Incomplete';
         }
     } else {
         $bankDetails = 'N/A';
     }
     //Set the start date
     $startDate = Zend_Date::now();
     $startDate = $startDate->toString(Zend_Date::ISO_8601);
     //If the product is a credit reference, provide minimal data.
     if (isset($reference->productSelection->product->variables[Model_Referencing_ProductVariables::CREDIT_REFERENCE])) {
         $fullReference = 'N/A';
         $landLetterSent = 'N/A';
         $employLetterSent = 'N/A';
         $employDetails = 'N/A';
         $landlordRef = 'N/A';
         $employerRef = 'N/A';
     } else {
         $fullReference = 'No';
         //Identify the value for 'landlettersent'. This will be 'N/A' if the reference subject
         //does not have a current landlord, and 'No' if they do.
         $residences = $reference->referenceSubject->residences;
         $residenceManager = new Manager_Referencing_Residence();
         $currentResidence = $residenceManager->findSpecificResidence($residences, Model_Referencing_ResidenceChronology::CURRENT);
         if (empty($currentResidence->refereeDetails)) {
             $landLetterSent = 'N/A';
         } else {
             $landLetterSent = 'No';
         }
         //Identify the value for 'employlettersent'. This will be 'N/A' if the applicant is unemployed
         //with no future occupation. Else will be 'No'.
         $occupations = $reference->referenceSubject->occupations;
         $occupationManager = new Manager_Referencing_Occupation();
         $currentOccupation = $occupationManager->findSpecificOccupation($occupations, Model_Referencing_OccupationChronology::CURRENT, Model_Referencing_OccupationImportance::FIRST);
         $employLetterSent = 'No';
         if ($currentOccupation->type == Model_Referencing_OccupationTypes::UNEMPLOYMENT) {
             if (count($occupations) == 1) {
                 $employLetterSent = 'N/A';
             }
         } else {
             if ($currentOccupation->type == Model_Referencing_OccupationTypes::STUDENT) {
                 $employLetterSent = 'N/A';
             }
         }
         //The 'employdetails' field is always set to 'Complete' for full references.
         $employDetails = 'Complete';
         //Determine the value for 'landlordref'. This should be set to 'N/A' if the reference
         //subject is a homeowner or living with relatives. Else it should be set to
         //'Incomplete'.
         $landlordRef = 'N/A';
         if ($currentResidence->status == Model_Referencing_ResidenceStatus::TENANT) {
             $landlordRef = 'Incomplete';
         }
         //Deterine the value for 'employerref'. This should be 'N/A' if the $employLetterSent
         //is 'N/A', else should be 'Incomplete'.
         $employerRef = 'Incomplete';
         if ($employLetterSent == 'N/A') {
             $employerRef = 'N/A';
         }
     }
     //Upsert the record.
     $data = array('propertydetails' => 'Complete', 'propertylandlorddetails' => 'Complete', 'tenantdetails' => 'Complete', 'tenantaddressdetails' => 'Complete', 'bankdetails' => $bankDetails, 'plandlorddetails' => 'Complete', 'llapproved' => 'Yes', 'termsagreed' => 'Yes', 'creditreference' => 'No', 'start_time' => $startDate, 'fullreference' => $fullReference, 'landlettersent' => $landLetterSent, 'employlettersent' => $employLetterSent, 'employdetails' => $employDetails, 'landlordref' => $landlordRef, 'employerref' => $employerRef);
     if ($upsertType == 'insert') {
         $data['refno'] = $reference->externalId;
         $this->insert($data);
     } else {
         $where = $this->quoteInto('refno = ? ', (string) $reference->externalId);
         $this->update($data, $where);
     }
 }
 public function saveData()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $data = $this->getValues();
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($session->referenceId);
     //Record the reference subject's personal details.
     if (empty($reference->referenceSubject->name)) {
         //If here then things are a bit weird - we should have the reference subject name
         //captured from an earlier form.
         $nameManager = new Manager_Core_Name();
         $reference->referenceSubject->name = $nameManager->createName();
     }
     $reference->referenceSubject->name->title = $data['personal_title'];
     $reference->referenceSubject->name->firstName = $data['first_name'];
     $reference->referenceSubject->name->middleName = $data['middle_name'];
     $reference->referenceSubject->name->lastName = $data['last_name'];
     $reference->referenceSubject->name->maidenName = $data['other_name'];
     //Reference subject contact details
     if (empty($reference->referenceSubject->contactDetails)) {
         $contactDetailsManager = new Manager_Core_ContactDetails();
         $reference->referenceSubject->contactDetails = $contactDetailsManager->createContactDetails();
     }
     $reference->referenceSubject->contactDetails->telephone1 = $data['telephone_day'];
     $reference->referenceSubject->contactDetails->telephone2 = $data['mobile_number'];
     $reference->referenceSubject->contactDetails->email1 = $data['email'];
     //Reference subject miscellaneous.
     $reference->referenceSubject->dob = new Zend_Date($data['tenancy_start_date'], Zend_Date::DATES);
     if ('Yes' == $data['has_adverse_credit']) {
         $reference->referenceSubject->hasAdverseCredit = true;
     } else {
         $reference->referenceSubject->hasAdverseCredit = false;
     }
     //Bank account details. Bank account details are optional.
     if (empty($data['bank_account_number']) || empty($data['bank_sortcode_number'])) {
         //No bank account details have been provided.
         if (!empty($reference->referenceSubject->bankAccount)) {
             //We have an existing bank account details record - delete this to reflect the
             //user input.
             $bankAccountManager = new Manager_Referencing_BankAccount();
             $bankAccountManager->deleteBankAccount($reference->referenceSubject->bankAccount);
         }
     } else {
         if (empty($reference->referenceSubject->bankAccount)) {
             $bankAccountManager = new Manager_Referencing_BankAccount();
             $reference->referenceSubject->bankAccount = $bankAccountManager->insertPlaceholder($session->referenceId);
         }
         $reference->referenceSubject->bankAccount->accountNumber = $data['bank_account_number'];
         $reference->referenceSubject->bankAccount->sortCode = $data['bank_sortcode_number'];
         //Run the bank account details through the validators.
         $reference->referenceSubject->bankAccount->isValidated = false;
         $bankManager = new Manager_Core_Bank();
         if ($bankManager->isSortCodeValid($data['bank_sortcode_number'])) {
             if ($bankManager->isAccountNumberValid($data['bank_sortcode_number'], $data['bank_account_number'])) {
                 $reference->referenceSubject->bankAccount->isValidated = true;
             }
         }
     }
     //Create a current residence record, if not already done so. Ensure the current residence record
     //reflects the residential status provided by the user.
     if (empty($reference->referenceSubject->residences)) {
         $residenceManager = new Manager_Referencing_Residence();
         $residence = $residenceManager->insertPlaceholder($session->referenceId, Model_Referencing_ResidenceChronology::CURRENT);
         $residence->status = $data['residential_status'];
         $reference->referenceSubject->residences = array();
         $reference->referenceSubject->residences[] = $residence;
     } else {
         //Locate the current residence record, and set the residential status accordingly.
         foreach ($reference->referenceSubject->residences as $residence) {
             if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) {
                 $residence->status = $data['residential_status'];
                 break;
             }
         }
     }
     //Create or locate the current occupation record.
     $occupationManager = new Manager_Referencing_Occupation();
     if (empty($reference->referenceSubject->occupations)) {
         $isNew = true;
         $currentOccupation = $occupationManager->createNewOccupation($session->referenceId, Model_Referencing_OccupationChronology::CURRENT, Model_Referencing_OccupationImportance::FIRST);
     } else {
         $isNew = false;
         //Locate the current primary occupation record, and set the occupation type accordingly.
         $currentOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::CURRENT, Model_Referencing_OccupationImportance::FIRST);
     }
     //Update the current occupation record to reflect the user inputs.
     $currentOccupation->type = $data['occupational_type'];
     $currentOccupation->income = new Zend_Currency(array('value' => $data['total_annual_income'], 'precision' => 0));
     if ($data['occupation_will_change'] == 'No') {
         $currentOccupation->isPermanent = true;
     } else {
         $currentOccupation->isPermanent = false;
     }
     //Add the current occupation to the ReferenceSubject, if it is new.
     if ($isNew) {
         $reference->referenceSubject->occupations = array();
         $reference->referenceSubject->occupations[] = $currentOccupation;
     }
     //Identify if a future occupation record is required.
     if (isset($data['is_future_employment_secured'])) {
         if ('Yes' == $data['is_future_employment_secured']) {
             //See if a future occupation record exists already.
             $futureOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::FUTURE, Model_Referencing_OccupationImportance::FIRST);
             if (empty($futureOccupation)) {
                 $createFutureOccupation = true;
             } else {
                 $createFutureOccupation = false;
             }
             if ($createFutureOccupation) {
                 $futureOccupation = $occupationManager->createNewOccupation($session->referenceId, Model_Referencing_OccupationChronology::FUTURE, Model_Referencing_OccupationImportance::FIRST);
                 $futureOccupation->type = Model_Referencing_OccupationTypes::EMPLOYMENT;
                 $reference->referenceSubject->occupations[] = $futureOccupation;
             }
         } else {
             //No future occupation record is required at this time, so ensure that
             //any existing are deleted.
             $futureOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::FUTURE, Model_Referencing_OccupationImportance::FIRST);
             if (!empty($futureOccupation)) {
                 $occupationManager->deleteOccupation($futureOccupation);
             }
         }
     }
     //Write the updates to the datasources.
     $referenceManager->updateReference($reference);
 }
Пример #3
0
 /**
  * Returns a TAT object encapsulating details of the Enquiry.
  *
  * @param void
  * The unique Enquiry identifier (internal or external). May be integer or string.
  *
  * @return mixed
  * Returns a Model_Referencing_Tat object holds details of the reference,
  * or null if not found.
  */
 public function getTat()
 {
     $tat = new Model_Referencing_Tat();
     //Set the isInvitationSent attribute.
     $tatDatasource = new Datasource_Referencing_TatInvitation();
     $tat->isInvitationSent = $tatDatasource->getIsTatInvitationSent($this->_reference->externalId);
     //Set the referenceSubject attribute.
     $referenceSubject = $this->_reference->referenceSubject;
     $tat->referenceSubject = $referenceSubject;
     //Set the propertyLease attribute.
     $tat->propertyLease = $this->_reference->propertyLease;
     //Arrive at the Enquiry state by a cascade: Start by assuming the Enquiry state is complete.
     $tat->enquiryStatus = Model_Referencing_TatStates::REFERENCE_COMPLETE;
     //Next identify if the state should be changed to 'In Progress' based on the
     //current Enquiry conclusion
     switch ($this->_reference->status->state) {
         case Model_Referencing_ReferenceStates::INPROGRESS:
         case Model_Referencing_ReferenceStates::INCOMPLETE:
             $tat->enquiryStatus = Model_Referencing_TatStates::REFERENCE_INPROGRESS;
             break;
     }
     $progressItem = Manager_Referencing_Progress::findSpecificProgressItem($this->_reference->progress, Model_Referencing_ProgressItemVariables::FINISHED);
     //Finally, override the conclusion if the progress result is not complete.
     if ($progressItem->itemState != Model_Referencing_ProgressItemStates::COMPLETE) {
         //The progress object also has to indicate complete - this will allow us to detect
         //references that have been reopened.
         $tat->enquiryStatus = Model_Referencing_TatStates::REFERENCE_INPROGRESS;
     }
     //Set the occupation attributes.
     foreach ($referenceSubject->occupations as $occupation) {
         //Set the occupation reference status.
         if (empty($occupation->referencingDetails)) {
             $isReferencedString = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
         } else {
             if ($occupation->isComplete) {
                 $isReferencedString = Model_Referencing_TatStates::REFERENCE_ITEM_COMPLETE;
             } else {
                 $isReferencedString = Model_Referencing_TatStates::REFERENCE_ITEM_INPROGRESS;
             }
         }
         //Now identify which occupation we are dealing with.
         if ($occupation->chronology == Model_Referencing_OccupationChronology::FUTURE) {
             $tat->futureOccupationReferenceStatus = $isReferencedString;
         } else {
             if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) {
                 if ($occupation->importance == Model_Referencing_OccupationImportance::FIRST) {
                     $tat->currentOccupationReferenceStatus = $isReferencedString;
                 } else {
                     $tat->secondOccupationReferenceStatus = $isReferencedString;
                 }
             }
         }
     }
     //Some of the occupation attributes may not be applicable. Set them to N/A as appropriate.
     if (empty($tat->currentOccupationReferenceStatus)) {
         $tat->currentOccupationReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
     }
     if (empty($tat->secondOccupationReferenceStatus)) {
         $tat->secondOccupationReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
     }
     if (empty($tat->futureOccupationReferenceStatus)) {
         $tat->futureOccupationReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
     }
     //Set the landlord attribute.
     $residenceManager = new Manager_Referencing_Residence();
     $currentResidence = $residenceManager->findSpecificResidence($this->_reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::CURRENT);
     if ($currentResidence->status != Model_Referencing_ResidenceStatus::TENANT) {
         $tat->currentResidentialReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_NOTAPPLICABLE;
     } else {
         if (empty($currentResidence->referencingDetails)) {
             $tat->currentResidentialReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_INPROGRESS;
         } else {
             if ($currentResidence->referencingDetails->submissionType == null) {
                 $tat->currentResidentialReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_INPROGRESS;
             } else {
                 $tat->currentResidentialReferenceStatus = Model_Referencing_TatStates::REFERENCE_ITEM_COMPLETE;
             }
         }
     }
     //Set the missing information attribute.
     /*
             $productName = $enquiry->productSelection->product->name;
             $flowManager = Manager_Referencing_DataEntry_Flow_FlowFactory::createFlowManager($productName);
     		$missingInformationManager = new Manager_Referencing_DataEntry_MissingInformation_Despatcher();
     		$missingInfoList = array();
     		do {
     
     	$missingInfoSubList = $missingInformationManager->getMissingInformation($enquiry->externalId, $flowManager->currentFlowItem);
     	if(!empty($missingInfoSubList)) {
     
     		foreach($missingInfoSubList as $subListItem) {
     
     			$missingInfoList[] = $subListItem;
     		}
     	}
     }
     while($flowManager->moveToNext($enquiryId));
     $tat->missingInformation = $missingInfoList;
     */
     //Use the legacy missing information manager until the new one is fully operational.
     $missingInformationManager = new Manager_Referencing_DataEntry_MissingInformation_Legacy();
     $tat->missingInformation = $missingInformationManager->getMissingInformation($this->_reference);
     //Set the tat notifications.
     $tatNotifications = new Datasource_Referencing_TatNotification();
     $tat->tatNotifications = $tatNotifications->getByEnquiry($this->_reference->externalId);
     return $tat;
 }
 /**
  * Displays the reference summary details page as a popup.
  */
 public function summaryDialogAction()
 {
     $this->_helper->getHelper('layout')->disableLayout();
     $session = new Zend_Session_Namespace('referencing_global');
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($session->referenceId);
     //Prepare the prospective landlord details.
     $prospectiveLandlord = $reference->propertyLease->prospectiveLandlord;
     $pllArray = array();
     $pllArray['name'] = $prospectiveLandlord->name->firstName . ' ' . $prospectiveLandlord->name->lastName;
     $pllArray['contactName'] = '';
     $pllArray['address'] = $prospectiveLandlord->address->addressLine1 . ' ' . $prospectiveLandlord->address->addressLine2 . ' ' . $prospectiveLandlord->address->town;
     $pllArray['postCode'] = $prospectiveLandlord->address->postCode;
     $pllArray['telephone'] = $prospectiveLandlord->contactDetails->telephone1;
     $pllArray['mobile'] = $prospectiveLandlord->contactDetails->telephone2;
     $pllArray['email'] = $prospectiveLandlord->contactDetails->email1;
     $this->view->prospectiveLandlord = $pllArray;
     //Prepare the property details.
     $propertyArray = array();
     $propertyArray['address'] = $reference->propertyLease->address->addressLine1 . ' ' . $reference->propertyLease->address->addressLine2 . ' ' . $reference->propertyLease->address->town;
     $propertyArray['postCode'] = $reference->propertyLease->address->postCode;
     $propertyArray['rent'] = $reference->propertyLease->rentPerMonth->getValue();
     $propertyArray['startDate'] = $reference->propertyLease->tenancyStartDate->toString();
     $propertyArray['duration'] = $reference->propertyLease->tenancyTerm;
     $propertyArray['noOfTenants'] = $reference->propertyLease->noOfTenants;
     $this->view->property = $propertyArray;
     //Prepare the reference subject details
     $referenceSubject = $reference->referenceSubject;
     $referenceSubjectArray = array();
     $referenceSubjectArray['name'] = $referenceSubject->name->firstName . ' ' . $referenceSubject->name->lastName;
     $referenceSubjectArray['maidenName'] = $referenceSubject->name->maidenName;
     $referenceSubjectArray['dob'] = $referenceSubject->dob->toString();
     if (!empty($referenceSubject->bankAccount)) {
         $referenceSubjectArray['bankAccountNumber'] = $referenceSubject->bankAccount->accountNumber;
         $referenceSubjectArray['bankSortCode'] = $referenceSubject->bankAccount->sortCode;
     } else {
         $referenceSubjectArray['bankAccountNumber'] = '';
         $referenceSubjectArray['bankSortCode'] = '';
     }
     $referenceSubjectArray['telephone'] = $referenceSubject->contactDetails->telephone1;
     $referenceSubjectArray['mobile'] = $referenceSubject->contactDetails->telephone2;
     $referenceSubjectArray['email'] = $referenceSubject->contactDetails->email1;
     $residenceManager = new Manager_Referencing_Residence();
     $residence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::CURRENT);
     $referenceSubjectArray['currentResidentialStatus'] = Model_Referencing_ResidenceStatus::toString($residence->status);
     $occupationManager = new Manager_Referencing_Occupation();
     $occupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::CURRENT, Model_Referencing_OccupationImportance::FIRST);
     //Convert the occupation type to an 'occupation status' for display purposes.
     switch ($occupation->type) {
         case Model_Referencing_OccupationTypes::EMPLOYMENT:
             $occupationStatus = 'Employed';
             break;
         case Model_Referencing_OccupationTypes::CONTRACT:
             $occupationStatus = 'On Contract';
             break;
         case Model_Referencing_OccupationTypes::SELFEMPLOYMENT:
             $occupationStatus = 'Self Employed';
             break;
         case Model_Referencing_OccupationTypes::INDEPENDENT:
             $occupationStatus = 'Financially Independent';
             break;
         case Model_Referencing_OccupationTypes::RETIREMENT:
             $occupationStatus = 'Retired';
             break;
         case Model_Referencing_OccupationTypes::STUDENT:
             $occupationStatus = 'Student';
             break;
         case Model_Referencing_OccupationTypes::UNEMPLOYMENT:
             $occupationStatus = 'Unemployed';
             break;
         case Model_Referencing_OccupationTypes::OTHER:
             $occupationStatus = 'Other';
             break;
         default:
             throw new Zend_Exception(get_class() . '::' . __FUNCTION__ . ': unknonwn type provided.');
     }
     $referenceSubjectArray['currentOccupationStatus'] = $occupationStatus;
     $referenceSubjectArray['isOccupationLikelyToChange'] = $occupation->isPermanent ? 'No' : 'Yes';
     //Calculate the total income.
     $totalIncome = new Zend_Currency(array('value' => 0, 'precision' => 0));
     foreach ($reference->referenceSubject->occupations as $occupation) {
         $totalIncome->add($occupation->income);
     }
     $referenceSubjectArray['income'] = $totalIncome->getValue();
     $referenceSubjectArray['shareOfRent'] = $referenceSubject->shareOfRent->getValue();
     $this->view->referenceSubject = $referenceSubjectArray;
     //Prepare the current landlord details.
     $currentResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::CURRENT);
     $currentLandlordArray = array();
     if (!empty($currentResidence->refereeDetails)) {
         $currentLandlordArray['name'] = $currentResidence->refereeDetails->name->firstName . ' ' . $currentResidence->refereeDetails->name->lastName;
         $currentLandlordArray['address'] = $currentResidence->refereeDetails->address->addressLine1 . ' ' . $currentResidence->refereeDetails->address->addressLine2 . ' ' . $currentResidence->refereeDetails->address->town;
         $currentLandlordArray['postCode'] = $currentResidence->refereeDetails->address->postCode;
         $currentLandlordArray['telephoneDay'] = $currentResidence->refereeDetails->contactDetails->telephone1;
         $currentLandlordArray['telephoneEvening'] = $currentResidence->refereeDetails->contactDetails->telephone2;
         $currentLandlordArray['fax'] = $currentResidence->refereeDetails->contactDetails->fax1;
         $currentLandlordArray['email'] = $currentResidence->refereeDetails->contactDetails->email1;
     } else {
         $currentLandlordArray['name'] = '';
         $currentLandlordArray['address'] = '';
         $currentLandlordArray['postCode'] = '';
         $currentLandlordArray['telephoneDay'] = '';
         $currentLandlordArray['telephoneEvening'] = '';
         $currentLandlordArray['fax'] = '';
         $currentLandlordArray['email'] = '';
     }
     $this->view->currentLandlord = $currentLandlordArray;
     //Prepare the occupation details.
     for ($i = 0; $i < 2; $i++) {
         switch ($i) {
             case 0:
                 $thisOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::CURRENT, Model_Referencing_OccupationImportance::FIRST);
                 break;
             case 1:
                 $thisOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::FUTURE, Model_Referencing_OccupationImportance::FIRST);
                 break;
         }
         $thisOccupationArray = array();
         if (empty($thisOccupation)) {
             $thisOccupationArray['organisationName'] = '';
             $thisOccupationArray['contactName'] = '';
             $thisOccupationArray['contactPosition'] = '';
             $thisOccupationArray['oranisationAddress'] = '';
             $thisOccupationArray['postCode'] = '';
             $thisOccupationArray['telephone'] = '';
             $thisOccupationArray['fax'] = '';
             $thisOccupationArray['email'] = '';
             $thisOccupationArray['salary'] = '';
             $thisOccupationArray['positionHeld'] = '';
             $thisOccupationArray['payrollNumber'] = '';
             $thisOccupationArray['startDate'] = '';
             $thisOccupationArray['endDate'] = '';
             $thisOccupationArray['isPermanent'] = '';
         } else {
             if (!empty($thisOccupation->refereeDetails)) {
                 $thisOccupationArray['organisationName'] = $thisOccupation->refereeDetails->organisationName;
                 $thisOccupationArray['contactName'] = $thisOccupation->refereeDetails->name->firstName . ' ' . $thisOccupation->refereeDetails->name->lastName;
                 $thisOccupationArray['contactPosition'] = $thisOccupation->refereeDetails->position;
                 $thisOccupationArray['oranisationAddress'] = $thisOccupation->refereeDetails->address->addressLine1 . ' ' . $thisOccupation->refereeDetails->address->addressLine2 . ' ' . $thisOccupation->refereeDetails->address->town;
                 $thisOccupationArray['postCode'] = $thisOccupation->refereeDetails->address->postCode;
                 $thisOccupationArray['telephone'] = $thisOccupation->refereeDetails->contactDetails->telephone1;
                 $thisOccupationArray['fax'] = $thisOccupation->refereeDetails->contactDetails->fax1;
                 $thisOccupationArray['email'] = $thisOccupation->refereeDetails->contactDetails->email1;
             } else {
                 $thisOccupationArray['organisationName'] = '';
                 $thisOccupationArray['contactName'] = '';
                 $thisOccupationArray['contactPosition'] = '';
                 $thisOccupationArray['oranisationAddress'] = '';
                 $thisOccupationArray['postCode'] = '';
                 $thisOccupationArray['telephone'] = '';
                 $thisOccupationArray['fax'] = '';
                 $thisOccupationArray['email'] = '';
             }
             if (empty($thisOccupation->variables)) {
                 $thisOccupationArray['positionHeld'] = '';
                 $thisOccupationArray['payrollNumber'] = '';
             } else {
                 $thisOccupationArray['positionHeld'] = $thisOccupation->variables[Model_Referencing_OccupationVariables::POSITION];
                 $thisOccupationArray['payrollNumber'] = $thisOccupation->variables[Model_Referencing_OccupationVariables::PAYROLL_NUMBER];
             }
             $thisOccupationArray['salary'] = $thisOccupation->income->getValue();
             $thisOccupationArray['positionHeld'] = '';
             $thisOccupationArray['payrollNumber'] = '';
             $thisOccupationArray['startDate'] = empty($thisOccupation->startDate) ? '' : $thisOccupation->startDate->toString();
             $thisOccupationArray['endDate'] = '';
             $thisOccupationArray['isPermanent'] = $thisOccupation->isPermanent ? 'Yes' : 'No';
         }
         switch ($i) {
             case 0:
                 $this->view->currentOccupation = $thisOccupationArray;
                 break;
             case 1:
                 $this->view->futureOccupation = $thisOccupationArray;
                 break;
         }
     }
     //Prepare the residential details.
     for ($i = 0; $i < 3; $i++) {
         switch ($i) {
             case 0:
                 $thisResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::CURRENT);
                 break;
             case 1:
                 $thisResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::FIRST_PREVIOUS);
                 break;
             case 2:
                 $thisResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::SECOND_PREVIOUS);
                 break;
         }
         $thisResidenceArray = array();
         if (empty($thisResidence)) {
             $thisResidenceArray['address'] = '';
             $thisResidenceArray['postCode'] = '';
             $thisResidenceArray['duration'] = '';
         } else {
             if ($thisResidence->address->isOverseasAddress) {
                 $thisResidenceArray['address'] = 'Overseas';
                 $thisResidenceArray['postCode'] = 'Overseas';
             } else {
                 $thisResidenceArray['address'] = $thisResidence->address->addressLine1 . ' ' . $thisResidence->address->addressLine2 . ' ' . $thisResidence->address->town;
                 $thisResidenceArray['postCode'] = $thisResidence->address->postCode;
             }
             $thisResidenceArray['duration'] = $thisResidence->durationAtAddress;
         }
         switch ($i) {
             case 0:
                 $this->view->firstResidence = $thisResidenceArray;
                 break;
             case 1:
                 $this->view->secondResidence = $thisResidenceArray;
                 break;
             case 2:
                 $this->view->thirdResidence = $thisResidenceArray;
                 break;
         }
     }
 }
Пример #5
0
 public function saveData()
 {
     $session = new Zend_Session_Namespace('referencing_global');
     $data = $this->getValues();
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($session->referenceId);
     //Derive the residence chronology from the current flow item, so that we can locate
     //the relevant residence to update.
     switch ($session->currentFlowItem) {
         case Model_Referencing_DataEntry_FlowItems::FIRST_RESIDENCE:
             $chronology = Model_Referencing_ResidenceChronology::CURRENT;
             break;
         case Model_Referencing_DataEntry_FlowItems::SECOND_RESIDENCE:
             $chronology = Model_Referencing_ResidenceChronology::FIRST_PREVIOUS;
             break;
         case Model_Referencing_DataEntry_FlowItems::THIRD_RESIDENCE:
             $chronology = Model_Referencing_ResidenceChronology::SECOND_PREVIOUS;
             break;
     }
     //Attept to locate the relevant residence.
     $residenceManager = new Manager_Referencing_Residence();
     $thisResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, $chronology);
     if (empty($thisResidence)) {
         //The residence to process does not exist, so create it first.
         $thisResidence = $residenceManager->insertPlaceholder($session->referenceId, $chronology);
         if (empty($reference->referenceSubject->residences)) {
             $reference->referenceSubject->residences = array();
         }
         $reference->referenceSubject->residences[] = $thisResidence;
     }
     //Update thisResidence to reflect the user inputs.
     if (isset($data['is_foreign_address']) && 'Yes' == $data['is_foreign_address']) {
         // Needed by the HRT system to recognise foreign addresses
         $thisResidence->address->addressLine1 = 'Abroad';
         $thisResidence->address->town = 'Abroad';
         $thisResidence->address->postCode = '1001';
         $thisResidence->address->isOverseasAddress = true;
     } else {
         //Format the property details.
         $postcodeManager = new Manager_Core_Postcode();
         $propertyAddress = $postcodeManager->getPropertyByID($data['property_address'], false);
         $addressLine1 = ($propertyAddress['organisation'] != '' ? "{$propertyAddress['organisation']}, " : '') . ($propertyAddress['houseNumber'] != '' ? "{$propertyAddress['houseNumber']} " : '') . ($propertyAddress['buildingName'] != '' ? "{$propertyAddress['buildingName']}, " : '') . $propertyAddress['address2'];
         $addressLine2 = $propertyAddress['address4'];
         $town = $propertyAddress['address5'];
         $postCode = $data['property_postcode'];
         if (empty($thisResidence->address)) {
             $addressManager = new Manager_Core_Address();
             $thisResidence->address = $addressManager->createAddress();
         }
         $thisResidence->address->addressLine1 = $addressLine1;
         $thisResidence->address->addressLine2 = $addressLine2;
         $thisResidence->address->town = $town;
         $thisResidence->address->postCode = $postCode;
         $thisResidence->address->isOverseasAddress = false;
     }
     $thisResidence->durationAtAddress = $data['duration_at_address'];
     //months
     //Finally, identify if the ReferenceSubject should be classed as a foreign national,
     //which is when they have spent the 6 months or more abroad.
     if ($this->_isOverseas($reference)) {
         $reference->referenceSubject->isForeignNational = true;
     } else {
         $reference->referenceSubject->isForeignNational = false;
     }
     //Update the datasources.
     $referenceManager->updateReference($reference);
 }