/** * Creates a new, empty Residence and corresponding record in the datasource. * * @param integer $referenceId * The unique Reference identifier. This is used to link the new Residence * record to the Reference record. * * @param integer $chronology * Indicates the residential chronology. Must corresond to one of the consts * exposed by the Model_Referencing_ResidentialChronology class. * * @return Model_Referencing_Residence * Returns the newly created, empty Residence. */ public function insertPlaceholder($referenceId, $chronology) { $id = $this->insert(array('reference_id' => $referenceId, 'chronology_id' => $chronology)); $residence = new Model_Referencing_Residence(); $residence->id = $id; $residence->referenceId = $referenceId; $residence->chronology = $chronology; $addressManager = new Manager_Core_Address(); $residence->address = $addressManager->createAddress(); return $residence; }
/** * Saves the form data to the datastore. * * @return void */ public function saveData() { $session = new Zend_Session_Namespace('referencing_global'); $data = $this->getValues(); // Create a new Enquiry, or load the existing one. $referenceManager = new Manager_Referencing_Reference(); if (empty($session->referenceId)) { $reference = $referenceManager->createReference(); $session->referenceId = $reference->internalId; } else { $reference = $referenceManager->getReference($session->referenceId); } // Set the customer map if (empty($reference->customer)) { $reference->customer = new Model_Referencing_CustomerMap(); } $reference->customer->customerType = Model_Referencing_CustomerTypes::LANDLORD; $reference->customer->customerId = $session->customerId; // Format the property details $postcodeManager = new Manager_Core_Postcode(); $propertyAddress = $postcodeManager->getPropertyByID($data['subform_propertyaddress']['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['subform_propertyaddress']['ins_property_postcode']; // Store the property details into the PropertyLease. if (empty($reference->propertyLease)) { $propertyLeaseManager = new Manager_Referencing_PropertyLease(); $reference->propertyLease = $propertyLeaseManager->insertPlaceholder($session->referenceId); } if (empty($reference->propertyLease->address)) { $addressManager = new Manager_Core_Address(); $reference->propertyLease->address = $addressManager->createAddress(); } $reference->propertyLease->address->addressLine1 = $addressLine1; $reference->propertyLease->address->addressLine2 = $addressLine2; $reference->propertyLease->address->town = $town; $reference->propertyLease->address->postCode = $postCode; // Store the rental price index details, if provided. $this->_savePropertyAspects(); // Set the remainder of the property lease details. $reference->propertyLease->rentPerMonth = new Zend_Currency(array('value' => $data['subform_propertymisc']['total_rent'], 'precision' => 0)); $reference->propertyLease->tenancyStartDate = new Zend_Date($data['subform_propertymisc']['tenancy_start_date'], Zend_Date::DATES); $reference->propertyLease->tenancyTerm = $data['subform_propertymisc']['tenancy_term']; $reference->propertyLease->noOfTenants = $data['subform_propertymisc']['no_of_tenants']; $referenceManager->updateReference($reference); }
/** * Saves the form data to the datastore. * * @return void */ public function saveData() { $session = new Zend_Session_Namespace('referencing_global'); $data = $this->getValues(); //Retrieve the main reference details. $referenceManager = new Manager_Referencing_Reference(); $reference = $referenceManager->getReference($session->referenceId); //Create a new PLL record if not already done so. if (empty($reference->propertyLease->prospectiveLandlord)) { $prospectiveLandlordManager = new Manager_Referencing_ProspectiveLandlord(); $reference->propertyLease->prospectiveLandlord = $prospectiveLandlordManager->insertPlaceholder($session->referenceId); } //Record the PLL's name if (empty($reference->propertyLease->prospectiveLandlord->name)) { $nameManager = new Manager_Core_Name(); $reference->propertyLease->prospectiveLandlord->name = $nameManager->createName(); } $reference->propertyLease->prospectiveLandlord->name->title = $data['personal_title']; $reference->propertyLease->prospectiveLandlord->name->firstName = $data['first_name']; $reference->propertyLease->prospectiveLandlord->name->lastName = $data['last_name']; //Record the PLL's contact details if (empty($reference->propertyLease->prospectiveLandlord->contactDetails)) { $contactDetailsManager = new Manager_Core_ContactDetails(); $reference->propertyLease->prospectiveLandlord->contactDetails = $contactDetailsManager->createContactDetails(); } $reference->propertyLease->prospectiveLandlord->contactDetails->telephone1 = $data['telephone_day']; $reference->propertyLease->prospectiveLandlord->contactDetails->telephone2 = $data['telephone_evening']; $reference->propertyLease->prospectiveLandlord->contactDetails->fax1 = $data['fax_number']; $reference->propertyLease->prospectiveLandlord->contactDetails->email1 = $data['email']; //Record the PLL's address. $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($reference->propertyLease->prospectiveLandlord->address)) { $addressManager = new Manager_Core_Address(); $reference->propertyLease->prospectiveLandlord->address = $addressManager->createAddress(); } $reference->propertyLease->prospectiveLandlord->address->addressLine1 = $addressLine1; $reference->propertyLease->prospectiveLandlord->address->addressLine2 = $addressLine2; $reference->propertyLease->prospectiveLandlord->address->town = $town; $reference->propertyLease->prospectiveLandlord->address->postCode = $postCode; //And update... both the reference and the PLL customer details, which are held in the //legacy datasources. $referenceManager->updateReference($reference); //Next, update the customer record if the user is a PLL. If the user is a reference subject, //then we do not want to overwrite the PLL (customer) details with the data they have //entered. if ($session->userType == Model_Referencing_ReferenceUserTypes::PRIVATE_LANDLORD) { //Retrieve the primary customer details - ugly I know. $session = new Zend_Session_Namespace('referencing_global'); $customerManager = new Manager_Referencing_Customer(); $customer = $customerManager->getCustomer($session->customerId); $customer->setTitle($data['personal_title']); $customer->setFirstName($data['first_name']); $customer->setLastName($data['last_name']); $customer->setTelephone(Model_Core_Customer::TELEPHONE1, $data['telephone_day']); $customer->setTelephone(Model_Core_Customer::TELEPHONE2, $data['telephone_evening']); $customer->setFax($data['fax_number']); $customer->setEmailAddress($data['email']); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE1, $addressLine1); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE2, $addressLine2); $customer->setAddressLine(Model_Core_Customer::ADDRESSLINE3, $town); $customer->setPostCode($postCode); $customerManager->updateCustomer($customer); } }
/** * Saves the form data to the datastore. * * @return void */ public function saveData() { $session = new Zend_Session_Namespace('referencing_global'); $data = $this->getValues(); $referenceManager = new Manager_Referencing_Reference(); $reference = $referenceManager->getReference($session->referenceId); //Locate the current residence object, so that we can attach the current landlords //reference to that. foreach ($reference->referenceSubject->residences as $residence) { if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) { $currentResidence = $residence; break; } } //Create a new residential referee if one does not exist already. if (empty($currentResidence->refereeDetails)) { $refereeManager = new Manager_Referencing_ResidenceReferee(); $currentResidence->refereeDetails = $refereeManager->createReferee($currentResidence->id); } //There is currently no way to capture the type of residential referee, so //assign a default for now. $currentResidence->refereeDetails->type = Model_Referencing_ResidenceRefereeTypes::PRIVATE_LANDLORD; //Record the referee's name. if (empty($currentResidence->refereeDetails->name)) { $nameManager = new Manager_Core_Name(); $currentResidence->refereeDetails->name = $nameManager->createName(); } $currentResidence->refereeDetails->name->title = $data['personal_title']; $currentResidence->refereeDetails->name->firstName = $data['first_name']; $currentResidence->refereeDetails->name->lastName = $data['last_name']; //Record the referee's contact details if (empty($currentResidence->refereeDetails->contactDetails)) { $contactDetailsManager = new Manager_Core_ContactDetails(); $currentResidence->refereeDetails->contactDetails = $contactDetailsManager->createContactDetails(); } $currentResidence->refereeDetails->contactDetails->telephone1 = $data['telephone_day']; $currentResidence->refereeDetails->contactDetails->telephone2 = $data['telephone_evening']; $currentResidence->refereeDetails->contactDetails->fax1 = $data['fax_number']; $currentResidence->refereeDetails->contactDetails->email1 = $data['email']; //Record the referee's address. $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($currentResidence->refereeDetails->address)) { $addressManager = new Manager_Core_Address(); $currentResidence->refereeDetails->address = $addressManager->createAddress(); } $currentResidence->refereeDetails->address->addressLine1 = $addressLine1; $currentResidence->refereeDetails->address->addressLine2 = $addressLine2; $currentResidence->refereeDetails->address->town = $town; $currentResidence->refereeDetails->address->postCode = $postCode; //Update progress. //And update... $referenceManager->updateReference($reference); }
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); }
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 occupation chronology from the current flow item, so that we can locate //the relevant occupation to update. switch ($session->currentFlowItem) { case Model_Referencing_DataEntry_FlowItems::CURRENT_OCCUPATION: $chronology = Model_Referencing_OccupationChronology::CURRENT; $classification = Model_Referencing_OccupationImportance::FIRST; break; case Model_Referencing_DataEntry_FlowItems::SECOND_OCCUPATION: $chronology = Model_Referencing_OccupationChronology::CURRENT; $classification = Model_Referencing_OccupationImportance::SECOND; break; case Model_Referencing_DataEntry_FlowItems::FUTURE_OCCUPATION: $chronology = Model_Referencing_OccupationChronology::FUTURE; $classification = Model_Referencing_OccupationImportance::FIRST; break; } //Attept to locate the relevant occupation. $occupationManager = new Manager_Referencing_Occupation(); $thisOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, $chronology, $classification); if (empty($thisOccupation)) { //The occupation to process does not exist, so create it first. $thisOccupation = $occupationManager->createNewOccupation($session->referenceId, $chronology, $classification); if (empty($reference->referenceSubject->occupations)) { $reference->referenceSubject->occupations = array(); } $reference->referenceSubject->occupations[] = $thisOccupation; } //Now update $thisOccupation with the occupational details provided by the ReferenceSubject. if (empty($thisOccupation->refereeDetails)) { $refereeManager = new Manager_Referencing_OccupationReferee(); $thisOccupation->refereeDetails = $refereeManager->createReferee($thisOccupation->id); } //Add general details. $thisOccupation->refereeDetails->organisationName = $data['company_name']; $thisOccupation->refereeDetails->position = $data['contact_position']; $thisOccupation->income = new Zend_Currency(array('value' => $data['income'], 'precision' => 0)); //Add the referee name if required. if (empty($thisOccupation->refereeDetails->name)) { $nameManager = new Manager_Core_Name(); $thisOccupation->refereeDetails->name = $nameManager->createName(); } $nameArray = preg_split("/\\s/", $data['contact_name']); if (count($nameArray) >= 2) { $thisOccupation->refereeDetails->name->firstName = array_shift($nameArray); $thisOccupation->refereeDetails->name->lastName = array_pop($nameArray); } else { if (count($nameArray) == 1) { $thisOccupation->refereeDetails->name->firstName = array_shift($nameArray); } } //Capture and process the referee address. $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($thisOccupation->refereeDetails->address)) { $addressManager = new Manager_Core_Address(); $thisOccupation->refereeDetails->address = $addressManager->createAddress(); } $thisOccupation->refereeDetails->address->addressLine1 = $addressLine1; $thisOccupation->refereeDetails->address->addressLine2 = $addressLine2; $thisOccupation->refereeDetails->address->town = $town; $thisOccupation->refereeDetails->address->postCode = $postCode; //Capture and process the referee contact details. if (empty($thisOccupation->refereeDetails->contactDetails)) { $contactDetailsManager = new Manager_Core_ContactDetails(); $thisOccupation->refereeDetails->contactDetails = $contactDetailsManager->createContactDetails(); } $thisOccupation->refereeDetails->contactDetails->telephone1 = $data['telephone_number']; $thisOccupation->refereeDetails->contactDetails->fax1 = $data['fax_number']; $thisOccupation->refereeDetails->contactDetails->email1 = $data['email']; if (!empty($data['tenancy_start_date'])) { $thisOccupation->startDate = new Zend_Date($data['tenancy_start_date'], Zend_Date::DATES); } if (!empty($data['is_permanent'])) { if ($data['is_permanent'] == 'Yes') { $thisOccupation->isPermanent = true; } else { $thisOccupation->isPermanent = false; } } //Now capture the optional details and insert into the occupation variables array. if (!empty($data['reference_number'])) { if (empty($thisOccupation->variables)) { $thisOccupation->variables = array(); } $thisOccupation->variables[Model_Referencing_OccupationVariables::PAYROLL_NUMBER] = $data['reference_number']; } if (!empty($data['position'])) { if (empty($thisOccupation->variables)) { $thisOccupation->variables = array(); } $thisOccupation->variables[Model_Referencing_OccupationVariables::POSITION] = $data['position']; } //Identify if a future occupation is applicable and required. if (!empty($data['will_change'])) { if ($data['will_change'] == 'Yes') { //If its going to change then we need to create a future employer record, if not already //done so. $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 { //Delete any future employer records. $futureOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::FUTURE, Model_Referencing_OccupationImportance::FIRST); if (!empty($futureOccupation)) { $occupationManager->deleteOccupation($futureOccupation); } } } //And update... $referenceManager->updateReference($reference); return $thisOccupation; }