<style type="text/css">

    table#formwizard tr td {
        padding             : 1px   !important;
        background-color    : transparent;
    }

    span.form_notice {
        font-size           : 8pt;
    }
</style>

<script type="text/javascript" language="JavaScript">


    function openCategory() {
        var url = "index.php?module=category&class=select&id=1&fwiz=1";
        $("#dialog-category").fancybox({
            title: 'Kategorie wählen',
            href: url,
            type: 'ajax',
            minWidth: 200,
            minHeight: 200,
            autoResize: true
        }).trigger("click");
    }

    function deaktivateCatSelection() {
        document.getElementById('CategoryDescr1').value = '';
        document.getElementById('CategoryDescr2').value = '';
        document.getElementById('CategoryID1').value = '';
        document.getElementById('CategoryID2').value = '';
    }
    $(document).ready(function () {
        $(".dialog").fancybox({
            maxWidth: 800,
            maxHeight: 600,
            closeClick: false
        });

        $(".multiple").multiselect({
            buttonClass: 'form-select',
    templates: {
        button: '<button type="button" class="multiselect dropdown-toggle" data-bs-toggle="dropdown"><span class="multiselect-selected-text"></span></button>',
    },
            noneSelectedText: 'Wählen Sie',
            selectedList: 1,
            selectedText: false,
            header: false,
            multiple: false
        });
    });


</script>

<form action="index.php?module=formwizard&event=newFormular" method="post" class="form-horizontal form-label-left">

    <div class="card panel-fcs-border shadow-sm">
        <div class="card-header">
            <span class="fcs-card-title h2">
                [%$user->gettext('Formulare')%]
            </span>
        </div>
        <div class="card-body">
            <div class="col-lg-8 offset-md-2">

                [% if $TableNameError %]<div class="alert alert-danger" role="alert"><strong>[% $user->gettext('Fehler')%]: </strong>[% $user->gettext('Die Tabellenbezeichnung ist ung&uuml;ltig.') %]</div>[% /if %]
                [% if $TableNameExistError %]<div class="alert alert-danger" role="alert"><strong>[% $user->gettext('Fehler')%]: </strong>[% $user->gettext('Eine Tabelle mit dieser Bezeichnung existiert bereits.') %]</div>[% /if %]
                [% if $FormNameError %]<div class="alert alert-danger" role="alert"><strong>[% $user->gettext('Fehler')%]: </strong>[% $user->gettext('Ein Name f&uuml;r das Formular muss angegeben werden.') %]</div>[% /if %]
                [% if $CategoryIDError %]<div class="alert alert-danger" role="alert"><strong>[% $user->gettext('Fehler')%]: </strong>[% $user->gettext('Die Kategorie existiert nicht.') %]</div>[% /if %]
                [% if $TicketTemplateIDError %]<div class="alert alert-danger" role="alert"><strong>[% $user->gettext('Fehler')%]: </strong>[% $user->gettext('Die Vorlage existiert nicht oder ist bereits mit einem Formular verknüpft.') %]</div>[% /if %]
                [% if $CategoryIDError2 %]<div class="alert alert-danger" role="alert"><strong>[% $user->gettext('Fehler')%]: </strong>[% $user->gettext('Die Kategorie wird bereits von einem anderen Formular verwendet.') %]</div>[% /if %]
                [% if $TicketTemplateIDError2 %]<div class="alert alert-danger" role="alert"><strong>[% $user->gettext('Fehler')%]: </strong>[% $user->gettext('Die Vorlage wird bereits von einem anderen Formular verwendet.') %]</div>[% /if %]
                [% if $TableCreateError %]<div class="alert alert-danger" role="alert"><strong>[% $user->gettext('Fehler')%]: </strong>[% $user->gettext('Die Tabelle konnte nicht angelegt werden. (evtl. nicht ausreichende Rechte.)') %]</div>[% /if %]                            

                <div class="card panel-info shadow-sm rounded">
                    <div class="card-header">
                        <div class="row">
                            <div class="col-lg-6">
                                <span class="fcs-card-title h3">[% $user->gettext('Neues Formular erstellen')%] </span>
                            </div>
                            <div class="col-lg-6 text-end">
                                <div class="btn-group">
                                    <input type="submit" value="[% $user->gettext('Speichern') %]" class="btn btn-outline-primary" onclick="submitForm();" />
                                    <input type="button" value="[% $user->gettext('Zur&uuml;ck') %]" class="btn btn-outline-secondary" onclick="document.location.href = 'index.php?module=formwizard';" />
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="card-body">
                        <div class="form-group row mb-3">
                            <label class="col-lg-3 control-label">
                                [% $user->gettext('Tabellenname') %]:
                            </label>
                            <div class="col-lg-9">

                                <div class="input-group">

                                    <span class="input-group-text">
                                        hm_form_
                                    </span>
                                    <input type="text" name="TableName"  class="form-control" value="[% $TableName %]" required="required" pattern="[A-Za-z0-9]+"/>
                                </div>


                                <p class="form-control-static">[% $user->gettext('<b>Hinweis:</b> Bitte nur a-z0-9 benutzen. Keine Leerzeichen. Dies wird der Tabellenname in der Datenbank.') %]</p>

                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="col-lg-3 control-label">
                                [% $user->gettext('Formularname') %]:
                            </label>
                            <div class="col-lg-9">
                                <input type="text" name="FormName" size="30" maxlength="100" class="form-control " value="[% $FormName %]" required="required" />
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="col-lg-3 control-label">
                                [% $user->gettext('Kategorie') %]:
                            </label>
                            <div class="col-lg-9">
                                <div class="input-group">
                                    <input type="hidden" name="CategoryID" id="CategoryID1" value="[% $CategoryID %]">
                                    <input type="hidden" id="CategoryID2" value="" />
                                    <input type="hidden" id="CategoryDescr2" value="" />
                                    <input type="text" class="form-control" id="CategoryDescr1" readonly="readonly" value="[% $CategoryDescr %]">
                                    <span class="input-group-text">
                                        <a href="JavaScript:void(0);" onclick="openCategory(1);" class="btn btn-outline-primary"><i class="fa  fa-folder-open"  title="[% $user->gettext('Kategorie ausw&auml;hlen') %]"></i></a>
                                    </span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="col-lg-3 control-label">
                                [% $user->gettext('Ticketvorlage') %]:
                            </label>
                            <div class="col-lg-9">
                                <select id="TicketTemplateID" name="TicketTemplateID" id="TicketTemplateID" class="form-control" onchange="deaktivateCatSelection();">
                                    [% html_options size="1" options=$TicketTemplates selected=$form.tickettemplateid %]
                                </select>
                            </div>
                        </div>

                        <div class="form-group row mb-3">
                            <label class="col-lg-3 control-label">
                                [% $user->gettext('Freigabe') %]:
                            </label>
                            <div class="col-lg-9">
                                <input type="radio" name="Published" value="Y" [% if $Published == "Y" %]checked="checked"[% /if %] />
                                <label>[% $user->gettext('Ja') %]</label>
                                <input type="radio" name="Published" value="N" [% if $Published != "Y" %]checked="checked"[% /if %] />
                                <label>[% $user->gettext('Nein') %]</label>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>


</form>
<div id="dialog-category" style="display:none;" width="500" hight="500">

</div>

