/** * @list : danh sách nhóm người dùng * @selectvalue : giá trị 'selected' nếu parent_id trùng với id nhóm * @group_id : id nhóm cần sửa truyền vào * @parent_id : id nhóm cha * KQ: đưa ra danh sách nhóm dưới dạng selectbox */ public static function DropdownGroup($list, $selectvalue = null, $group_id = '', $parent_id = null) { $html = ''; foreach ($list as $row) { $selected = $row['id'] == $selectvalue ? 'selected' : ''; $disabled = $row['id'] == $group_id ? 'disabled' : ''; $prefix = str_repeat('|-- ', substr_count($row['parents'], '-') - 1); if ($row['parent_id'] == $parent_id) { $html .= '<option value="' . $row['id'] . ' " ' . $selected . $disabled . '> ' . $prefix . $row['title'] . '</option>'; $html .= Recursive::DropdownGroup($list, $selectvalue, $group_id, $row['id']); } } return $html; }