getAll($get_all_companies); $final_results = array(); foreach($results AS $result) $final_results[$result['id']] = $result; return $final_results; } public function get_company_locations($company_id) { global $database; // $database->debug = true; $company_locations = array(); $get_company_locations = " SELECT id, company_id, CONCAT(address,', ',suburb,', ',state,', ',post_code,', ',country) AS 'name' FROM companies_locations WHERE company_id = '$company_id' AND status = '1' "; $company_locations = $database->getAll($get_company_locations); $final_results = array(); if(count($company_locations) > 0) foreach($company_locations AS $result) $final_results[$result['id']] = $result; return $final_results; } public function get_location($location_id) { global $database; $get_company_location = " SELECT CONCAT(address,', ',suburb,', ',state,', ',post_code,', ',country) AS 'name' FROM companies_locations WHERE id = $location_id LIMIT 1 "; $location = $database->getOne($get_company_location); return $location; } public function get_all_companies_id() { global $database; $get_companies_id = " SELECT id FROM companies "; $companies_id = $database->getAll($get_companies_id); return $companies_id; } public function get_all_companies_name() { global $database; $get_companies_name = " SELECT company_name FROM companies "; $companies_name = $database->getAll($get_companies_name); return $companies_name; } public function get_company_name($company_id) { global $database; $get_name = " SELECT company_name FROM companies WHERE id = '$company_id' "; $company_name = $database->getOne($get_name); echo $get_name; return $company_name; } public function company_details($company_id) { global $database; $get_companies = " SELECT company_name, multi_location, primary_location_id FROM companies WHERE id = '$company_id' LIMIT 1 "; $results = $database->getRow($get_companies); $location_id = $results['primary_location_id']; $get_location = " SELECT CONCAT(address,', ',suburb,', ',state,', ',post_code,', ',country) AS 'address', business_phone AS 'phone', fax FROM companies_locations WHERE id = $location_id LIMIT 1 "; $locations = $database->getRow($get_location); $company['company_name']=$results['company_name']; if($results['multi_location']==1) $company['multi_location']="Yes"; else $company['multi_location']="No"; $company['address']=$locations['address']; $company['phone']=$locations['phone']; $company['fax']=$locations['fax']; return $company; } public function get_multi_location($company_id) { global $database; $get_multi = " SELECT multi_location FROM companies WHERE id = '$company_id' LIMIT 1 "; $multi_location = $database->getOne($get_multi); return $multi_location; } public function get_primary_location($company_id) { global $database; $get_primary = " SELECT primary_location_id FROM companies WHERE id = '$company_id' LIMIT 1 "; $primary_location = $database->getOne($get_primary); return $primary_location; } } ?>