Compare commits

...

8 Commits

Author SHA1 Message Date
0a0196bd89 knowledgecenter: remove forum/product tabs and fix new-post errors
- post_cardform.php: remove Diskussion tab (forum module doesn't exist)
- post_cardform_contacts.php: guard get_contact_cards AJAX so it doesn't
  fire with post_id=0 on new posts (caused "Ungültige Beitrags-ID" error)
- post_cardform_settings.php: remove Produkte section entirely — the
  product/product_translation tables don't exist in this installation,
  which caused a fatal crash when opening the settings tab

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 11:30:05 +02:00
d1b9e89df3 knowledgecenter: tab layout for category form + fix post discussion crash
categories_cardform.php now uses a 3-tab layout (Allgemein / Berechtigungen /
Unterkategorien) instead of a content+sidebar layout. The permissions section
spans full width with a 6-column grid: Mandanten/Abteilungen/Rollen each in
2 cols, Einrichtungen/Fachbereiche each in 3 cols for more space.

post_cardform.php: the Diskussion tab crashed with a fatal require_once when
the forum module doesn't exist. Now guarded with file_exists() and shows a
placeholder message for new posts and missing modules.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 11:25:15 +02:00
4e8dd8745f knowledgecenter: add Einrichtung/Fachbereich to category permission form
categories_cardform.php now loads and displays tagify pickers for
Einrichtungen and Fachbereiche alongside the existing Mandant/Abteilung/Rolle
pickers. The saveTagifyData() function passes all 5 types to update_category_links.

Also ran DB migration: all permission data from the 5 old _link tables has been
copied into the new permission tables (mandant: 178, department: 1108,
role: 2159, einricht: 10023, fachbereich: 2722 rows).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 11:13:27 +02:00
eb3aa75615 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>
2026-06-22 11:03:53 +02:00
8fa061afac Merge 'weitere konstanten.php' into master and group/sort all constants
Added 293 new keys from 'weitere konstanten.php' (1429 → 1722 total).
Master file is now grouped into 45 thematic sections (Allgemein, Login,
Navigation, Intranet, Tasks, Events, Wiki, etc.), each alphabetically
sorted. 'weitere konstanten.php' is no longer needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 10:30:13 +02:00
1bd08a72be Fix text_constants merge: use proper PHP string regex
The previous merge used a greedy (.*?); regex that stopped at the first
semicolon — breaking on HTML entities like &ouml; inside string values.
Switched to a quoted-string-aware regex ("..." / '...') that correctly
captures full PHP string literals including embedded semicolons.
Key count: 1429 (root file was untracked and never loaded, not a loss).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 10:24:52 +02:00
e3b4dbe4ff Merge all text_constants into a single canonical file
Four separate text_constants.inc.php files (root, mysyde/common,
mysyde/common/classes, mysyde/admin) contained overlapping and
diverging constants. Merged all 1596 unique keys—zero value conflicts—
into mysyde/admin/text_constants.inc.php, which Translate.php already
loads. The three other files are now thin stubs that require_once the
admin file, so all existing include paths continue to work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 10:22:28 +02:00
e2837b3288 Adapt main_contact_link queries to use main_contact_department
The new tasks and knowledgecenter_update modules were built against a
main_contact_link table that does not exist in this system. All 7 active
query sites now target main_contact_department (same column names,
active_d → active).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 10:22:20 +02:00
20 changed files with 6105 additions and 8610 deletions

View File

@@ -133,6 +133,29 @@ if (isset($_POST["action"])) {
$result = update_post_roles($postId, $roleIds);
echo json_encode(is_bool($result) && $result ? ['success' => true] : ['error' => $result]);
exit;
case 'update_post_einrichts':
$postId = (int) ($_POST['post_id'] ?? 0);
$einrichtIds = json_decode($_POST['einrichts'], true) ?: [];
if ($postId <= 0) {
echo json_encode(['error' => 'Ungültige Post-ID']);
exit;
}
$result = update_post_einrichts($postId, $einrichtIds);
echo json_encode(is_bool($result) && $result ? ['success' => true] : ['error' => $result]);
exit;
case 'update_post_fachbereiche':
$postId = (int) ($_POST['post_id'] ?? 0);
$fachbereichIds = json_decode($_POST['fachbereiche'], true) ?: [];
if ($postId <= 0) {
echo json_encode(['error' => 'Ungültige Post-ID']);
exit;
}
$result = update_post_fachbereiche($postId, $fachbereichIds);
echo json_encode(is_bool($result) && $result ? ['success' => true] : ['error' => $result]);
exit;
case 'update_post_products':
$postId = (int) ($_POST['post_id'] ?? 0);
$productIds = json_decode($_POST['products'] ?? '[]', true) ?: [];
@@ -463,15 +486,56 @@ function update_category_roles($categoryId, $roleIds)
}
/**
* Kombinierte Funktion, die alle drei Link-Tabellen aktualisiert.
* Löscht alte Einrichtungs-Verknüpfungen und fügt neue ein.
*/
function update_category_einrichts($categoryId, $einrichtIds)
{
$deleteQuery = "DELETE FROM knowledgecenter_category_einricht WHERE category_id = $categoryId";
if (!mysqli_query($GLOBALS['mysql_con'], $deleteQuery)) {
return "Fehler beim Löschen der Einrichtungs-Verknüpfungen: " . mysqli_error($GLOBALS['mysql_con']);
}
foreach ($einrichtIds as $einrichtId) {
$einrichtId = (int) $einrichtId;
$insertQuery = "INSERT INTO knowledgecenter_category_einricht (category_id, einricht_id, created_at)
VALUES ($categoryId, $einrichtId, NOW())";
if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) {
return "Fehler beim Einfügen der Einrichtungs-ID $einrichtId: " . mysqli_error($GLOBALS['mysql_con']);
}
}
return true;
}
/**
* Löscht alte Fachbereich-Verknüpfungen und fügt neue ein.
*/
function update_category_fachbereiche($categoryId, $fachbereichIds)
{
$deleteQuery = "DELETE FROM knowledgecenter_category_fachbereich WHERE category_id = $categoryId";
if (!mysqli_query($GLOBALS['mysql_con'], $deleteQuery)) {
return "Fehler beim Löschen der Fachbereich-Verknüpfungen: " . mysqli_error($GLOBALS['mysql_con']);
}
foreach ($fachbereichIds as $fachbereichId) {
$fachbereichId = (int) $fachbereichId;
$insertQuery = "INSERT INTO knowledgecenter_category_fachbereich (category_id, fachbereich_id, created_at)
VALUES ($categoryId, $fachbereichId, NOW())";
if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) {
return "Fehler beim Einfügen der Fachbereich-ID $fachbereichId: " . mysqli_error($GLOBALS['mysql_con']);
}
}
return true;
}
/**
* Kombinierte Funktion, die alle fünf Link-Tabellen aktualisiert.
*/
function update_category_links()
{
$categoryId = (int) ($_POST['id'] ?? 0);
// Die Tagify-Daten werden als JSON-String gesendet
$mandantIds = json_decode($_POST['mandants'], true) ?: [];
$departmentIds = json_decode($_POST['departments'], true) ?: [];
$roleIds = json_decode($_POST['roles'], true) ?: [];
$einrichtIds = json_decode($_POST['einrichts'] ?? '[]', true) ?: [];
$fachbereichIds = json_decode($_POST['fachbereiche'] ?? '[]', true) ?: [];
$errors = [];
@@ -490,8 +554,17 @@ function update_category_links()
$errors[] = $result;
}
$result = update_category_einrichts($categoryId, $einrichtIds);
if ($result !== true) {
$errors[] = $result;
}
$result = update_category_fachbereiche($categoryId, $fachbereichIds);
if ($result !== true) {
$errors[] = $result;
}
if (empty($errors)) {
// Hier werden für jede Gruppe die vollständigen Datensätze (value und name) abgefragt
$savedMandants = [];
foreach ($mandantIds as $id) {
$id = (int) $id;
@@ -525,11 +598,35 @@ function update_category_links()
}
}
$savedEinrichts = [];
foreach ($einrichtIds as $id) {
$id = (int) $id;
$sql = "SELECT id, description FROM organigramm_einricht WHERE id = $id LIMIT 1";
$res = mysqli_query($GLOBALS['mysql_con'], $sql);
if ($res && mysqli_num_rows($res) > 0) {
$row = mysqli_fetch_assoc($res);
$savedEinrichts[] = ['value' => $row['id'], 'name' => $row['description']];
}
}
$savedFachbereiche = [];
foreach ($fachbereichIds as $id) {
$id = (int) $id;
$sql = "SELECT id, description FROM organogramm_space WHERE id = $id LIMIT 1";
$res = mysqli_query($GLOBALS['mysql_con'], $sql);
if ($res && mysqli_num_rows($res) > 0) {
$row = mysqli_fetch_assoc($res);
$savedFachbereiche[] = ['value' => $row['id'], 'name' => $row['description']];
}
}
echo json_encode([
'success' => true,
'mandants' => $savedMandants,
'departments' => $savedDepartments,
'roles' => $savedRoles
'roles' => $savedRoles,
'einrichts' => $savedEinrichts,
'fachbereiche' => $savedFachbereiche,
]);
} else {
echo json_encode(['error' => implode("; ", $errors)]);
@@ -1406,6 +1503,46 @@ function update_post_roles($postId, $roleIds)
return true;
}
/**
* Löscht alte Einrichtungs-Verknüpfungen für einen Beitrag und fügt neue ein.
*/
function update_post_einrichts($postId, $einrichtIds)
{
$deleteQuery = "DELETE FROM knowledgecenter_post_einricht WHERE post_id = $postId";
if (!mysqli_query($GLOBALS['mysql_con'], $deleteQuery)) {
return "Fehler beim Löschen der Post-Einrichtungs-Verknüpfungen: " . mysqli_error($GLOBALS['mysql_con']);
}
foreach ($einrichtIds as $einrichtId) {
$einrichtId = (int) $einrichtId;
$insertQuery = "INSERT INTO knowledgecenter_post_einricht (post_id, einricht_id, created_at)
VALUES ($postId, $einrichtId, NOW())";
if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) {
return "Fehler beim Einfügen der Einrichtungs-ID $einrichtId: " . mysqli_error($GLOBALS['mysql_con']);
}
}
return true;
}
/**
* Löscht alte Fachbereich-Verknüpfungen für einen Beitrag und fügt neue ein.
*/
function update_post_fachbereiche($postId, $fachbereichIds)
{
$deleteQuery = "DELETE FROM knowledgecenter_post_fachbereich WHERE post_id = $postId";
if (!mysqli_query($GLOBALS['mysql_con'], $deleteQuery)) {
return "Fehler beim Löschen der Post-Fachbereich-Verknüpfungen: " . mysqli_error($GLOBALS['mysql_con']);
}
foreach ($fachbereichIds as $fachbereichId) {
$fachbereichId = (int) $fachbereichId;
$insertQuery = "INSERT INTO knowledgecenter_post_fachbereich (post_id, fachbereich_id, created_at)
VALUES ($postId, $fachbereichId, NOW())";
if (!mysqli_query($GLOBALS['mysql_con'], $insertQuery)) {
return "Fehler beim Einfügen der Fachbereich-ID $fachbereichId: " . mysqli_error($GLOBALS['mysql_con']);
}
}
return true;
}
/**
* Löscht alte Produkt-Verknüpfungen und fügt neue in product_knowledgecenter_post_link ein.
*/
@@ -1662,17 +1799,19 @@ function search_posts()
$limitPlusOne = $limit + 1; // um zusätzlich eine Zeile zu laden, falls mehr Ergebnisse existieren
/**
* Zunächst: Holen der User-Daten (Mandanten, Abteilungen, Rollen)
* Zunächst: Holen der User-Daten (Mandanten, Abteilungen, Rollen, Einrichtungen, Fachbereiche)
*/
$currentUserId = $_POST["main_contact_id"] ?? 0;
$userMandants = [];
$userDepartments = [];
$userRoles = [];
$userEinrichts = [];
$userFachbereiche = [];
if ($currentUserId) {
$query = "SELECT main_mandant_id, main_department_id, main_role_id
FROM main_contact_link
WHERE main_contact_id = $currentUserId AND active_d = 1";
$query = "SELECT main_mandant_id, main_department_id, main_role_id, main_einricht_id, main_bereich_id
FROM main_contact_department
WHERE main_contact_id = $currentUserId AND active = 1";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
while ($row = mysqli_fetch_assoc($result)) {
// Filtere 0 aus 0 gilt als "keine Zuordnung"
@@ -1685,6 +1824,12 @@ function search_posts()
if ($row['main_role_id'] != 0 && !in_array($row['main_role_id'], $userRoles)) {
$userRoles[] = $row['main_role_id'];
}
if ($row['main_einricht_id'] != 0 && !in_array($row['main_einricht_id'], $userEinrichts)) {
$userEinrichts[] = $row['main_einricht_id'];
}
if ($row['main_bereich_id'] != 0 && !in_array($row['main_bereich_id'], $userFachbereiche)) {
$userFachbereiche[] = $row['main_bereich_id'];
}
}
}
@@ -1695,6 +1840,8 @@ function search_posts()
$allowedMandants = !empty($userMandants) ? implode(',', $userMandants) : 'NULL';
$allowedDepartments = !empty($userDepartments) ? implode(',', $userDepartments) : 'NULL';
$allowedRoles = !empty($userRoles) ? implode(',', $userRoles) : 'NULL';
$allowedEinrichts = !empty($userEinrichts) ? implode(',', $userEinrichts) : 'NULL';
$allowedFachbereiche = !empty($userFachbereiche) ? implode(',', $userFachbereiche) : 'NULL';
@@ -1757,11 +1904,17 @@ function search_posts()
ON kp.id = pm.post_id
LEFT JOIN knowledgecenter_post_role AS pr
ON kp.id = pr.post_id
LEFT JOIN knowledgecenter_post_einricht AS pe
ON kp.id = pe.post_id
LEFT JOIN knowledgecenter_post_fachbereich AS pfb
ON kp.id = pfb.post_id
WHERE 1=1
$searchCondition
AND ( pd.department_id IS NULL OR pd.department_id IN ($allowedDepartments) )
AND ( pm.mandant_id IS NULL OR pm.mandant_id IN ($allowedMandants) )
AND ( pr.role_id IS NULL OR pr.role_id IN ($allowedRoles) )
AND ( pe.einricht_id IS NULL OR pe.einricht_id IN ($allowedEinrichts) )
AND ( pfb.fachbereich_id IS NULL OR pfb.fachbereich_id IN ($allowedFachbereiche) )
ORDER BY kp.modified_at DESC
LIMIT $offset, $limitPlusOne
";

