Files
awo-hamburg-intranet/module/knowledgecenter_update/Views/post_listform.php

95 lines
3.2 KiB
PHP
Raw Normal View History

<?php
// post_listform.php
// Redirect-URL für den Zurück-Button bzw. Navigation
$redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=Category';
// Kategorien für das Dropdown holen (state = 1)
$catsQuery = "
SELECT c.id, t.title
FROM knowledgecenter_categories_update AS c
LEFT JOIN knowledgecenter_category_translations AS t
ON t.category_id = c.id AND t.language_id = $languageId
ORDER BY t.title ASC
";
$catsResult = mysqli_query($GLOBALS['mysql_con'], $catsQuery);
$allCategories = [];
while ($r = mysqli_fetch_assoc($catsResult)) {
$allCategories[] = $r;
}
?>
<div class="titlebar">
<div>
<a title="<?= $translation->get("back") ?>" href="?action=List"></a>
<h1><?= $translation->get("post_list") ?> <span id="postCount"></span>
</h1>
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1) { ?>
<a href="?action=NewPost" class="post-action-btn green">+</a>
<?php } ?>
</div>
<div>
<select id="categoryFilter">
<option value=""><?= $translation->get("all_categories") ?></option>
<?php foreach ($allCategories as $cat): ?>
<option value="<?= $cat['id'] ?>">
<?= htmlspecialchars($cat['title'] ?: "ID:{$cat['id']}") ?>
</option>
<?php endforeach; ?>
</select>
<input type="search" id="searchQuery" placeholder="<?= $translation->get("search_placeholder") ?>" />
</div>
</div>
<div id="postListContainer" class="wiki-list">
</div>
<script>
var myRedirectURL = window.location.href;
var debounceTimer;
function loadPostList() {
var searchQuery = $('#searchQuery').val();
var categoryId = $('#categoryFilter').val(); // neu
$.ajax({
url: '/module/knowledgecenter_update/Ajax/Ajax.php',
type: 'POST',
data: {
action: 'get_post_list',
language_code: '<?= $languageCode ?>',
language_id: '<?= $languageId ?>',
redirectURL: myRedirectURL,
query: searchQuery,
category_id: categoryId // hier mitgeben
},
dataType: 'json',
beforeSend: function () { $('#overlayLoader').show(); },
complete: function () { $('#overlayLoader').hide(); },
success: function (response) {
if (response.success) {
$('#postListContainer').html(response.html);
var c = parseInt(response.count || 0, 10);
$('#postCount').text('(' + c + ')');
} else {
alert('Fehler: ' + response.error);
}
},
error: function (xhr, status, error) {
console.error('AJAX-Fehler:', error);
}
});
}
$(document).ready(function () {
loadPostList();
$('#searchQuery').on('input', function () {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(loadPostList, 300);
});
$('#categoryFilter').on('change', loadPostList);
});
</script>