Add Einrichtung and Fachbereich as permission/filter types (knowledgecenter + tasks)
- Create knowledgecenter_category_einricht, _fachbereich, knowledgecenter_post_einricht, knowledgecenter_post_fachbereich tables; extend task_target_rule with main_einricht_id and main_bereich_id columns - Middleware: load main_einricht_id/main_bereich_id from main_contact_department, expose $allowedEinrichts/$allowedFachbereiche globals (same pattern as existing 3 types) - Ajax: add update_category/post_einrichts/fachbereiche functions, extend update_category_links() and search filter query - Views: add einricht/fachbereich LEFT JOINs and WHERE filters in all 5 query sites (categories_posts_listform, category_posts_widget, post_announcement_listform, post_cardform userHasAccessForPost, Ajax search) - post_cardform_settings: add Einrichtungen/Fachbereiche tagify pickers with save/load - Tasks: add listEinrichts/listFachbereiche to repo+service, add UI selects in task_form, extend target-rule normalization and upsert builder, extend AssignmentResolverService scope loading and matchesAnyRule to include einricht/fachbereich matching Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -115,7 +115,7 @@ while ($row = mysqli_fetch_assoc($result)) {
|
||||
}
|
||||
$selectedPostRoles = [];
|
||||
if ($postId != 0) {
|
||||
$querySelected = "SELECT r.id, r.description
|
||||
$querySelected = "SELECT r.id, r.description
|
||||
FROM knowledgecenter_post_role AS pr
|
||||
JOIN main_role AS r ON pr.role_id = r.id
|
||||
WHERE pr.post_id = $postId";
|
||||
@@ -125,6 +125,44 @@ if ($postId != 0) {
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------- Einrichtungen für Post --------------------
|
||||
$postEinrichtsData = [];
|
||||
$query = "SELECT id, description FROM organigramm_einricht ORDER BY description ASC";
|
||||
$result = mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$postEinrichtsData[] = ['value' => $row['id'], 'name' => $row['description']];
|
||||
}
|
||||
$selectedPostEinrichts = [];
|
||||
if ($postId != 0) {
|
||||
$querySelected = "SELECT e.id, e.description
|
||||
FROM knowledgecenter_post_einricht AS pe
|
||||
JOIN organigramm_einricht AS e ON pe.einricht_id = e.id
|
||||
WHERE pe.post_id = $postId";
|
||||
$resultSelected = mysqli_query($GLOBALS['mysql_con'], $querySelected);
|
||||
while ($row = mysqli_fetch_assoc($resultSelected)) {
|
||||
$selectedPostEinrichts[] = ['value' => $row['id'], 'name' => $row['description']];
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------- Fachbereiche für Post --------------------
|
||||
$postFachbereicheData = [];
|
||||
$query = "SELECT id, description FROM organogramm_space ORDER BY description ASC";
|
||||
$result = mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$postFachbereicheData[] = ['value' => $row['id'], 'name' => $row['description']];
|
||||
}
|
||||
$selectedPostFachbereiche = [];
|
||||
if ($postId != 0) {
|
||||
$querySelected = "SELECT s.id, s.description
|
||||
FROM knowledgecenter_post_fachbereich AS pfb
|
||||
JOIN organogramm_space AS s ON pfb.fachbereich_id = s.id
|
||||
WHERE pfb.post_id = $postId";
|
||||
$resultSelected = mysqli_query($GLOBALS['mysql_con'], $querySelected);
|
||||
while ($row = mysqli_fetch_assoc($resultSelected)) {
|
||||
$selectedPostFachbereiche[] = ['value' => $row['id'], 'name' => $row['description']];
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------- Produkte für Post --------------------
|
||||
$productsData = [];
|
||||
$query = "SELECT p.id, pt.title
|
||||
@@ -221,6 +259,16 @@ if (!empty($post['text_color'])) {
|
||||
<input type="text" id="postRoleTags" name="postRoles" placeholder="<?=$translation->get("roles")?>…" />
|
||||
</div>
|
||||
|
||||
<h3>Einrichtungen</h3>
|
||||
<div class="settings_container">
|
||||
<input type="text" id="postEinrichtTags" name="postEinrichts" placeholder="Einrichtung hinzufügen…" />
|
||||
</div>
|
||||
|
||||
<h3>Fachbereiche</h3>
|
||||
<div class="settings_container">
|
||||
<input type="text" id="postFachbereichTags" name="postFachbereiche" placeholder="Fachbereich hinzufügen…" />
|
||||
</div>
|
||||
|
||||
<h3><?=$translation->get("products")?></h3>
|
||||
<div class="settings_container">
|
||||
<input type="text" id="postProductTags" name="postProducts" placeholder="<?=$translation->get("products")?>…" />
|
||||
@@ -262,10 +310,14 @@ if (!empty($post['text_color'])) {
|
||||
var postMandantsData = <?php echo json_encode($postMandantsData); ?>;
|
||||
var postDepartmentsData = <?php echo json_encode($postDepartmentsData); ?>;
|
||||
var postRolesData = <?php echo json_encode($postRolesData); ?>;
|
||||
var postEinrichtsData = <?php echo json_encode($postEinrichtsData); ?>;
|
||||
var postFachbereicheData = <?php echo json_encode($postFachbereicheData); ?>;
|
||||
var selectedCategories = <?php echo json_encode($selectedCategories); ?>;
|
||||
var selectedPostMandants = <?php echo json_encode($selectedPostMandants); ?>;
|
||||
var selectedPostDepartments = <?php echo json_encode($selectedPostDepartments); ?>;
|
||||
var selectedPostRoles = <?php echo json_encode($selectedPostRoles); ?>;
|
||||
var selectedPostEinrichts = <?php echo json_encode($selectedPostEinrichts); ?>;
|
||||
var selectedPostFachbereiche = <?php echo json_encode($selectedPostFachbereiche); ?>;
|
||||
var productsData = <?php echo json_encode($productsData); ?>;
|
||||
var selectedProducts = <?php echo json_encode($selectedProducts); ?>;
|
||||
|
||||
@@ -370,6 +422,42 @@ if (!empty($post['text_color'])) {
|
||||
tagifyPostRoles.addTags(selectedPostRoles);
|
||||
}
|
||||
|
||||
// Einrichtungen für Post
|
||||
var tagifyPostEinrichts = new Tagify(document.getElementById('postEinrichtTags'), {
|
||||
whitelist: postEinrichtsData,
|
||||
tagTextProp: 'name',
|
||||
enforceWhitelist: true,
|
||||
dropdown: { enabled: 0, maxItems: Infinity, searchKeys: ["name"] },
|
||||
templates: {
|
||||
dropdownItem: function (tagData) {
|
||||
return `<div ${this.getAttributes(tagData)} class="tagify__dropdown__item">
|
||||
<span>${tagData.name}</span>
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (selectedPostEinrichts.length) {
|
||||
tagifyPostEinrichts.addTags(selectedPostEinrichts);
|
||||
}
|
||||
|
||||
// Fachbereiche für Post
|
||||
var tagifyPostFachbereiche = new Tagify(document.getElementById('postFachbereichTags'), {
|
||||
whitelist: postFachbereicheData,
|
||||
tagTextProp: 'name',
|
||||
enforceWhitelist: true,
|
||||
dropdown: { enabled: 0, maxItems: Infinity, searchKeys: ["name"] },
|
||||
templates: {
|
||||
dropdownItem: function (tagData) {
|
||||
return `<div ${this.getAttributes(tagData)} class="tagify__dropdown__item">
|
||||
<span>${tagData.name}</span>
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (selectedPostFachbereiche.length) {
|
||||
tagifyPostFachbereiche.addTags(selectedPostFachbereiche);
|
||||
}
|
||||
|
||||
// Produkte für Post
|
||||
var tagifyPostProducts = new Tagify(document.getElementById('postProductTags'), {
|
||||
whitelist: productsData,
|
||||
@@ -400,6 +488,8 @@ if (!empty($post['text_color'])) {
|
||||
var selectedMandants = tagifyPostMandants.value.map(tag => tag.value);
|
||||
var selectedDepartments = tagifyPostDepartments.value.map(tag => tag.value);
|
||||
var selectedRoles = tagifyPostRoles.value.map(tag => tag.value);
|
||||
var selectedEinrichts = tagifyPostEinrichts.value.map(tag => tag.value);
|
||||
var selectedFachbereiche = tagifyPostFachbereiche.value.map(tag => tag.value);
|
||||
var selectedFormId = $("#postFormSelect").val();
|
||||
var postBackgroundColor = $("#postBackgroundColor").val();
|
||||
var postTextColor = $("#postTextColor").val();
|
||||
@@ -435,6 +525,19 @@ if (!empty($post['text_color'])) {
|
||||
post_id: postId,
|
||||
roles: JSON.stringify(selectedRoles)
|
||||
}, "json"),
|
||||
|
||||
$.post("/module/knowledgecenter_update/Ajax/Ajax.php", {
|
||||
action: "update_post_einrichts",
|
||||
post_id: postId,
|
||||
einrichts: JSON.stringify(selectedEinrichts)
|
||||
}, "json"),
|
||||
|
||||
$.post("/module/knowledgecenter_update/Ajax/Ajax.php", {
|
||||
action: "update_post_fachbereiche",
|
||||
post_id: postId,
|
||||
fachbereiche: JSON.stringify(selectedFachbereiche)
|
||||
}, "json"),
|
||||
|
||||
$.post("/module/knowledgecenter_update/Ajax/Ajax.php", {
|
||||
action: "update_post_products",
|
||||
post_id: postId,
|
||||
@@ -451,17 +554,19 @@ if (!empty($post['text_color'])) {
|
||||
background_color: postBackgroundColor,
|
||||
text_color: postTextColor
|
||||
}, "json")
|
||||
).done(function (categoriesResponse, mandantsResponse, formResponse, departmentsResponse, rolesResponse, productsResponse, pdfInlineResponse, postColorsResponse) {
|
||||
).done(function (categoriesResponse, mandantsResponse, formResponse, departmentsResponse, rolesResponse, einrichtsResponse, fachbereicheResponse, productsResponse, pdfInlineResponse, postColorsResponse) {
|
||||
var catSuccess = categoriesResponse[0].success;
|
||||
var mandantsSuccess = mandantsResponse[0].success;
|
||||
var formSuccess = formResponse[0].success;
|
||||
var departmentsSuccess = departmentsResponse[0].success;
|
||||
var rolesSuccess = rolesResponse[0].success;
|
||||
var einrichtsSuccess = einrichtsResponse[0].success;
|
||||
var fachbereicheSuccess = fachbereicheResponse[0].success;
|
||||
var productsSuccess = productsResponse[0].success;
|
||||
var pdfInlineSuccess = pdfInlineResponse[0].success;
|
||||
var postColorsSuccess = postColorsResponse[0].success;
|
||||
|
||||
if (catSuccess && mandantsSuccess && formSuccess && departmentsSuccess && rolesSuccess && productsSuccess && pdfInlineSuccess && postColorsSuccess) {
|
||||
if (catSuccess && mandantsSuccess && formSuccess && departmentsSuccess && rolesSuccess && einrichtsSuccess && fachbereicheSuccess && productsSuccess && pdfInlineSuccess && postColorsSuccess) {
|
||||
showMessage("Alle Daten erfolgreich gespeichert!", true);
|
||||
} else {
|
||||
var errorMsg = "Fehler beim Speichern:";
|
||||
@@ -470,6 +575,8 @@ if (!empty($post['text_color'])) {
|
||||
if (!formSuccess) errorMsg += " Formular";
|
||||
if (!departmentsSuccess) errorMsg += " Departments";
|
||||
if (!rolesSuccess) errorMsg += " Rollen";
|
||||
if (!einrichtsSuccess) errorMsg += " Einrichtungen";
|
||||
if (!fachbereicheSuccess) errorMsg += " Fachbereiche";
|
||||
if (!productsSuccess) errorMsg += " Produkte";
|
||||
if (!pdfInlineSuccess) errorMsg += " PDF Inline Vorschau";
|
||||
if (!postColorsSuccess) errorMsg += " Farben";
|
||||
|
||||
Reference in New Issue
Block a user