| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -217,6 +217,55 @@ class GroupPortalManager | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     * Get the subgroups ID from a group. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     * The default $levels value is 10 considering it as a extensive level of depth | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @param int $groupId The parent group ID | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @param int $levels The depth levels | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @return array The list of ID | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    public static function getGroupsByDepthLevel($groupId, $levels = 10) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $groups = array(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $groupId = intval($groupId); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $groupTable = Database::get_main_table(TABLE_MAIN_GROUP); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $groupRelGroupTable = Database :: get_main_table(TABLE_MAIN_GROUP_REL_GROUP); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $select = "SELECT "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $from = "FROM $groupTable g1 "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        for ($i = 1; $i <= $levels; $i++) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            $tableIndexNumber = $i; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            $tableIndexJoinNumber = $i - 1; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            $select .= "g$i.id as id_$i "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            $select .= ($i != $levels ? ", " : null); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            if ($i == 1) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $from .= "INNER JOIN $groupRelGroupTable gg0 ON g1.id = gg0.subgroup_id and gg0.group_id = $groupId "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $from .= "LEFT JOIN $groupRelGroupTable gg$tableIndexJoinNumber "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $from .= " ON g$tableIndexJoinNumber.id = gg$tableIndexJoinNumber.group_id "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $from .= "LEFT JOIN $groupTable g$tableIndexNumber "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $from .= " ON gg$tableIndexJoinNumber.subgroup_id = g$tableIndexNumber.id "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        $result = Database::query("$select $from"); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        while ($item = Database::fetch_assoc($result)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            foreach ($item as $groupId) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                if (!empty($groupId)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                    $groups[] = $groupId; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        return array_map('intval', $groups); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param int $root | 
					 | 
					 | 
					 | 
					     * @param int $root | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					     * @param int $level | 
					 | 
					 | 
					 | 
					     * @param int $level | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -234,7 +283,7 @@ class GroupPortalManager | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if ($i == $level) { | 
					 | 
					 | 
					 | 
					            if ($i == $level) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                $select_part .= "g$i.id as id_$i, g$i.name as name_$i "; | 
					 | 
					 | 
					 | 
					                $select_part .= "g$i.id as id_$i, g$i.name as name_$i "; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } else { | 
					 | 
					 | 
					 | 
					            } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                $select_part .="g$i.id as id_$i, g$i.name name_$i, "; | 
					 | 
					 | 
					 | 
					                $select_part .= "g$i.id as id_$i, g$i.name name_$i, "; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if ($i == 1) { | 
					 | 
					 | 
					 | 
					            if ($i == 1) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                $cond_part .= "FROM $t_group g1 JOIN $t_rel_group rg0 on g1.id = rg0.subgroup_id and rg0.group_id = $root "; | 
					 | 
					 | 
					 | 
					                $cond_part .= "FROM $t_group g1 JOIN $t_rel_group rg0 on g1.id = rg0.subgroup_id and rg0.group_id = $root "; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -245,24 +294,24 @@ class GroupPortalManager | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $sql = $select_part.' '.$cond_part; | 
					 | 
					 | 
					 | 
					        $sql = $select_part.' '.$cond_part; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $res = Database::query($sql); | 
					 | 
					 | 
					 | 
					        $res = Database::query($sql); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $toreturn = array(); | 
					 | 
					 | 
					 | 
					        $toReturn = array(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        while ($item = Database::fetch_assoc($res)) { | 
					 | 
					 | 
					 | 
					        while ($item = Database::fetch_assoc($res)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            foreach ($item as $key => $value) { | 
					 | 
					 | 
					 | 
					            foreach ($item as $key => $value) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if ($key == 'id_1') { | 
					 | 
					 | 
					 | 
					                if ($key == 'id_1') { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $toreturn[$value]['name'] = $item['name_1']; | 
					 | 
					 | 
					 | 
					                    $toReturn[$value]['name'] = $item['name_1']; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } else { | 
					 | 
					 | 
					 | 
					                } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $temp = explode('_', $key); | 
					 | 
					 | 
					 | 
					                    $temp = explode('_', $key); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $index_key = $temp[1]; | 
					 | 
					 | 
					 | 
					                    $indexKey = $temp[1]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $string_key = $temp[0]; | 
					 | 
					 | 
					 | 
					                    $stringKey = $temp[0]; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $previous_key = $string_key.'_'.$index_key - 1; | 
					 | 
					 | 
					 | 
					                    $previousKey = $stringKey.'_'.$indexKey - 1; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    if ($string_key == 'id' && isset($item[$key])) { | 
					 | 
					 | 
					 | 
					                    if ($stringKey == 'id' && isset($item[$key])) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        $toreturn[$item[$previous_key]]['hrms'][$index_key]['name'] = $item['name_'.$index_id]; | 
					 | 
					 | 
					 | 
					                        $toReturn[$item[$previousKey]]['hrms'][$indexKey]['name'] = $item['name_'.$indexKey]; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return $toreturn; | 
					 | 
					 | 
					 | 
					        return $toReturn; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -292,16 +341,16 @@ class GroupPortalManager | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $sql = $select_part.' '.$cond_part."WHERE rg0.subgroup_id='$group_id'"; | 
					 | 
					 | 
					 | 
					        $sql = $select_part.' '.$cond_part."WHERE rg0.subgroup_id='$group_id'"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $res = Database::query($sql); | 
					 | 
					 | 
					 | 
					        $res = Database::query($sql); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $temp_arr = Database::fetch_array($res, 'NUM'); | 
					 | 
					 | 
					 | 
					        $temp_arr = Database::fetch_array($res, 'NUM'); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        $toreturn = array(); | 
					 | 
					 | 
					 | 
					        $toReturn = array(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (is_array($temp_arr)) { | 
					 | 
					 | 
					 | 
					        if (is_array($temp_arr)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            foreach ($temp_arr as $elt) { | 
					 | 
					 | 
					 | 
					            foreach ($temp_arr as $elt) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (isset($elt)) { | 
					 | 
					 | 
					 | 
					                if (isset($elt)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $toreturn[] = $elt; | 
					 | 
					 | 
					 | 
					                    $toReturn[] = $elt; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return $toreturn; | 
					 | 
					 | 
					 | 
					        return $toReturn; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    /** | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |