/** * Get Employment Data for Client/Spouse * @param Client $id */ public function getEmploymentData($id) { $employment = array(); $employment['client'] = array(); $employment['spouse'] = array(); //Check to see if this client has a spouse $clientGateway = new Clients_Model_ClientGateway(); // retrieve spouse details $spouseId = $clientGateway->fetchClientSpouseId($id); $clientEmploymentGateway = new Clients_Model_ClientEmploymentGateway(); //Spouse confirmed if ($spouseId) { // retrieve spouse details $clientEmployment = $clientEmploymentGateway->fetchClientAndSpouseEmployment($id); if (count($clientEmployment) == '2') { if ($clientEmployment['0']['client_id'] == $id) { $employment['client'] = $clientEmployment['0']; $employment['spouse'] = $clientEmployment['1']; } else { $employment['client'] = $clientEmployment['1']; $employment['spouse'] = $clientEmployment['0']; } } elseif (count($clientEmployment) == '1') { if ($clientEmployment['0']['client_id'] == $id) { $employment['client'] = $clientEmployment['0']; } else { $employment['spouse'] = $clientEmployment['0']; } } } else { $clientEmployment = $clientEmploymentGateway->fetchClientEmployment($id); if (is_object($clientEmployment)) { $employment['client'] = $clientEmployment->toArray(); } else { $employment['client'] = $clientEmployment; } } return $employment; }