/**
  * Retrieves the ResidentialReferee for a specific Residence.
  *
  * @param integer $residenceId
  * The unique Residence identifier.
  *
  * @return mixed
  * Returns a Model_Referencing_ResidentialReferee object, or null if no
  * referee is found.
  */
 public function getByResidenceId($residenceId)
 {
     if (empty($residenceId)) {
         return null;
     }
     $select = $this->select();
     $select->where('residence_id = ?', $residenceId);
     $refereeRow = $this->fetchRow($select);
     if (empty($refereeRow)) {
         $returnVal = null;
     } else {
         $residentialReferee = new Model_Referencing_ResidenceReferee();
         $residentialReferee->residenceId = $refereeRow->residence_id;
         $residentialReferee->type = $refereeRow->type_id;
         if (!empty($refereeRow->name_id)) {
             $namesDatasource = new Datasource_Core_Names();
             $residentialReferee->name = $namesDatasource->getById($refereeRow->name_id);
         }
         if (!empty($refereeRow->contact_id)) {
             $contactDatasource = new Datasource_Core_ContactDetails();
             $residentialReferee->contactDetails = $contactDatasource->getById($refereeRow->contact_id);
         }
         if (!empty($refereeRow->address_id)) {
             $addressDatasource = new Datasource_Core_Addresses();
             $residentialReferee->address = $addressDatasource->getById($refereeRow->address_id);
         }
         $returnVal = $residentialReferee;
     }
     return $returnVal;
 }
 /**
  * Retrieves the OccupationalReferee for a specific Occupation.
  *
  * @param integer $occupationId
  * The unique Occupation identifier.
  *
  * @return mixed
  * Returns a Model_Referencing_OccupationalReferee object, or null if no
  * referee is found.
  */
 public function getByOccupationId($occupationId)
 {
     if (empty($occupationId)) {
         return null;
     }
     $select = $this->select();
     $select->where('occupation_id = ?', $occupationId);
     $refereeRow = $this->fetchRow($select);
     if (empty($refereeRow)) {
         $returnVal = null;
     } else {
         $occupationalReferee = new Model_Referencing_OccupationReferee();
         $occupationalReferee->occupationId = $refereeRow->occupation_id;
         if (!empty($refereeRow->name_id)) {
             $namesDatasource = new Datasource_Core_Names();
             $occupationalReferee->name = $namesDatasource->getById($refereeRow->name_id);
         }
         if (!empty($refereeRow->contact_id)) {
             $contactDatasource = new Datasource_Core_ContactDetails();
             $occupationalReferee->contactDetails = $contactDatasource->getById($refereeRow->contact_id);
         }
         if (!empty($refereeRow->address_id)) {
             $addressDatasource = new Datasource_Core_Addresses();
             $occupationalReferee->address = $addressDatasource->getById($refereeRow->address_id);
         }
         $occupationalReferee->organisationName = $refereeRow->organisation_name;
         $occupationalReferee->position = $refereeRow->referee_position;
         $returnVal = $occupationalReferee;
     }
     return $returnVal;
 }
 /**
  * Retrieves the specified ReferenceSubject.
  *
  * @param integer $referenceId
  * The unique integer Reference identifier.
  *
  * @return mixed
  * The ReferenceSubject details encapsulated in a Model_Referencing_ReferenceSubject
  * object, or null if the reference subject cannot be found.
  */
 public function getByReferenceId($referenceId)
 {
     $select = $this->select();
     $select->where('reference_id = ?', $referenceId);
     $referenceSubjectRow = $this->fetchRow($select);
     if (empty($referenceSubjectRow)) {
         Application_Core_Logger::log(get_class() . '::' . __FUNCTION__ . ': Unable to find ReferenceSubject.');
         $returnVal = null;
     } else {
         $referenceSubject = new Model_Referencing_ReferenceSubject();
         $referenceSubject->referenceId = $referenceSubjectRow->reference_id;
         if (!empty($referenceSubjectRow->name_id)) {
             $namesDatasource = new Datasource_Core_Names();
             $referenceSubject->name = $namesDatasource->getById($referenceSubjectRow->name_id);
         }
         if (!empty($referenceSubjectRow->contact_id)) {
             $contactDatasource = new Datasource_Core_ContactDetails();
             $referenceSubject->contactDetails = $contactDatasource->getById($referenceSubjectRow->contact_id);
         }
         if (!empty($referenceSubjectRow->dob)) {
             if ($referenceSubjectRow->dob != '0000-00-00') {
                 $referenceSubject->dob = new Zend_Date($referenceSubjectRow->dob, Zend_Date::ISO_8601);
             }
         }
         if (!empty($referenceSubjectRow->type_id)) {
             $referenceSubject->type = $referenceSubjectRow->type_id;
         }
         if (empty($referenceSubjectRow->has_adverse_credit) || $referenceSubjectRow->has_adverse_credit == 0) {
             $referenceSubject->hasAdverseCredit = false;
         } else {
             $referenceSubject->hasAdverseCredit = true;
         }
         if (!empty($referenceSubjectRow->rent_share)) {
             $referenceSubject->shareOfRent = new Zend_Currency(array('value' => $referenceSubjectRow->rent_share, 'precision' => 0));
         }
         if (empty($referenceSubjectRow->is_foreign_national) || $referenceSubjectRow->is_foreign_national == 0) {
             $referenceSubject->isForeignNational = false;
         } else {
             $referenceSubject->isForeignNational = true;
         }
         $returnVal = $referenceSubject;
     }
     return $returnVal;
 }