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