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

<div id="overlaycrumb">
    <?php if ($input_unit["id"] == "") {
        echo $translation->get("new_unit");
    } else {
        echo $translation->get("edit_unit");
    }
    ?>
    <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>
                <?= button("delete", $translation->get("delete"), $formname, "loadCard('delete', true, '{$translation->get('delete_user_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_id" type="hidden" value="<?= $input_unit["id"] ?>">
    <input name="input_line_id" type="hidden" value="<?= $input_unit["id"] ?>" />
    <table class="cardform" border="0" cellspacing="0" cellpadding="0">
        <tr class="certificate_table_row">
            <td class="w-100">
                <? input($translation->get("title"), "input_title", "text", $input_unit["title"], 255) ?>
                <? input($translation->get("description"), "input_description", "textarea", $input_unit["description"]) ?>
                <div class="iframe_input">
                    <div class="label pfusch">iFrame Link</div>
                    <div class="input_note">
                        <?= $translation->get("iframe_note") ?> <a href="https://support.microsoft.com/de-de/office/einbetten-von-dateien-direkt-in-ihre-website-oder-einen-blog-ed07dd52-8bdb-431d-96a5-cbe8a80b7418">Link</a> 
                    </div>
                    <? input($translation->get("link"), "input_link", "textarea", $input_unit["link"]) ?>
                </div>
            </td>
            <td class="w-100">
                <div class="basic_settings">
                    <div class="toggle_headline opened">
                        <h3><?= $translation->get("basic_settings") ?></h3>
                        <div class="chevron"></div>
                    </div>
                    <div class="toggle_area">
                        <div class="basic_setting_inputs">
                            <div class="choose_mandants">
                            <div class="label"><?= $translation->get("choose_mandants") ?></div>
                            <?php
                            create_mandant_select($input_unit['id']);
                            ?>
                            </div>
                            <div class="choose_category">
                            <?php
                            create_category_select($input_unit['id']);
                            ?>
                            </div>
                        </div>
                    </div>
                </div>

            </td>

        </tr>

    </table>

    <?php
        if ($input_unit['id'] != "") {
            require_once 'learning_contact_listform.inc.php';
        } ?>
</form>

<script>

    $(document).ready(function(){
  $('#input_recurring').change(function(){
    if(this.checked){
      $('.recurring_select').show();
    }
    else{
      $('.recurring_select').hide();
    }
  });

  $(".toggle_headline").click(function() {
    $(this).next().slideToggle();
    $(this).toggleClass("opened");

})
});
</script>

<?
if ($input_unit['id'] != "") {
    require_once 'learning_unit_line_listform.inc.php';
}
