function getAllCategoryPreferencesDT() { global $bdd, $_TABLES; if (!is_null($bdd) && !is_null($_TABLES)) { $content = '<thead>'; $content .= '<tr>'; $content .= '<th>Id</th>'; $content .= '<th>User</th>'; $content .= '<th>Category</th>'; $content .= '<th>Action</th>'; $content .= '</tr>'; $content .= '</thead>'; $content .= '<tbody>'; $objCategoryPreference = new CategoryPreference($bdd, $_TABLES); $category_preferences = $objCategoryPreference->getAllCategoryPreferences(); if ($category_preferences) { foreach ($category_preferences as $key => $category_preference) { $content .= '<tr category_preference_id=' . $category_preference->id . '>'; $content .= '<td>' . $category_preference->id . '</td>'; $content .= '<td><select class="select_dt select_dt_user_id">'; $objUser = new User($bdd, $_TABLES); $users_items = $objUser->getAllUsers(); if ($users_items) { foreach ($users_items as $key_u => $user_item) { $temp_content = ''; $temp_content .= '<option value="' . $user_item->id . '" '; if ($user_item->id == $category_preference->user_id) { $temp_content .= 'selected>'; } else { $temp_content .= '>'; } $temp_content .= $user_item->name . '</option>'; $content .= $temp_content; } } $content .= '</select></td>'; $content .= '<td><select class="select_dt select_dt_category_id">'; $objCategory = new Category($bdd, $_TABLES); $categories_items = $objCategory->getAllCategories(); if ($categories_items) { foreach ($categories_items as $key_u => $category_item) { $temp_content = ''; $temp_content .= '<option value="' . $category_item->id . '" '; if ($category_item->id == $category_preference->category_id) { $temp_content .= 'selected>'; } else { $temp_content .= '>'; } $temp_content .= $category_item->category . '</option>'; $content .= $temp_content; } } $content .= '</select></td>'; $content .= "<td><input type='button' class='edit edit_category_preference_dt' value='Save' />\n\t\t\t\t <input type='button' class='delete delete_category_preference_dt' value='Supprimer' /></td>"; $content .= '</tr>'; } } $content .= '</tbody>'; return $content; } else { error_log("BDD ERROR : " . json_encode($bdd)); error_log("TABLES ERROR : " . json_encode($_TABLES)); } }