fixed from error
This commit is contained in:
@@ -55,13 +55,13 @@ class Projectsmanagement extends Renderer {
|
||||
WHERE caption = "Fortlaufende Projekte"', $newName);
|
||||
mysqli_query($this->dbConnection, $query);
|
||||
$id = mysqli_insert_id($this->dbConnection);
|
||||
$query = 'SELECT id, short_title FROM project p ORDER BY short_title';
|
||||
$query = 'SELECT id, short_title, project_type_id FROM project p ORDER BY short_title';
|
||||
$dbResult = mysqli_query($this->dbConnection, $query);
|
||||
$list = [];
|
||||
while ($row = mysqli_fetch_assoc($dbResult)) {
|
||||
$list[] = ['id' => $row['id'], 'title' => $row['short_title'] ];
|
||||
$list[] = ['id' => $row['id'], 'title' => $row['short_title'], 'project_type_id' => $row['project_type_id'] ];
|
||||
}
|
||||
echo json_encode(['list' => $list, 'id' => $id]);
|
||||
echo json_encode(['list' => $list, 'id' => $id, 'types' => $this->getProjectTypes()]);
|
||||
}
|
||||
|
||||
protected function setDescription(): void {
|
||||
@@ -90,15 +90,10 @@ class Projectsmanagement extends Renderer {
|
||||
}
|
||||
|
||||
protected function generateContent(): void {
|
||||
$typesQuery = 'SELECT * FROM project_type ORDER BY id';
|
||||
$typesResult = mysqli_query($this->dbConnection, $typesQuery);
|
||||
$types = [];
|
||||
while ($row = mysqli_fetch_assoc($typesResult)) {
|
||||
$types[$row['id'] ] = $row['caption'];
|
||||
}
|
||||
$types = $this->getProjectTypes();
|
||||
$query = 'SELECT * FROM project ORDER BY short_title';
|
||||
$result = mysqli_query($this->dbConnection, $query);
|
||||
$overviewHtml = '<table><thead><tr><th>Projekt</th><th>Projekttyp</th><tr><thead><tbody>';
|
||||
$overviewHtml = '<table id="projectoverview"><thead><tr><th>Projekt</th><th>Projekttyp</th><tr><thead><tbody>';
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$overviewHtml .= '<tr><td>' . $row['short_title'] . '</td>';
|
||||
$overviewHtml .= '<td><select name="project_type" data="' . $row['id'] . '">';
|
||||
@@ -111,4 +106,14 @@ class Projectsmanagement extends Renderer {
|
||||
$overviewHtml .= '</tbody></table>';
|
||||
$this->content['projects'] = $overviewHtml;
|
||||
}
|
||||
|
||||
protected function getProjectTypes(): array {
|
||||
$typesQuery = 'SELECT * FROM project_type ORDER BY id';
|
||||
$typesResult = mysqli_query($this->dbConnection, $typesQuery);
|
||||
$types = [];
|
||||
while ($row = mysqli_fetch_assoc($typesResult)) {
|
||||
$types[$row['id'] ] = $row['caption'];
|
||||
}
|
||||
return $types;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ $(document).ready(function() {
|
||||
return;
|
||||
}
|
||||
$("#shorttitle > option:not(:first-child)").remove();
|
||||
$("#projectoverview > tbody > tr").remove();
|
||||
response.list.forEach(function(item) {
|
||||
let newItem = $("<option></option>");
|
||||
newItem.attr("id", item.id);
|
||||
@@ -26,7 +27,16 @@ $(document).ready(function() {
|
||||
if (item.id == response.id) {
|
||||
newItem.attr("selected", "selected");
|
||||
}
|
||||
$("#shorttitle").append(newItem);
|
||||
let newRow = $('<tr><td>' + item.title + '</td></tr>');
|
||||
let selectElement = $('<select name="project_type" data="' + item.id + '"></select>');
|
||||
for (let typeId in response.types) {
|
||||
if (response.types.hasOwnProperty(typeId)) {
|
||||
let option = $('<option value="' + typeId + '"' + (typeId == item.project_type_id ? ' selected' : '') + '>' + response.types[typeId] + '</option>');
|
||||
selectElement.append(option);
|
||||
}
|
||||
}
|
||||
newRow.append('<td>' + selectElement.prop('outerHTML') + '</td>');
|
||||
$("#projectoverview tbody").append(newRow);
|
||||
});
|
||||
}).fail(function(response) {
|
||||
alert(response);
|
||||
|
||||
Reference in New Issue
Block a user