/** * @static * This function returns an array of reportee IDs that are sales reps * * @param String user_id The id of the user to check * @param boolean included_deleted Boolean Value indicating whether or not to include deleted records (defaults to false) * @return array Array of rep reportee IDs */ public static function getReporteeReps($user_id, $include_deleted = false) { $returnArray = array(); $reportees = User::getReporteesWithLeafCount($user_id, $include_deleted); foreach ($reportees as $key => $value) { if ($value == 0) { $returnArray[] = $key; } } return $returnArray; }
/** * Recursive Method to Retrieve the full tree of reportees for your team. * * @param string $user_id User to check for reportees on * @return array */ protected function getReportingUsers($user_id) { $final_users = array(); $reporting_users = User::getReporteesWithLeafCount($user_id); foreach ($reporting_users as $user => $reportees) { $final_users[] = $user; // if the user comes back with zero (0) for the count, don't try as they don't have any reportees if ($reportees > 0) { $final_users = array_merge($final_users, $this->getReportingUsers($user)); } } return $final_users; }