<?php
$formname    = "form_mandant_card";
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
$inputname   = "input_id";
?>

<div id="overlaycrumb">
    <?php if ($input_mandant["id"] == "") {
        echo $translation->get("new_mandant");
    } else {
        echo $translation->get("edit_mandant");
    }
    ?>
    <div id="closeoverlay" onclick="disableOverlay();"></div>
</div>
    <ul class="toolbar_menu">
        <?= button("save", $translation->get("save"), $formname, "loadCard('save', true)"); ?>
        <?= button("save", $translation->get("save_and_close"), $formname, "loadCard('save', true, '', true)"); ?>
        <li>
            <ul>
                <?php
                if ($input_mandant["id"] != "") {
                    echo button("delete", $translation->get("delete"), $formname, "loadCard('delete', true, '{$translation->get('delete_mandant_confirm')}', true)", "", FALSE);
                }
                ?>
                <?= button("reset", $translation->get("restore"), $formname, "?action=edit", "", 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_id" type="hidden" value="<?= $input_mandant["id"] ?>">

    <table class="cardform" border="0" cellspacing="0" cellpadding="0">
        <div class='pr-30'>
            <? input($translation->get("description"), "input_description", "text", $input_mandant["description"], 100) ?>
        </div>
        <tr>
            <td>
                <? input($translation->get("address"), "input_address", "text", $input_mandant["address"], 50) ?>
                <? input($translation->get("number_central"), "input_number_central", "text", $input_mandant["number_central"], 50) ?>
                <? input($translation->get("number_support"), "input_number_support", "text", $input_mandant["number_support"], 50) ?>
                <? input($translation->get("number_fax"), "input_number_fax", "text", $input_mandant["number_fax"], 50) ?>
                <? input($translation->get("image"), "input_image", "file", $input_mandant["image"], 45);
                    $valFile = '';
                    if($input_mandant['image'] != '' && $input_mandant['image'] != NULL){
                        $valFile = $input_mandant['image'];
                    }
                ?>
                <input type="hidden" name="mandant_image_old" value="<?=$valFile;?>">
                <?php
                    if($input_mandant["image"] != NULL && $input_mandant["image"] != ''){
                        echo "<div class='img_container mandant_image'><img class='img-fluid' src='/userdata/intranet/mandant/".$input_mandant["image"]."'></div>";
                        echo button("delete", $translation->get("delete"), $formname, "loadCard('delete_image', true, '{$translation->get('delete_user_picture')}', false)", "", FALSE);
                    }
                ?>
                <? input($translation->get("image"), "input_bg_image", "file", $input_mandant["bg_image"], 45);
                    $valFile = '';
                    if($input_mandant['bg_image'] != '' && $input_mandant['bg_image'] != NULL){
                        $valFile = $input_mandant['bg_image'];
                    }
                ?>
                <input type="hidden" name="mandant_bg_image_old" value="<?=$valFile;?>">
                <?php
                    if($input_mandant["bg_image"] != NULL && $input_mandant["bg_image"] != ''){
                        echo "<div class='img_container mandant_image'><img class='img-fluid' src='/userdata/intranet/mandant/".$input_mandant["bg_image"]."'></div>";
                        echo button("delete", $translation->get("delete"), $formname, "loadCard('delete_image', true, '{$translation->get('delete_user_picture')}', false)", "", FALSE);
                    }
                ?>
            </td>
            <td>
                <? input($translation->get("link_support"), "input_link_support", "text", $input_mandant["link_support"], 100) ?>
                <? input($translation->get("link_website"), "input_link_website", "text", $input_mandant["link_website"], 100) ?>
                <? input($translation->get("mail_team"), "input_mail_team", "text", $input_mandant["mail_team"], 100) ?>
                <?= input_select_from_sql($translation->get("startpage"), "input_navigation_id", 'SELECT id, menu_name as name FROM main_navigation ORDER BY level, sorting', $input_mandant['main_navigation_id'], FALSE, FALSE, "", TRUE); ?>
                <? input($translation->get("border_radius"), "input_border_radius", "number", $input_mandant["mandant_border_radius"], 100) ?>
                <? input($translation->get("mandant_color"), "input_mandant_color", "color", $input_mandant["mandant_color"], 100) ?>
                <? input($translation->get("mandant_border_color"), "input_mandant_border_color", "color", $input_mandant["mandant_border_color"], 100) ?>
                <? input($translation->get("input_mandant_bg_light"), "input_mandant_bg_light", "color", $input_mandant["mandant_bg_light"], 100) ?>
                <? input($translation->get("favicon"), "input_favicon", "file", $input_mandant["favicon"], 45, $disabled);
                    $valFile = '';
                    if($input_mandant['favicon'] != '' && $input_mandant['favicon'] != NULL){
                        $valFile = $input_mandant['favicon'];
                    }
                ?>
                      <input type="hidden" name="favicon_image_old" value="<?=$valFile;?>">
                <?php
                    if($input_mandant["favicon"] != NULL && $input_mandant["favicon"] != ''){
                        echo "<div class='img_container favicon_image'><img class='img-fluid' src='/userdata/intranet/mandant/".$input_mandant["favicon"]."'></div>";
                    }
                ?>
            </td>
        </tr>
    </table>
</form>