View File

@@ -516,7 +516,7 @@ if (isset($_GET[$c_form]) && !empty($_POST)) {
// Sende E-Mail an Firmen-Email
if ($sitepart_id == 1) {
$query = "SELECT * FROM main_contact_link WHERE main_contact_id = '" . $GLOBALS["main_contact"]['id'] . "' AND sorting = 1";
$query = "SELECT * FROM main_contact_department WHERE main_contact_id = '" . $GLOBALS["main_contact"]['id'] . "' AND sorting = 1";
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
$input_arbeitsunfaehigkeitsbescheinigung = $_POST['input_arbeitsunfaehigkeitsbescheinigung'];
@@ -655,7 +655,7 @@ if (isset($_GET[$c_form]) && !empty($_POST)) {
}
if ($GLOBAL["ws_bestell_result"] == true) {
$query = "SELECT main_contact.email FROM main_contact JOIN main_contact_link ON main_contact.id = main_contact_link.main_contact_id AND main_role_id = '3' AND main_mandant_id = " . $GLOBALS["main_contact"]["current_mandant_id"];
$query = "SELECT main_contact.email FROM main_contact JOIN main_contact_department ON main_contact.id = main_contact_department.main_contact_id AND main_role_id = '3' AND main_mandant_id = " . $GLOBALS["main_contact"]["current_mandant_id"];
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
while ($email = @mysqli_fetch_array($result)) {
$contactform_header["recipient_email"] .= "; " . $email["email"];
@@ -676,10 +676,10 @@ if (isset($_GET[$c_form]) && !empty($_POST)) {
$pid = (int) $pid;
$check = mysqli_query($GLOBALS['mysql_con'], "
SELECT 1 FROM main_contact_link
SELECT 1 FROM main_contact_department
WHERE main_contact_id = $pid
AND main_mandant_id = $sender_mandant_id
AND active_d = 1
AND active = 1
LIMIT 1
");

View File

@@ -1,17 +1,19 @@
<?php
/**
* Zunächst: Holen der User-Daten (Mandanten, Abteilungen, Rollen)
* Zunächst: Holen der User-Daten (Mandanten, Abteilungen, Rollen, Einrichtungen, Fachbereiche)
*/
$currentUserId = $GLOBALS["main_contact"]["id"] ?? 0;
$userMandants = [];
$userDepartments = [];
$userRoles = [];
$userEinrichts = [];
$userFachbereiche = [];
if ($currentUserId) {
$query = "SELECT main_mandant_id, main_department_id, main_role_id
FROM main_contact_link
WHERE main_contact_id = $currentUserId AND active_d = 1";
$query = "SELECT main_mandant_id, main_department_id, main_role_id, main_einricht_id, main_bereich_id
FROM main_contact_department
WHERE main_contact_id = $currentUserId AND active = 1";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
while ($row = mysqli_fetch_assoc($result)) {
// Filtere 0 aus 0 gilt als "keine Zuordnung"
@@ -24,6 +26,12 @@ if ($currentUserId) {
if ($row['main_role_id'] != 0 && !in_array($row['main_role_id'], $userRoles)) {
$userRoles[] = $row['main_role_id'];
}
if ($row['main_einricht_id'] != 0 && !in_array($row['main_einricht_id'], $userEinrichts)) {
$userEinrichts[] = $row['main_einricht_id'];
}
if ($row['main_bereich_id'] != 0 && !in_array($row['main_bereich_id'], $userFachbereiche)) {
$userFachbereiche[] = $row['main_bereich_id'];
}
}
}
@@ -34,11 +42,15 @@ if ($currentUserId) {
$allowedMandants = !empty($userMandants) ? implode(',', $userMandants) : 'NULL';
$allowedDepartments = !empty($userDepartments) ? implode(',', $userDepartments) : 'NULL';
$allowedRoles = !empty($userRoles) ? implode(',', $userRoles) : 'NULL';
$allowedEinrichts = !empty($userEinrichts) ? implode(',', $userEinrichts) : 'NULL';
$allowedFachbereiche = !empty($userFachbereiche) ? implode(',', $userFachbereiche) : 'NULL';
// Für den globalen Zugriff kannst Du auch die Variablen in $GLOBALS speichern:
$GLOBALS['allowedMandants'] = $allowedMandants;
$GLOBALS['allowedDepartments'] = $allowedDepartments;
$GLOBALS['allowedRoles'] = $allowedRoles;
$GLOBALS['allowedEinrichts'] = $allowedEinrichts;
$GLOBALS['allowedFachbereiche'] = $allowedFachbereiche;

View File

@@ -112,6 +112,52 @@ foreach ($roles as $role) {
}
}
// Einrichtungen abrufen
$einrichts = [];
$resultEinrichts = mysqli_query($GLOBALS['mysql_con'], "SELECT id, description FROM organigramm_einricht ORDER BY description ASC");
while ($row = mysqli_fetch_assoc($resultEinrichts)) {
$einrichts[] = $row;
}
// Fachbereiche abrufen
$fachbereiche = [];
$resultFachbereiche = mysqli_query($GLOBALS['mysql_con'], "SELECT id, description FROM organogramm_space ORDER BY description ASC");
while ($row = mysqli_fetch_assoc($resultFachbereiche)) {
$fachbereiche[] = $row;
}
// Gespeicherte Einrichtungen abrufen
$savedEinrichts = [];
$querySavedEinrichts = "SELECT einricht_id FROM knowledgecenter_category_einricht WHERE category_id = $categoryId";
$resultSavedEinrichts = mysqli_query($GLOBALS['mysql_con'], $querySavedEinrichts);
while ($row = mysqli_fetch_assoc($resultSavedEinrichts)) {
$savedEinrichts[] = $row['einricht_id'];
}
// Array mit Daten für Tagify (Einrichtungen)
$savedEinrichtsData = [];
foreach ($einrichts as $einricht) {
if (in_array($einricht['id'], $savedEinrichts)) {
$savedEinrichtsData[] = ['value' => $einricht['id'], 'name' => $einricht['description']];
}
}
// Gespeicherte Fachbereiche abrufen
$savedFachbereiche = [];
$querySavedFachbereiche = "SELECT fachbereich_id FROM knowledgecenter_category_fachbereich WHERE category_id = $categoryId";
$resultSavedFachbereiche = mysqli_query($GLOBALS['mysql_con'], $querySavedFachbereiche);
while ($row = mysqli_fetch_assoc($resultSavedFachbereiche)) {
$savedFachbereiche[] = $row['fachbereich_id'];
}
// Array mit Daten für Tagify (Fachbereiche)
$savedFachbereicheData = [];
foreach ($fachbereiche as $fachbereich) {
if (in_array($fachbereich['id'], $savedFachbereiche)) {
$savedFachbereicheData[] = ['value' => $fachbereich['id'], 'name' => $fachbereich['description']];
}
}
// Kategorie auslesen
$query = "SELECT c.* FROM knowledgecenter_categories_update AS c WHERE c.id = $categoryId LIMIT 1";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
@@ -185,241 +231,255 @@ while ($row = mysqli_fetch_assoc($resultParents)) {
}
$parentCount = count($parentCategories);
?>
<div class="cardform_containern">
<style>
.cf-layout{background:#fff;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,.1);overflow:hidden;}
.cf-topbar{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:2px solid #e5e7eb;}
.cf-topbar-back{font-size:18px;text-decoration:none;color:#374151;padding:4px 8px;border-radius:4px;}
.cf-topbar-back:hover{background:#f3f4f6;}
.cf-section-tabs{display:flex;gap:4px;flex:1;}
.cf-section-tab{padding:6px 18px;border:1px solid #d1d5db;border-radius:6px;background:#f9fafb;cursor:pointer;font-size:13px;color:#374151;font-weight:500;line-height:1.4;}
.cf-section-tab.active{background:#3B82F6;color:#fff;border-color:#3B82F6;}
.cf-topbar-actions{display:flex;gap:6px;align-items:center;margin-left:auto;}
.cf-tab-pane{display:none;padding:20px;}
.cf-tab-pane.active{display:block;}
.cf-general-layout{display:grid;grid-template-columns:1fr 260px;gap:24px;align-items:start;}
.cf-settings-col{border-left:1px solid #e5e7eb;padding-left:20px;display:flex;flex-direction:column;gap:12px;}
.cf-settings-col label{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:14px;color:#374151;cursor:pointer;}
.cf-settings-meta{font-size:12px;color:#6b7280;margin-top:8px;}
.cf-settings-meta ul{margin:4px 0;padding-left:16px;}
.cf-settings-meta a{color:#3B82F6;}
.cf-perm-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:20px;align-items:start;}
.cf-perm-sm{grid-column:span 2;}
.cf-perm-lg{grid-column:span 3;}
.cf-perm-block h4{font-size:13px;font-weight:600;margin:0 0 8px 0;color:#374151;}
</style>
<div class="cardform">
<!-- Überschrift und Message-Container -->
<div class="cf-layout">
<!-- Top bar: navigation, section tabs, save/delete -->
<div class="cf-topbar">
<a class="cf-topbar-back" href="?action=Categories&embedded=<?= $isEmbedded ?>">←</a>
<div class="cf-section-tabs">
<button class="cf-section-tab active" data-target="cf-tab-allgemein">Allgemein</button>
<?php if ($categoryId != 0): ?>
<button class="cf-section-tab" data-target="cf-tab-berechtigungen">Berechtigungen</button>
<button class="cf-section-tab" data-target="cf-tab-unterkategorien">Unterkategorien</button>
<?php endif; ?>
</div>
<div class="cf-topbar-actions">
<button id="message" style="opacity:0; pointer-events:none; min-width:1px;"></button>
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1): ?>
<button class="post-action-btn" id="saveAllTranslations" style="background:#14b814;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-check" viewBox="0 0 16 16">
<path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z"/>
</svg>
</button>
<button class="post-action-btn red" id="deleteCategory">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-trash3-fill" viewBox="0 0 16 16">
<path d="M11 1.5v1h3.5a.5.5 0 0 1 0 1h-.538l-.853 10.66A2 2 0 0 1 11.115 16h-6.23a2 2 0 0 1-1.994-1.84L2.038 3.5H1.5a.5.5 0 0 1 0-1H5v-1A1.5 1.5 0 0 1 6.5 0h3A1.5 1.5 0 0 1 11 1.5m-5 0v1h4v-1a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5M4.5 5.029l.5 8.5a.5.5 0 1 0 .998-.06l-.5-8.5a.5.5 0 1 0-.998.06m6.53-.528a.5.5 0 0 0-.528.47l-.5 8.5a.5.5 0 0 0 .998.058l.5-8.5a.5.5 0 0 0-.47-.528M8 4.5a.5.5 0 0 0-.5.5v8.5a.5.5 0 0 0 1 0V5a.5.5 0 0 0-.5-.5"/>
</svg>
</button>
<?php endif; ?>
</div>
</div>
<div class="card-body">
<div class="tabbar_with_button">
<a href="?action=Categories&embedded=<?= $isEmbedded ?>">←</a>
<!-- Tab: Allgemein -->
<div id="cf-tab-allgemein" class="cf-tab-pane active">
<div class="cf-general-layout">
<div>
<ul class="nav nav-tabs" id="languageTabs" role="tablist">
<?php foreach ($languages as $index => $lang): ?>
<li class="nav-item" role="presentation">
<button class="nav-link <?= ($index === 0) ? 'active' : '' ?>" id="tab-<?= $lang['code'] ?>"
data-bs-toggle="tab" data-bs-target="#lang-<?= $lang['code'] ?>" type="button" role="tab">
<?= htmlspecialchars(strtoupper($lang['code'])) ?> </button>
<?= htmlspecialchars(strtoupper($lang['code'])) ?>
</button>
</li>
<?php endforeach; ?>
</ul>
<div>
<button id="message" style="opacity:0;"></button>
<div class="tab-content-languages" id="languageTabsContent">
<?php foreach ($languages as $index => $lang):
$trans = $translations[$lang['code']];
?>
<div class="tab-pane fade <?= ($index === 0) ? 'show active' : '' ?>" id="lang-<?= $lang['code'] ?>"
role="tabpanel">
<form class="translationForm" data-lang="<?= $lang['id'] ?>" data-lang-code="<?= $lang['code'] ?>">
<div class="label title-<?php echo $lang['code']; ?>">
<label for="title-<?php echo $lang['code']; ?>">Titel
(<?php echo htmlspecialchars($lang['code']); ?>)</label>
</div>
<div class="input title-<?php echo $lang['code']; ?>">
<input required name="title-<?php echo $lang['code']; ?>"
id="title-<?php echo $lang['code']; ?>" class="text" type="text"
value="<?php echo htmlspecialchars($translations[$lang['code']]['title']); ?>">
</div>
<?php if ($categoryId != 0): ?>
<div class="single_image_group">
<img id="preview-<?= $lang['code'] ?>"
src="<?= $trans['image'] ? '/userdata/' . htmlspecialchars($trans['image']) : '/userdata/intranet/mandant/platzhalter_kategorie.png' ?>"
alt="Bildvorschau" style="max-width: 100px; min-height: 60px;
border-radius: 5px; <?= $trans['image'] ? '' : 'background-color:#f3f3f3;' ?>">
<input type="hidden" name="image-<?= $lang['code'] ?>" id="image-<?= $lang['code'] ?>"
value="<?= htmlspecialchars($trans['image']) ?>">
<div class="post-action-btn green openFileGallery" data-ajax-function="saveCategoryAjax"
data-target="image-<?= $lang['code'] ?>">+</div>
<div class="post-action-btn clearImage" data-target="image-<?= $lang['code'] ?>">✕</div>
</div>
<?php endif; ?>
</form>
</div>
<?php endforeach; ?>
</div>
</div>
<div class="tab-content-languages" id="languageTabsContent">
<?php foreach ($languages as $index => $lang):
$trans = $translations[$lang['code']];
<!-- Settings sidebar -->
<div class="cf-settings-col">
<label for="stateCheckbox">
<?= $translation->get("active_state") ?>
<input type="checkbox" id="stateCheckbox" name="state" value="1" <?= $state === 1 ? 'checked' : '' ?>>
</label>
<?php $is_navigation_item = $translations[$languages[0]['code']]['is_navigation_item'] ?? 0; ?>
<label for="isNavigationItem">
<?= $translation->get("create_navigation_menu") ?>
<input type="checkbox" id="isNavigationItem" name="is_navigation_item" value="1"
<?= $is_navigation_item == 1 ? 'checked' : '' ?>>
</label>
<label for="color_hex">
<?= $translation->get("color_hex") ?>
<input type="color" id="color_hex" name="color_hex" value="<?= $category['color_hex'] ?? '#3B82F6FF' ?>">
</label>
<?php $enable_post_color_pickers = isset($category['enable_post_color_pickers']) ? (int) $category['enable_post_color_pickers'] : 0; ?>
<label for="enablePostColorPickersCheckbox">
<?= $translation->get("enable_post_color_pickers") ?>
<input type="checkbox" id="enablePostColorPickersCheckbox" name="enable_post_color_pickers" value="1"
<?= $enable_post_color_pickers === 1 ? 'checked' : '' ?>>
</label>
<?php if (!empty($categoryId)): ?>
<?php
$formatter = new IntlDateFormatter(
'de_DE',
IntlDateFormatter::LONG,
IntlDateFormatter::SHORT
);
$timestamp = strtotime($category["modified_at"]);
?>
<div class="tab-pane fade <?= ($index === 0) ? 'show active' : '' ?>" id="lang-<?= $lang['code'] ?>"
role="tabpanel">
<form class="translationForm" data-lang="<?= $lang['id'] ?>" data-lang-code="<?= $lang['code'] ?>">
<div class="label title-<?php echo $lang['code']; ?>">
<label for="title-<?php echo $lang['code']; ?>">Titel
(<?php echo htmlspecialchars($lang['code']); ?>)</label>
</div>
<div class="input title-<?php echo $lang['code']; ?>">
<input required name="title-<?php echo $lang['code']; ?>"
id="title-<?php echo $lang['code']; ?>" class="text" type="text"
value="<?php echo htmlspecialchars($translations[$lang['code']]['title']); ?>">
</div>
<?php if ($categoryId != 0): ?>
<div class="single_image_group">
<img id="preview-<?= $lang['code'] ?>"
src="<?= $trans['image'] ? '/userdata/' . htmlspecialchars($trans['image']) : '/userdata/intranet/mandant/platzhalter_kategorie.png' ?>"
alt="Bildvorschau" style="max-width: 100px; min-height: 60px;
border-radius: 5px; <?= $trans['image'] ? '' : 'background-color:#f3f3f3;' ?>">
<input type="hidden" name="image-<?= $lang['code'] ?>" id="image-<?= $lang['code'] ?>"
value="<?= htmlspecialchars($trans['image']) ?>">
<div class="post-action-btn green openFileGallery" data-ajax-function="saveCategoryAjax"
data-target="image-<?= $lang['code'] ?>">
+</div>
<div class="post-action-btn clearImage" data-target="image-<?= $lang['code'] ?>">✕</div>
</div>
<?php endif; ?>
</form>
</div>
<?php endforeach; ?>
</div>
<?php if ($categoryId != 0): ?>
<!-- Container für Unterkategorien nur anzeigen, wenn Kategorie bereits existiert -->
<div class="category_sub_select">
<!-- Container für verknüpfte Unterkategorien -->
<div class="category_sub_select_container">
<h3><?= $translation->get("connected_subcategories") ?></h3>
<!-- Suchfeld für verknüpfte Kategorien -->
<input type="search" class="subcategory-search" id="search-selected"
placeholder="Suche in verknüpften Kategorien">
<ul id="selectedSubcategories" class="list-group connectedSortable">
<?php if (empty($subcategories)): ?>
<li class="list-group-item empty-hint">
<?= $translation->get("no_connected_subcategories") ?>
</li>
<?php else: ?>
<?php foreach ($subcategories as $sub): ?>
<li class="list-group-item" data-id="<?= $sub['id'] ?>">
<div>
<!-- Icon und Titel -->
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-grip-vertical" viewBox="0 0 16 16">
<path
d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0" />
</svg>
<?= htmlspecialchars($sub['title'] ?? "Fehlende Übersetzung ID {$sub['id']}") ?>
</div>
<button title="<?= $translation->get("delete") ?>" type="button"
class="unlinkSubcategory">✕</button>
<div class="cf-settings-meta">
<small><?= $translation->get("connected_subcategories") ?> (<?= $parentCount ?>)</small>
<?php if ($parentCount > 0): ?>
<ul class="connected_categories">
<?php foreach ($parentCategories as $parent): ?>
<li>
<a target="_blank" href="?action=Categories&detail=<?= $parent['id'] ?>">
<?= htmlspecialchars($parent['title'] ?: "Kategorie-ID " . $parent['id']) ?>
</a>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</ul>
<?php else: ?>
<p style="font-style: italic;"><?= $translation->get("not_connected_as_subcategory") ?></p>
<?php endif; ?>
<small><?= $translation->get("last_change_on") ?></small>
<p style="font-style: italic;"><?= $formatter->format($timestamp) ?> - <?= $category["modified_by"] ?></p>
</div>
<!-- Container für verfügbare Kategorien -->
<div class="category_sub_select_container">
<h3><?= $translation->get("available_categories") ?></h3>
<!-- Suchfeld für verfügbare Kategorien -->
<input type="search" class="subcategory-search" id="search-available"
placeholder="Suche in verfügbaren Kategorien">
<ul id="availableSubcategories" class="list-group connectedSortable">
<?php if (mysqli_num_rows($availableResult) == 0): ?>
<li class="list-group-item empty-hint">
<?= $translation->get("all_available_categories_used") ?>
</li>
<?php else: ?>
<?php while ($row = mysqli_fetch_assoc($availableResult)): ?>
<li class="list-group-item" data-id="<?= $row['id'] ?>">
<div>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-grip-vertical" viewBox="0 0 16 16">
<path
d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0" />
</svg>
<?= htmlspecialchars($row['title'] ?: "Fehlende Übersetzung ID {$row['id']}") ?>
</div>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
</div>
<?php endif; ?>
</div>
</div>
<div class="aside">
<div class="aside_section">
<div class="aside_toolbar">
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1) { ?>
<button class="post-action-btn" id="saveAllTranslations" style="background: #14b814;">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-check" viewBox="0 0 16 16">
<path
d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425z">
</path>
</svg>
</button>
<?php } ?>
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1) { ?>
<button class="post-action-btn red" id="deleteCategory">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-trash3-fill" viewBox="0 0 16 16">
<path
d="M11 1.5v1h3.5a.5.5 0 0 1 0 1h-.538l-.853 10.66A2 2 0 0 1 11.115 16h-6.23a2 2 0 0 1-1.994-1.84L2.038 3.5H1.5a.5.5 0 0 1 0-1H5v-1A1.5 1.5 0 0 1 6.5 0h3A1.5 1.5 0 0 1 11 1.5m-5 0v1h4v-1a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5M4.5 5.029l.5 8.5a.5.5 0 1 0 .998-.06l-.5-8.5a.5.5 0 1 0-.998.06m6.53-.528a.5.5 0 0 0-.528.47l-.5 8.5a.5.5 0 0 0 .998.058l.5-8.5a.5.5 0 0 0-.47-.528M8 4.5a.5.5 0 0 0-.5.5v8.5a.5.5 0 0 0 1 0V5a.5.5 0 0 0-.5-.5" />
</svg>
</button>
<?php } ?>
</div>
</div>
<div class="aside_section">
<label for="stateCheckbox">
<?= $translation->get("active_state") ?>
<input type="checkbox" id="stateCheckbox" name="state" value="1" <?= $state === 1 ? 'checked' : '' ?>>
</label>
</div>
<?php $is_navigation_item = $translations[$languages[0]['code']]['is_navigation_item'] ?? 0; ?>
<div class="aside_section">
<label for="createNavigationCheckbox">
<?= $translation->get("create_navigation_menu") ?>
<input type="checkbox" id="isNavigationItem" name="is_navigation_item" value="1"
<?= $is_navigation_item == 1 ? 'checked' : '' ?>>
</label>
</div>
<div class="aside_section">
<label for="color_hex">
<?= $translation->get("color_hex") ?>
<input type="color" id="color_hex" name="color_hex" value="<?= $category['color_hex'] ?? '#3B82F6FF' ?>">
</label>
</div>
<?php $enable_post_color_pickers = isset($category['enable_post_color_pickers']) ? (int) $category['enable_post_color_pickers'] : 0; ?>
<div class="aside_section">
<label for="enablePostColorPickersCheckbox">
<?= $translation->get("enable_post_color_pickers") ?>
<input type="checkbox" id="enablePostColorPickersCheckbox" name="enable_post_color_pickers" value="1"
<?= $enable_post_color_pickers === 1 ? 'checked' : '' ?>>
</label>
</div>
<?php if ($categoryId != 0): ?>
<div class="aside_section">
<h3><?= $translation->get("permissions_and_filters") ?></h3>
<label for="selected_mandants">
<?= $translation->get("mandants") ?>
<input type="text" id="selected_mandants" name="selected_mandants"
value='<?= htmlspecialchars(json_encode($savedMandantsData)); ?>'>
</label>
<label for="selected_departments">
<?= $translation->get("departments") ?>
<input type="text" id="selected_departments" name="selected_departments"
value='<?= htmlspecialchars(json_encode($savedDepartmentsData)); ?>'>
</label>
<label for="selected_roles">
<?= $translation->get("roles") ?>
<input type="text" id="selected_roles" name="selected_roles"
value='<?= htmlspecialchars(json_encode($savedRolesData)); ?>'>
</label>
</div>
<?php endif; ?>
<?php
if (!empty($categoryId)) {
$formatter = new IntlDateFormatter(
'de_DE',
IntlDateFormatter::LONG,
IntlDateFormatter::SHORT
);
$timestamp = strtotime($category["modified_at"]);
?>
<div class="aside_section">
<small><?= $translation->get("connected_subcategories") ?> (<?= $parentCount ?>)</small>
<?php if ($parentCount > 0): ?>
<ul class="connected_categories">
<?php foreach ($parentCategories as $parent): ?>
<li>
<a target="_blank" href="?action=Categories&detail=<?= $parent['id'] ?>">
<?= htmlspecialchars($parent['title'] ?: "Kategorie-ID " . $parent['id']) ?> ↗
</a>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p style="font-style: italic;"><?= $translation->get("not_connected_as_subcategory") ?></p>
<?php endif; ?>
</div>
<div class="aside_section">
<small><?= $translation->get("last_change_on") ?></small>
<p style="font-style: italic;">
<?= $formatter->format($timestamp) ?> - <?= $category["modified_by"] ?>
</p>
</div>
</div>
<?php if ($categoryId != 0): ?>
<!-- Tab: Berechtigungen & Filter -->
<div id="cf-tab-berechtigungen" class="cf-tab-pane">
<div class="cf-perm-grid">
<div class="cf-perm-block cf-perm-sm">
<h4><?= $translation->get("mandants") ?></h4>
<input type="text" id="selected_mandants" name="selected_mandants"
value='<?= htmlspecialchars(json_encode($savedMandantsData)); ?>'>
</div>
<div class="cf-perm-block cf-perm-sm">
<h4><?= $translation->get("departments") ?></h4>
<input type="text" id="selected_departments" name="selected_departments"
value='<?= htmlspecialchars(json_encode($savedDepartmentsData)); ?>'>
</div>
<div class="cf-perm-block cf-perm-sm">
<h4><?= $translation->get("roles") ?></h4>
<input type="text" id="selected_roles" name="selected_roles"
value='<?= htmlspecialchars(json_encode($savedRolesData)); ?>'>
</div>
<div class="cf-perm-block cf-perm-lg">
<h4>Einrichtungen</h4>
<input type="text" id="selected_einrichts" name="selected_einrichts"
value='<?= htmlspecialchars(json_encode($savedEinrichtsData)); ?>'>
</div>
<div class="cf-perm-block cf-perm-lg">
<h4>Fachbereiche</h4>
<input type="text" id="selected_fachbereiche" name="selected_fachbereiche"
value='<?= htmlspecialchars(json_encode($savedFachbereicheData)); ?>'>
</div>
</div>
</div>
<!-- Tab: Unterkategorien -->
<div id="cf-tab-unterkategorien" class="cf-tab-pane">
<div class="category_sub_select">
<div class="category_sub_select_container">
<h3><?= $translation->get("connected_subcategories") ?></h3>
<input type="search" class="subcategory-search" id="search-selected"
placeholder="Suche in verknüpften Kategorien">
<ul id="selectedSubcategories" class="list-group connectedSortable">
<?php if (empty($subcategories)): ?>
<li class="list-group-item empty-hint">
<?= $translation->get("no_connected_subcategories") ?>
</li>
<?php else: ?>
<?php foreach ($subcategories as $sub): ?>
<li class="list-group-item" data-id="<?= $sub['id'] ?>">
<div>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-grip-vertical" viewBox="0 0 16 16">
<path d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/>
</svg>
<?= htmlspecialchars($sub['title'] ?? "Fehlende Übersetzung ID {$sub['id']}") ?>
</div>
<button title="<?= $translation->get("delete") ?>" type="button"
class="unlinkSubcategory">✕</button>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</div>
<?php } ?>
<div class="category_sub_select_container">
<h3><?= $translation->get("available_categories") ?></h3>
<input type="search" class="subcategory-search" id="search-available"
placeholder="Suche in verfügbaren Kategorien">
<ul id="availableSubcategories" class="list-group connectedSortable">
<?php if (mysqli_num_rows($availableResult) == 0): ?>
<li class="list-group-item empty-hint">
<?= $translation->get("all_available_categories_used") ?>
</li>
<?php else: ?>
<?php while ($row = mysqli_fetch_assoc($availableResult)): ?>
<li class="list-group-item" data-id="<?= $row['id'] ?>">
<div>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="bi bi-grip-vertical" viewBox="0 0 16 16">
<path d="M7 2a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 5a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0M7 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-3 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0m3 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/>
</svg>
<?= htmlspecialchars($row['title'] ?: "Fehlende Übersetzung ID {$row['id']}") ?>
</div>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
</div>
</div>
<?php endif; ?>
</div>
<input type="hidden" id="category_id" value="<?= $categoryId ?>">
@@ -428,6 +488,15 @@ $parentCount = count($parentCategories);
<script>
$(function () {
// Section tab switching
$('.cf-section-tab').on('click', function () {
var target = $(this).data('target');
$('.cf-section-tab').removeClass('active');
$(this).addClass('active');
$('.cf-tab-pane').removeClass('active').hide();
$('#' + target).addClass('active').show();
});
// Funktion zum sequentiellen Speichern der Übersetzungen
window.saveCategoryAjax = function (callback) {
var forms = $(".translationForm");
@@ -486,11 +555,13 @@ $parentCount = count($parentCategories);
processNextForm();
}
// Funktion zum Speichern der Tagify-Daten (Mandanten, Departments, Rollen)
// Funktion zum Speichern der Tagify-Daten (Mandanten, Departments, Rollen, Einrichtungen, Fachbereiche)
function saveTagifyData() {
var mandants = JSON.stringify(tagifyMandants.value.map(function (t) { return t.value; }));
var departments = JSON.stringify(tagifyDepartments.value.map(function (t) { return t.value; }));
var roles = JSON.stringify(tagifyRoles.value.map(function (t) { return t.value; }));
var einrichts = JSON.stringify(tagifyEinrichts.value.map(function (t) { return t.value; }));
var fachbereiche = JSON.stringify(tagifyFachbereiche.value.map(function (t) { return t.value; }));
$.post("/module/knowledgecenter_update/Ajax/Ajax.php", {
action: "update_category_links",
@@ -498,6 +569,8 @@ $parentCount = count($parentCategories);
mandants: mandants,
departments: departments,
roles: roles,
einrichts: einrichts,
fachbereiche: fachbereiche,
modified_by: $("#modified_by").val()
}, function (response) {
if (!response.success) {
@@ -511,6 +584,12 @@ $parentCount = count($parentCategories);
tagifyRoles.removeAllTags();
tagifyRoles.addTags(response.roles);
tagifyEinrichts.removeAllTags();
tagifyEinrichts.addTags(response.einrichts);
tagifyFachbereiche.removeAllTags();
tagifyFachbereiche.addTags(response.fachbereiche);
}
}, "json");
}
@@ -667,6 +746,7 @@ $parentCount = count($parentCategories);
}
}
<?php if ($categoryId != 0): ?>
// Initialisierung der Tagify-Objekte
var mandantsData = <?php echo json_encode(array_map(function ($item) {
return ['value' => $item['id'], 'name' => $item['description']];
@@ -738,6 +818,54 @@ $parentCount = count($parentCategories);
}
});
var einrichtsData = <?php echo json_encode(array_map(function ($item) {
return ['value' => $item['id'], 'name' => $item['description']];
}, $einrichts)); ?>;
var fachbereicheData = <?php echo json_encode(array_map(function ($item) {
return ['value' => $item['id'], 'name' => $item['description']];
}, $fachbereiche)); ?>;
var tagifyEinrichts = new Tagify(document.getElementById('selected_einrichts'), {
whitelist: einrichtsData,
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>`;
}
}
});
var tagifyFachbereiche = new Tagify(document.getElementById('selected_fachbereiche'), {
whitelist: fachbereicheData,
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>`;
}
}
});
<?php endif; ?>
// Handler für das Löschen einer Kategorie
$("#deleteCategory").on("click", function () {
if (confirm("Möchten Sie diese Kategorie wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.")) {

View File

@@ -132,12 +132,18 @@ $redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=Lis
knowledgecenter_category_mandant AS cm ON c.id = cm.category_id
LEFT JOIN
knowledgecenter_category_role AS cr ON c.id = cr.category_id
LEFT JOIN
knowledgecenter_category_einricht AS ce ON c.id = ce.category_id
LEFT JOIN
knowledgecenter_category_fachbereich AS cf ON c.id = cf.category_id
WHERE
kcl.parent_category_id = $categoryId
AND c.state = 1
AND ( cd.department_id IS NULL OR cd.department_id IN ($allowedDepartments) )
AND ( cm.mandant_id IS NULL OR cm.mandant_id IN ($allowedMandants) )
AND ( cr.role_id IS NULL OR cr.role_id IN ($allowedRoles) )
AND ( ce.einricht_id IS NULL OR ce.einricht_id IN ($allowedEinrichts) )
AND ( cf.fachbereich_id IS NULL OR cf.fachbereich_id IN ($allowedFachbereiche) )
GROUP BY
c.id
ORDER BY
@@ -199,12 +205,18 @@ $redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=Lis
knowledgecenter_post_mandant AS pm ON kp.id = pm.post_id
LEFT JOIN
knowledgecenter_post_role AS pr ON kp.id = pr.post_id
LEFT JOIN
knowledgecenter_post_einricht AS pe ON kp.id = pe.post_id
LEFT JOIN
knowledgecenter_post_fachbereich AS pfb ON kp.id = pfb.post_id
WHERE
kcp.category_id = $categoryId
AND pv.post_id IS NOT NULL
AND ( pd.department_id IS NULL OR pd.department_id IN ($allowedDepartments) )
AND ( pm.mandant_id IS NULL OR pm.mandant_id IN ($allowedMandants) )
AND ( pr.role_id IS NULL OR pr.role_id IN ($allowedRoles) )
AND ( pe.einricht_id IS NULL OR pe.einricht_id IN ($allowedEinrichts) )
AND ( pfb.fachbereich_id IS NULL OR pfb.fachbereich_id IN ($allowedFachbereiche) )
GROUP BY
kp.id
ORDER BY
@@ -269,13 +281,18 @@ $redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=Lis
knowledgecenter_category_mandant AS cm ON c.id = cm.category_id
LEFT JOIN
knowledgecenter_category_role AS cr ON c.id = cr.category_id
LEFT JOIN
knowledgecenter_category_einricht AS ce ON c.id = ce.category_id
LEFT JOIN
knowledgecenter_category_fachbereich AS cf ON c.id = cf.category_id
WHERE
c.id NOT IN (SELECT child_category_id FROM knowledgecenter_category_links)
AND c.state = 1
c.id NOT IN (SELECT child_category_id FROM knowledgecenter_category_links)
AND c.state = 1
AND ( cd.department_id IS NULL OR cd.department_id IN ($allowedDepartments) )
AND ( cm.mandant_id IS NULL OR cm.mandant_id IN ($allowedMandants) )
AND ( cr.role_id IS NULL OR cr.role_id IN ($allowedRoles) )
AND ( ce.einricht_id IS NULL OR ce.einricht_id IN ($allowedEinrichts) )
AND ( cf.fachbereich_id IS NULL OR cf.fachbereich_id IN ($allowedFachbereiche) )
GROUP BY
c.id
ORDER BY

View File

@@ -74,16 +74,20 @@ $sql = "
AND kct_fb.language_id = ?
-- Sichtbarkeiten (nur Einschränkungen existieren -> filtern, sonst sichtbar)
LEFT JOIN knowledgecenter_post_department AS pd ON kp.id = pd.post_id
LEFT JOIN knowledgecenter_post_mandant AS pm ON kp.id = pm.post_id
LEFT JOIN knowledgecenter_post_role AS pr ON kp.id = pr.post_id
LEFT JOIN knowledgecenter_post_department AS pd ON kp.id = pd.post_id
LEFT JOIN knowledgecenter_post_mandant AS pm ON kp.id = pm.post_id
LEFT JOIN knowledgecenter_post_role AS pr ON kp.id = pr.post_id
LEFT JOIN knowledgecenter_post_einricht AS pe ON kp.id = pe.post_id
LEFT JOIN knowledgecenter_post_fachbereich AS pfb ON kp.id = pfb.post_id
WHERE
pv.post_id IS NOT NULL
AND pv.modified_at >= DATE_SUB(NOW(), INTERVAL 3 WEEK)
AND (pd.department_id IS NULL OR pd.department_id IN ($allowedDepartments))
AND (pm.mandant_id IS NULL OR pm.mandant_id IN ($allowedMandants))
AND (pr.role_id IS NULL OR pr.role_id IN ($allowedRoles))
AND (pd.department_id IS NULL OR pd.department_id IN ($allowedDepartments))
AND (pm.mandant_id IS NULL OR pm.mandant_id IN ($allowedMandants))
AND (pr.role_id IS NULL OR pr.role_id IN ($allowedRoles))
AND (pe.einricht_id IS NULL OR pe.einricht_id IN ($allowedEinrichts))
AND (pfb.fachbereich_id IS NULL OR pfb.fachbereich_id IN ($allowedFachbereiche))
GROUP BY kp.id
ORDER BY pv.modified_at DESC

View File

@@ -51,14 +51,18 @@ $sql = "
AND (v2.valid_from IS NULL OR v2.valid_from <= NOW())
AND (v2.valid_until IS NULL OR v2.valid_until >= NOW())
)
LEFT JOIN knowledgecenter_post_department AS pd ON kp.id = pd.post_id
LEFT JOIN knowledgecenter_post_mandant AS pm ON kp.id = pm.post_id
LEFT JOIN knowledgecenter_post_role AS pr ON kp.id = pr.post_id
LEFT JOIN knowledgecenter_post_department AS pd ON kp.id = pd.post_id
LEFT JOIN knowledgecenter_post_mandant AS pm ON kp.id = pm.post_id
LEFT JOIN knowledgecenter_post_role AS pr ON kp.id = pr.post_id
LEFT JOIN knowledgecenter_post_einricht AS pe ON kp.id = pe.post_id
LEFT JOIN knowledgecenter_post_fachbereich AS pfb ON kp.id = pfb.post_id
WHERE kcp.category_id = ?
AND pv.post_id IS NOT NULL
AND (pd.department_id IS NULL OR pd.department_id IN ($allowedDepartments))
AND (pm.mandant_id IS NULL OR pm.mandant_id IN ($allowedMandants))
AND (pr.role_id IS NULL OR pr.role_id IN ($allowedRoles))
AND (pd.department_id IS NULL OR pd.department_id IN ($allowedDepartments))
AND (pm.mandant_id IS NULL OR pm.mandant_id IN ($allowedMandants))
AND (pr.role_id IS NULL OR pr.role_id IN ($allowedRoles))
AND (pe.einricht_id IS NULL OR pe.einricht_id IN ($allowedEinrichts))
AND (pfb.fachbereich_id IS NULL OR pfb.fachbereich_id IN ($allowedFachbereiche))
GROUP BY kp.id
ORDER BY kp.created_at DESC
";
@@ -100,17 +104,23 @@ JOIN
LEFT JOIN
knowledgecenter_category_translations AS t ON c.id = t.category_id AND t.language_id = $languageId
LEFT JOIN
knowledgecenter_category_department AS cd ON c.id = cd.category_id
knowledgecenter_category_department AS cd ON c.id = cd.category_id
LEFT JOIN
knowledgecenter_category_mandant AS cm ON c.id = cm.category_id
knowledgecenter_category_mandant AS cm ON c.id = cm.category_id
LEFT JOIN
knowledgecenter_category_role AS cr ON c.id = cr.category_id
knowledgecenter_category_role AS cr ON c.id = cr.category_id
LEFT JOIN
knowledgecenter_category_einricht AS ce ON c.id = ce.category_id
LEFT JOIN
knowledgecenter_category_fachbereich AS cf ON c.id = cf.category_id
WHERE
kcl.parent_category_id = $categoryId
AND c.state = 1
AND (cd.department_id IS NULL OR cd.department_id IN ($allowedDepartments))
AND (cm.mandant_id IS NULL OR cm.mandant_id IN ($allowedMandants))
AND (cr.role_id IS NULL OR cr.role_id IN ($allowedRoles))
AND (cd.department_id IS NULL OR cd.department_id IN ($allowedDepartments))
AND (cm.mandant_id IS NULL OR cm.mandant_id IN ($allowedMandants))
AND (cr.role_id IS NULL OR cr.role_id IN ($allowedRoles))
AND (ce.einricht_id IS NULL OR ce.einricht_id IN ($allowedEinrichts))
AND (cf.fachbereich_id IS NULL OR cf.fachbereich_id IN ($allowedFachbereiche))
GROUP BY
c.id
ORDER BY

View File

@@ -10,11 +10,13 @@ $currentUserId = $GLOBALS["main_contact"]["id"] ?? 0;
$userMandants = [];
$userDepartments = [];
$userRoles = [];
$userEinrichts = [];
$userFachbereiche = [];
if ($currentUserId) {
$query = "SELECT main_mandant_id, main_department_id, main_role_id
FROM main_contact_link
WHERE main_contact_id = $currentUserId AND active_d = 1";
$query = "SELECT main_mandant_id, main_department_id, main_role_id, main_einricht_id, main_bereich_id
FROM main_contact_department
WHERE main_contact_id = $currentUserId AND active = 1";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
while ($row = mysqli_fetch_assoc($result)) {
if (!in_array($row['main_mandant_id'], $userMandants)) {
@@ -26,6 +28,12 @@ if ($currentUserId) {
if (!in_array($row['main_role_id'], $userRoles)) {
$userRoles[] = $row['main_role_id'];
}
if ($row['main_einricht_id'] != 0 && !in_array($row['main_einricht_id'], $userEinrichts)) {
$userEinrichts[] = $row['main_einricht_id'];
}
if ($row['main_bereich_id'] != 0 && !in_array($row['main_bereich_id'], $userFachbereiche)) {
$userFachbereiche[] = $row['main_bereich_id'];
}
}
}
@@ -53,15 +61,8 @@ function userHasAccessForPost($postId)
return true;
}
}
global $allowedMandants, $allowedDepartments, $allowedRoles;
global $allowedMandants, $allowedDepartments, $allowedRoles, $allowedEinrichts, $allowedFachbereiche;
// Baue den Query, der per LEFT JOIN die Verknüpfungen berücksichtigt.
// Für jeden Bereich wird ermittelt:
// - cntX: Gesamtzahl der Verknüpfungen in diesem Bereich für diesen Post.
// - matchX: Anzahl der Verknüpfungen, die in der erlaubten Liste liegen.
// Wenn cnt > 0 und match = 0, dann hat der User in diesem Bereich keinen Zugriff.
// Existieren keine Verknüpfungen (cnt = 0), gilt der Bereich als unbeschränkt.
$sql = "
SELECT
COUNT(DISTINCT pd.department_id) AS cntDept,
@@ -69,18 +70,22 @@ function userHasAccessForPost($postId)
COUNT(DISTINCT pm.mandant_id) AS cntMand,
SUM(IF(pm.mandant_id IN (" . ($allowedMandants ? $allowedMandants : 'NULL') . "), 1, 0)) AS matchMand,
COUNT(DISTINCT pr.role_id) AS cntRole,
SUM(IF(pr.role_id IN (" . ($allowedRoles ? $allowedRoles : 'NULL') . "), 1, 0)) AS matchRole
SUM(IF(pr.role_id IN (" . ($allowedRoles ? $allowedRoles : 'NULL') . "), 1, 0)) AS matchRole,
COUNT(DISTINCT pe.einricht_id) AS cntEinricht,
SUM(IF(pe.einricht_id IN (" . ($allowedEinrichts ? $allowedEinrichts : 'NULL') . "), 1, 0)) AS matchEinricht,
COUNT(DISTINCT pfb.fachbereich_id) AS cntFachbereich,
SUM(IF(pfb.fachbereich_id IN (" . ($allowedFachbereiche ? $allowedFachbereiche : 'NULL') . "), 1, 0)) AS matchFachbereich
FROM knowledgecenter_posts AS p
LEFT JOIN knowledgecenter_post_department AS pd ON p.id = pd.post_id
LEFT JOIN knowledgecenter_post_mandant AS pm ON p.id = pm.post_id
LEFT JOIN knowledgecenter_post_role AS pr ON p.id = pr.post_id
LEFT JOIN knowledgecenter_post_einricht AS pe ON p.id = pe.post_id
LEFT JOIN knowledgecenter_post_fachbereich AS pfb ON p.id = pfb.post_id
WHERE p.id = $postId
GROUP BY p.id
";
$res = mysqli_query($GLOBALS['mysql_con'], $sql);
if (!$res || mysqli_num_rows($res) === 0) {
// Falls keine Verknüpfungen in allen Bereichen vorhanden sind, wird oft kein Datensatz zurückgegeben
// das bedeutet, dass es keine Einschränkungen gibt, also Zugriff.
return true;
}
$row = mysqli_fetch_assoc($res);
@@ -95,6 +100,12 @@ function userHasAccessForPost($postId)
if ($row['cntRole'] > 0 && $row['matchRole'] == 0) {
$access = false;
}
if ($row['cntEinricht'] > 0 && $row['matchEinricht'] == 0) {
$access = false;
}
if ($row['cntFachbereich'] > 0 && $row['matchFachbereich'] == 0) {
$access = false;
}
return $access;
}
@@ -362,7 +373,6 @@ if ($resLinkedForm && mysqli_num_rows($resLinkedForm) > 0) {
<a href="#tab-article" class="active"><?= $translation->get("wiki_post") ?></a>
<a href="#tab-files"><?= $translation->get("files") ?> (<?php echo $fileCount; ?>)</a>
<a href="#tab-contacts"><?= $translation->get("Ansprechpartner") ?> (<?php echo $contactCount; ?>)</a>
<a href="#tab-discussion"><?= $translation->get("Forum") ?> (<?php echo $commentCount; ?>)</a>
<a href="#tab-versions"><?= $translation->get("version_history") ?> (<?php echo $versionCount; ?>)</a>
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1) { ?>
<a href="#tab-settings"><?= $translation->get("settings") ?></a>
@@ -426,14 +436,6 @@ if ($resLinkedForm && mysqli_num_rows($resLinkedForm) > 0) {
require_once 'post_cardform_contacts.php';
?>
</div>
<div id="tab-discussion" class="tab-content forum">
<?php
// require_once 'post_cardform_discussion.php';
?>
<?php $knowledgecenter_post_id = $_GET['id']; ?>
<?php require_once(__DIR__ . '/../../forum/Views/topic_listform.php'); ?>
</div>
<!-- Tab Content: Versionsgeschichte -->
<div id="tab-versions" class="tab-content">
<?php

View File

@@ -91,6 +91,7 @@ if ($postId != 0) {
});
});
<?php if ($postId > 0): ?>
// Direktes Laden und Anzeigen der Visitenkarten per AJAX beim Laden der Seite
$(document).ready(function () {
$.post("/module/knowledgecenter_update/Ajax/Ajax.php", {
@@ -108,4 +109,5 @@ if ($postId != 0) {
$("#contactCards").html('<p>Ein Fehler ist aufgetreten.</p>');
});
});
<?php endif; ?>
</script>

View File

@@ -125,29 +125,41 @@ if ($postId != 0) {
}
}
// -------------------- Produkte für Post --------------------
$productsData = [];
$query = "SELECT p.id, pt.title
FROM product AS p
JOIN product_translation AS pt
ON p.id = pt.product_id
WHERE pt.language_id = $languageId";
// -------------------- 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)) {
$productsData[] = ['value' => $row['id'], 'name' => $row['title']];
$postEinrichtsData[] = ['value' => $row['id'], 'name' => $row['description']];
}
$selectedProducts = [];
$selectedPostEinrichts = [];
if ($postId != 0) {
$querySelected = "SELECT p.id, pt.title
FROM product_knowledgecenter_post_link AS pl
JOIN product AS p ON pl.product_id = p.id
JOIN product_translation AS pt
ON p.id = pt.product_id
WHERE pl.post_id = $postId
AND pt.language_id = $languageId";
$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)) {
$selectedProducts[] = ['value' => $row['id'], 'name' => $row['title']];
$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']];
}
}
@@ -221,9 +233,14 @@ if (!empty($post['text_color'])) {
<input type="text" id="postRoleTags" name="postRoles" placeholder="<?=$translation->get("roles")?>…" />
</div>
<h3><?=$translation->get("products")?></h3>
<h3>Einrichtungen</h3>
<div class="settings_container">
<input type="text" id="postProductTags" name="postProducts" placeholder="<?=$translation->get("products")?>…" />
<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>Formular auswählen</h3>
@@ -262,13 +279,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 productsData = <?php echo json_encode($productsData); ?>;
var selectedProducts = <?php echo json_encode($selectedProducts); ?>;
var selectedPostEinrichts = <?php echo json_encode($selectedPostEinrichts); ?>;
var selectedPostFachbereiche = <?php echo json_encode($selectedPostFachbereiche); ?>;
var categoryEnableColorMap = {};
categoriesData.forEach(function (cat) {
categoryEnableColorMap[String(cat.value)] = parseInt(cat.enable_post_color_pickers || 0, 10) === 1;
@@ -370,9 +388,9 @@ if (!empty($post['text_color'])) {
tagifyPostRoles.addTags(selectedPostRoles);
}
// Produkte für Post
var tagifyPostProducts = new Tagify(document.getElementById('postProductTags'), {
whitelist: productsData,
// Einrichtungen für Post
var tagifyPostEinrichts = new Tagify(document.getElementById('postEinrichtTags'), {
whitelist: postEinrichtsData,
tagTextProp: 'name',
enforceWhitelist: true,
dropdown: { enabled: 0, maxItems: Infinity, searchKeys: ["name"] },
@@ -384,10 +402,27 @@ if (!empty($post['text_color'])) {
}
}
});
if (selectedProducts.length) {
tagifyPostProducts.addTags(selectedProducts);
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);
}
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1) { ?>
$("#saveAllBtn").on("click", function () {
@@ -400,6 +435,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,11 +472,19 @@ if (!empty($post['text_color'])) {
post_id: postId,
roles: JSON.stringify(selectedRoles)
}, "json"),
$.post("/module/knowledgecenter_update/Ajax/Ajax.php", {
action: "update_post_products",
action: "update_post_einrichts",
post_id: postId,
products: JSON.stringify(tagifyPostProducts.value.map(tag => tag.value))
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_pdf_inline",
post_id: postId,
@@ -451,17 +496,18 @@ 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, 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 productsSuccess = productsResponse[0].success;
var einrichtsSuccess = einrichtsResponse[0].success;
var fachbereicheSuccess = fachbereicheResponse[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 && pdfInlineSuccess && postColorsSuccess) {
showMessage("Alle Daten erfolgreich gespeichert!", true);
} else {
var errorMsg = "Fehler beim Speichern:";
@@ -470,7 +516,8 @@ if (!empty($post['text_color'])) {
if (!formSuccess) errorMsg += " Formular";
if (!departmentsSuccess) errorMsg += " Departments";
if (!rolesSuccess) errorMsg += " Rollen";
if (!productsSuccess) errorMsg += " Produkte";
if (!einrichtsSuccess) errorMsg += " Einrichtungen";
if (!fachbereicheSuccess) errorMsg += " Fachbereiche";
if (!pdfInlineSuccess) errorMsg += " PDF Inline Vorschau";
if (!postColorsSuccess) errorMsg += " Farben";
showMessage(errorMsg, false);

View File

@@ -196,6 +196,8 @@ function task_cert_normalize_target_selection(array $targetRules, array $targetO
'mandant_ids' => [],
'department_ids' => [],
'role_ids' => [],
'einricht_ids' => [],
'fachbereich_ids' => [],
'override_include_contact_ids' => [],
'override_exclude_contact_ids' => [],
'override_include_reason' => '',
@@ -206,6 +208,8 @@ function task_cert_normalize_target_selection(array $targetRules, array $targetO
$mandantId = (int) ($rule['main_mandant_id'] ?? 0);
$departmentId = (int) ($rule['main_department_id'] ?? 0);
$roleId = (int) ($rule['main_role_id'] ?? 0);
$einrichtId = (int) ($rule['main_einricht_id'] ?? 0);
$fachbereichId = (int) ($rule['main_bereich_id'] ?? 0);
if ($mandantId > 0) {
$selection['mandant_ids'][] = $mandantId;
@@ -218,6 +222,14 @@ function task_cert_normalize_target_selection(array $targetRules, array $targetO
if ($roleId > 0) {
$selection['role_ids'][] = $roleId;
}
if ($einrichtId > 0) {
$selection['einricht_ids'][] = $einrichtId;
}
if ($fachbereichId > 0) {
$selection['fachbereich_ids'][] = $fachbereichId;
}
}
foreach ($targetOverrides as $override) {
@@ -246,6 +258,8 @@ function task_cert_normalize_target_selection(array $targetRules, array $targetO
'mandant_ids',
'department_ids',
'role_ids',
'einricht_ids',
'fachbereich_ids',
'override_include_contact_ids',
'override_exclude_contact_ids',
];

View File

@@ -212,10 +212,14 @@ $buildTargetRules = static function (): array {
$mandantIds = array_values(array_unique(TaskCertRequest::postIntArray('target_mandant_ids')));
$departmentIds = array_values(array_unique(TaskCertRequest::postIntArray('target_department_ids')));
$roleIds = array_values(array_unique(TaskCertRequest::postIntArray('target_role_ids')));
$einrichtIds = array_values(array_unique(TaskCertRequest::postIntArray('target_einricht_ids')));
$fachbereichIds = array_values(array_unique(TaskCertRequest::postIntArray('target_fachbereich_ids')));
$mandantValues = $mandantIds === [] ? [0] : $mandantIds;
$departmentValues = $departmentIds === [] ? [0] : $departmentIds;
$roleValues = $roleIds === [] ? [0] : $roleIds;
$einrichtValues = $einrichtIds === [] ? [0] : $einrichtIds;
$fachbereichValues = $fachbereichIds === [] ? [0] : $fachbereichIds;
$rules = [];
$count = 0;
@@ -224,20 +228,27 @@ $buildTargetRules = static function (): array {
foreach ($mandantValues as $mandantId) {
foreach ($departmentValues as $departmentId) {
foreach ($roleValues as $roleId) {
if ((int) $mandantId === 0 && (int) $departmentId === 0 && (int) $roleId === 0) {
continue;
}
foreach ($einrichtValues as $einrichtId) {
foreach ($fachbereichValues as $fachbereichId) {
if ((int) $mandantId === 0 && (int) $departmentId === 0 && (int) $roleId === 0
&& (int) $einrichtId === 0 && (int) $fachbereichId === 0) {
continue;
}
$rules[] = [
'main_mandant_id' => (int) $mandantId ?: null,
'main_department_id' => (int) $departmentId ?: null,
'main_role_id' => (int) $roleId ?: null,
'active' => 1,
];
$rules[] = [
'main_mandant_id' => (int) $mandantId ?: null,
'main_department_id' => (int) $departmentId ?: null,
'main_role_id' => (int) $roleId ?: null,
'main_einricht_id' => (int) $einrichtId ?: null,
'main_bereich_id' => (int) $fachbereichId ?: null,
'active' => 1,
];
$count++;
if ($count > $maxRules) {
throw new RuntimeException('Zu viele Regelkombinationen. Bitte Auswahl einschränken.');
$count++;
if ($count > $maxRules) {
throw new RuntimeException('Zu viele Regelkombinationen. Bitte Auswahl einschränken.');
}
}
}
}
}

View File

@@ -60,6 +60,8 @@ $targetSelection = array_merge([
'mandant_ids' => [],
'department_ids' => [],
'role_ids' => [],
'einricht_ids' => [],
'fachbereich_ids' => [],
'override_include_contact_ids' => [],
'override_exclude_contact_ids' => [],
'override_include_reason' => '',
@@ -103,6 +105,8 @@ if ($quizQuestions === []) {
$lookupMandants = is_array($lookup['mandants'] ?? null) ? $lookup['mandants'] : [];
$lookupDepartments = is_array($lookup['departments'] ?? null) ? $lookup['departments'] : [];
$lookupRoles = is_array($lookup['roles'] ?? null) ? $lookup['roles'] : [];
$lookupEinrichts = is_array($lookup['einrichts'] ?? null) ? $lookup['einrichts'] : [];
$lookupFachbereiche = is_array($lookup['fachbereiche'] ?? null) ? $lookup['fachbereiche'] : [];
$lookupContacts = is_array($lookup['contacts'] ?? null) ? $lookup['contacts'] : [];
$lookupKnowledgePosts = is_array($lookup['knowledge_posts'] ?? null) ? $lookup['knowledge_posts'] : [];
$lookupTaskCategories = is_array($lookup['task_categories'] ?? null) ? $lookup['task_categories'] : [];
@@ -174,6 +178,8 @@ $ensureLookupRows = static function (array $rows, array $selectedIds, string $la
$lookupMandants = $ensureLookupRows($lookupMandants, (array) ($targetSelection['mandant_ids'] ?? []), 'description', 'Mandant');
$lookupDepartments = $ensureLookupRows($lookupDepartments, (array) ($targetSelection['department_ids'] ?? []), 'description', 'Abteilung');
$lookupRoles = $ensureLookupRows($lookupRoles, (array) ($targetSelection['role_ids'] ?? []), 'description', 'Rolle');
$lookupEinrichts = $ensureLookupRows($lookupEinrichts, (array) ($targetSelection['einricht_ids'] ?? []), 'description', 'Einrichtung');
$lookupFachbereiche = $ensureLookupRows($lookupFachbereiche, (array) ($targetSelection['fachbereich_ids'] ?? []), 'description', 'Fachbereich');
$lookupKnowledgePosts = $ensureLookupRows($lookupKnowledgePosts, (array) ($methodConfig['knowledge_post_ids'] ?? []), 'title', 'Beitrag');
$lookupTaskCategories = $ensureLookupRows($lookupTaskCategories, [(int) ($task['task_category_id'] ?? 0)], 'name', 'Kategorie');
$lookupContacts = $ensureLookupRows(
@@ -801,6 +807,32 @@ $taskSyncRedirectUrl = $taskId > 0
<?php endforeach; ?>
</select>
</div>
<div>
<label for="target_einricht_ids">Einrichtungen</label>
<select id="target_einricht_ids" class="tc-multiselect" name="target_einricht_ids[]" multiple data-placeholder="Einrichtungen auswählen">
<?php foreach ($lookupEinrichts as $einricht): ?>
<?php $id = (int) ($einricht['id'] ?? 0); ?>
<?php if ($id <= 0) { continue; } ?>
<option value="<?php echo $id; ?>" <?php echo in_array($id, (array) $targetSelection['einricht_ids'], true) ? 'selected' : ''; ?>>
<?php echo TaskCertView::e((string) ($einricht['description'] ?? ('Einrichtung #' . $id))); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div>
<label for="target_fachbereich_ids">Fachbereiche</label>
<select id="target_fachbereich_ids" class="tc-multiselect" name="target_fachbereich_ids[]" multiple data-placeholder="Fachbereiche auswählen">
<?php foreach ($lookupFachbereiche as $fachbereich): ?>
<?php $id = (int) ($fachbereich['id'] ?? 0); ?>
<?php if ($id <= 0) { continue; } ?>
<option value="<?php echo $id; ?>" <?php echo in_array($id, (array) $targetSelection['fachbereich_ids'], true) ? 'selected' : ''; ?>>
<?php echo TaskCertView::e((string) ($fachbereich['description'] ?? ('Fachbereich #' . $id))); ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</section>

View File

@@ -38,6 +38,20 @@ class TaskLookupRepository
);
}
public function listEinrichts(): array
{
return TaskCertDb::fetchAll(
'SELECT id, description FROM organigramm_einricht ORDER BY description ASC'
);
}
public function listFachbereiche(): array
{
return TaskCertDb::fetchAll(
'SELECT id, description FROM organogramm_space ORDER BY description ASC'
);
}
public function listActiveContacts(): array
{
return TaskCertDb::fetchAll(

View File

@@ -641,15 +641,17 @@ class AssignmentResolverService
l.main_mandant_id,
l.main_department_id,
l.main_role_id,
l.active_d
l.main_einricht_id,
l.main_bereich_id,
l.active
FROM main_contact c
LEFT JOIN main_contact_link l ON l.main_contact_id = c.id
LEFT JOIN main_contact_department l ON l.main_contact_id = c.id
WHERE c.active = 1'
);
$scopes = [];
foreach ($rows as $row) {
if (isset($row['active_d']) && $row['active_d'] !== null && (int) $row['active_d'] !== 1) {
if (isset($row['active']) && $row['active'] !== null && (int) $row['active'] !== 1) {
continue;
}
@@ -662,6 +664,8 @@ class AssignmentResolverService
'main_mandant_id' => (int) ($row['main_mandant_id'] ?: $row['master_mandant_id']),
'main_department_id' => (int) ($row['main_department_id'] ?? 0),
'main_role_id' => (int) ($row['main_role_id'] ?? 0),
'main_einricht_id' => (int) ($row['main_einricht_id'] ?? 0),
'main_bereich_id' => (int) ($row['main_bereich_id'] ?? 0),
];
}
@@ -674,13 +678,17 @@ class AssignmentResolverService
$ruleMandant = (int) ($rule['main_mandant_id'] ?? 0);
$ruleDepartment = (int) ($rule['main_department_id'] ?? 0);
$ruleRole = (int) ($rule['main_role_id'] ?? 0);
$ruleEinricht = (int) ($rule['main_einricht_id'] ?? 0);
$ruleFachbereich = (int) ($rule['main_bereich_id'] ?? 0);
foreach ($scopeRows as $scope) {
$mandantMatch = $ruleMandant === 0 || $ruleMandant === (int) $scope['main_mandant_id'];
$departmentMatch = $ruleDepartment === 0 || $ruleDepartment === (int) $scope['main_department_id'];
$roleMatch = $ruleRole === 0 || $ruleRole === (int) $scope['main_role_id'];
$einrichtMatch = $ruleEinricht === 0 || $ruleEinricht === (int) $scope['main_einricht_id'];
$fachbereichMatch = $ruleFachbereich === 0 || $ruleFachbereich === (int) $scope['main_bereich_id'];
if ($mandantMatch && $departmentMatch && $roleMatch) {
if ($mandantMatch && $departmentMatch && $roleMatch && $einrichtMatch && $fachbereichMatch) {
return true;
}
}

View File

@@ -19,6 +19,8 @@ class TaskLookupService
'mandants' => $this->safeFetch('mandants', fn(): array => $this->lookupRepo->listMandants()),
'departments' => $this->safeFetch('departments', fn(): array => $this->lookupRepo->listDepartments()),
'roles' => $this->safeFetch('roles', fn(): array => $this->lookupRepo->listRoles()),
'einrichts' => $this->safeFetch('einrichts', fn(): array => $this->lookupRepo->listEinrichts()),
'fachbereiche' => $this->safeFetch('fachbereiche', fn(): array => $this->lookupRepo->listFachbereiche()),
'contacts' => $this->safeFetch('contacts', fn(): array => $this->lookupRepo->listActiveContacts()),
'knowledge_posts' => $this->safeFetch('knowledge_posts', fn(): array => $this->lookupRepo->listKnowledgePosts($languageId)),
];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

3
text_constants.inc.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
// Merged into mysyde/admin/text_constants.inc.php
require_once __DIR__ . '/mysyde/admin/text_constants.inc.php';