<style>
.select2-container {
    width: 100% !important;
}
</style>

<form action="index.php?module=mandant&event=save" method="post" name="hm" class="form-horizontal form-label-left">
    <div class="card panel-fcs-border shadow-sm">
        <div class="card-header">
            <div class="row">
                <div class="col-sm-6">
                    <span class="fcs-card-title h2">[% $user->gettext('Mandant bearbeiten') %]</span>
                </div>
                <div class="col-sm-6 text-end">
                    <div class="btn-group">
                        <input type="button" onclick="window.location.href = 'index.php?module=mandant';" value="[% $user->gettext('Liste') %]" class="btn btn-outline-secondary"  />
                        <input type="submit" value="[% $user->gettext('Speichern') %]" class="btn btn-outline-primary"  />
                    </div>
                </div>
            </div>
        </div>
        <div class="card-body">

            [% if $error %]
                <tr>
                    <th colspan="2" >
                        [% if $error == 1 %]
                            <div class="alert alert-error">[% $user->gettext('F&uuml;llen Sie bitte alle Pflichtfelder aus') %]</div>
                        [% /if %]

                        [% if $error == 2 %]
                            <div class="alert alert-info">[% $user->gettext('Mandant wurde aktualisiert') %]</div>
                        [% /if %]

                        [% if $error == 3 %]
                            <div class="alert alert-info">[% $user->gettext('Mandant wurde gespeichert') %]</div>
                        [% /if %]

                        [% if $error == 4 %]
                            <div class="alert alert-error">[% $user->gettext('Konnte aus unbekannten Gr&uuml;nden nicht gespeichert werden') %]</div>
                        [% /if %]

                    </th>
                </tr>
            [% /if %]



            <input type="hidden" name="id" value="[% $Mandant.id %]" />

            <div class="form-group row mb-3">
                <label class="col-lg-2 control-label">[% $user->gettext('Mandant') %] *</label>
                <div class="col-lg-10">
                    <input type="text" name="Descr"  maxlength="50" value="[% $Mandant.Name %]" class="form-control required"  required="required" />
                </div>
            </div>


            <div class="form-group row mb-3">
                <label class="col-lg-2 control-label">[% $user->gettext('Absenderadresse') %]</label>
                <div class="col-lg-10">
                    <input type="text" name="SendFromAdress"  maxlength="200" value="[% $Mandant.SendFromAdress %]" class="form-control" />
                </div>
            </div>

            <div class="form-group row mb-3">
                <label class="col-lg-2 control-label">[% $user->gettext('Gruppen') %]</label>
                <div class="col-lg-10">
                    <div>
                        <select size="1" name="GroupIDs[]" class="form-control select2" multiple="multiple">
                            [% html_options options=$groups selected=$Mandant.GroupIDs %]
                        </select>
                    </div>
                </div>
            </div>
            [% if $Mandant.created != '' %]
                <div class="form-group row mb-3">
                    <label class="col-lg-2 control-label">[% $user->gettext('Erstellt am') %]</label>
                    <div class="col-lg-10">
                        <p class="form-control-static">
                            [% $Mandant.Created|date_format:"%d.%m.%Y %H:%M" %]
                        </p>
                    </div>
                </div>
            [% /if %]
            [% if $Mandant.updated != '' %]
                <div class="form-group row mb-3">
                    <label class="col-lg-2 control-label">[% $user->gettext('Letzte &Auml;nderung') %]</label>
                    <div class="col-lg-10">
                        <p class="form-control-static">
                            [% $Mandant.Updated|date_format:"%d.%m.%Y %H:%M" %]
                        </p>
                    </div>
                </div>
            [% /if %]
        </div>
    </div>
</form>

<script>

    $('.select2').select2({theme: 'bootstrap-5',
        closeOnSelect: true,
        filter: true
    });

</script>

<!-- Component Mandant end -->
