Files
awo-hamburg-intranet/mysyde/intranet/admin/edit_department_listform.inc.php
2026-02-17 14:56:23 +01:00

62 lines
2.5 KiB
PHP

<?php
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
$formname = "form_department_list";
$inputname = "input_id";
global $filter_mandant;
$filter_mandant = (isset($_REQUEST['mandant_id']) ? $_REQUEST['mandant_id'] : 0);
function filter_mandant($filter){ ?>
<h3><?php echo get_translation('filter_mandant'); ?>:</h3>
<div class="input">
<select id="filter_mandant" name="filter_mandant" class="bigselect" onchange="filter_mandant();">
<option value="0"><?php echo get_translation('all_mandate'); ?></option>
<?php
$query = "SELECT * FROM main_mandant";
$result = @mysqli_query($GLOBALS['mysql_con'], $query);
while($row = @mysqli_fetch_array($result)){ ?>
<option value="<?= $row['id'] ?>" <?= ($filter == $row['id'] ? 'selected="selected"' : ""); ?>><?= $row['description'] ?></option>
<?php } ?>
</select>
</div>
<?php }
?>
<ul class="toolbar_menu">
<?= button("new", $translation->get("new"), $formname, "loadCard('new', true)"); ?>
<div class="filter_mandant">
<?= filter_mandant($filter_mandant) ?>
</div>
</ul>
<div id="mainContent">
<?php echo current_website_language($site, $language); ?>
<h1><?php echo get_translation('top_department'); ?></h1>
<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
<input type="hidden" class="selected_linklist_row" name="input_id" value="" />
<div class="requestLoader"></div>
<?
$where = "";
if($filter_mandant != 0){
$where = "WHERE main_mandant_id = ".$filter_mandant;
}
$query = "SELECT DISTINCT main_department.id, description AS '" . $translation->get("name") . "' FROM main_department LEFT JOIN main_department_mandant_link ON main_department.id = main_department_mandant_link.main_department_id ".$where." ORDER BY description ASC";
$format = array("option", "text");
if ($result = mysqli_query($GLOBALS['mysql_con'], $query)) {
linklist($result, "form_department_list", $format);
}
?>
</form>
</div>
<script>
function filter_mandant() {
var filter = jQuery('#filter_mandant').val();
const url = window.location.href.split('?')[0];
var newUrl = url + '?mandant_id='+filter;
window.location.href = newUrl;
}
</script>