<? 
$formname        = "form_knowledgecenter_card";
$main_layout_id     = $GLOBALS["language"]["main_layout_id"];
$knowledgecenter_id = $input_knowledgecenter["id"];
$translation        = \DynCom\mysyde\common\classes\Registry::get("translation");
?>

<div id="overlaycrumb">
    <?php if ($input_knowledgecenter["id"] == "") {
        echo $translation->get("new_menuitem_headline");
    } else {
        echo $translation->get("edit_menuitem");
    }
    ?>
    <div id="closeoverlay" onclick="disableOverlay();"></div>
</div>

<ul class="toolbar_menu">
    <?= button("save", $translation->get("save"), $formname, "loadCard('save_knowledgecenter', true)"); ?>
    <?= button("save", $translation->get("save_and_close"), $formname, "loadCard('save_knowledgecenter', true, '', true)"); ?>
    <li>
        <ul>
            <?= button("delete", $translation->get("delete"), $formname, "loadCard('delete_knowledgecenter', true, '{$translation->get('delete_navitem_confirm')}', true)", "", FALSE); ?>
        </ul>
    </li>

</ul>


<?php
if ($messages !== null) {
    if (count($messages)) {
        echo '<div id="overlayMessages">' . join("\r\n", $messages) . '</div>';
    } 
}
?>

<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
    <input name="input_knowledgecenter_id" type="hidden" value="<?= $input_knowledgecenter["id"] ?>">
    <input name="input_main_layout_id" type="hidden" value="<?= $main_layout_id ?>">

    <table class="cardform" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td class="w-100">
                <? input($translation->get("name"), "input_description", "text", $input_knowledgecenter["description"], 100) ?>
                <? input($translation->get("tags"), "input_tags", "text", $input_knowledgecenter["tags"], 100) ?>
                <? input($translation->get("image"), "input_image", "file", $input_knowledgecenter["image"], 45, $disabled);
                    $valFile = '';
                    if($input_knowledgecenter['image'] != '' && $input_knowledgecenter['image'] != NULL){
                        $valFile = $input_knowledgecenter['image'];
                    }
                ?>
                <input type="hidden" name="input_image_old" value="<?=$valFile;?>">
                <?php
                    if($input_knowledgecenter["image"] != NULL && $input_knowledgecenter["image"] != ''){
                        echo "<div class='img_container knowledgecenter_image'><img class='img-fluid' src='/userdata".$input_knowledgecenter["image"]."'></div>";
                        echo button("delete", $translation->get("delete_image"), $formname, "loadCard('delete_image', true, '{$translation->get('delete_image')}', false)", "", FALSE);
                    }
                ?>
                <? input($translation->get("active"), "input_active", "checkbox", $input_knowledgecenter["active"]) ?>
                <!-- <?= create_mandant_select($input_knowledgecenter['id']); ?> -->

                <?php
                try {
                    //code...
                    multi_select_permission($input_knowledgecenter['id'], 'mandant');
                    multi_select_permission($input_knowledgecenter['id'], 'department');
                    multi_select_permission($input_knowledgecenter['id'], 'role');
                    multi_select_permission($input_knowledgecenter['id'], 'einricht');
                    multi_select_permission($input_knowledgecenter['id'], 'fachbereich');
                } catch (\Throwable $th) {
                    echo $th;
                }
                ?>
            </td>
        </tr>
    </table>
</form>