<script type="text/javascript" src="includes/js/jquery-ui-timepicker-addon.js"></script>
<link rel="stylesheet" type="text/css" href="styles/[% $CSSTEMPLATE %]/css/jquery-ui-timepicker-addon.css" media="screen" />

        <script>
            var strNonSelectedText = "[% $user->gettext('Wählen Sie') %]" ;
            var strnSelectedText = "[% $user->gettext('gewählt') %]" ;
            var strallSelectedText = "[% $user->gettext('Alle gewählt') %]" ;
        </script>
             
        
<form action="index.php?module=calendar&amp;class=event&amp;event=storeEvent" method="post" name="hm" id="hm-CalendarForm" enctype="multipart/form-data" class="form-horizontal form-label-left" >
    [% if $event.caleventid > 0%]
        <input type="hidden" name="CalEventID" value="[% $event.caleventid %]" />
    [% /if %]
    <input type="hidden" name="task" value="save" />


    <!-- ###CONTENT### begin -->
    <div class="card panel-fcs-border shadow-sm">
        <div class="card-header">
            <span class="fcs-card-title h2">
                [% $user->gettext('Termin') %]
            </span>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-lg-6">
                    <div class="card panel-info shadow-sm rounded">
                        <div class="card-body text-center">
                            <div class="btn-group">
                                <input type="submit" value="[% $user->gettext('Speichern') %]" class="btn btn-outline-primary"/>
                                <input type="button" value="[% $user->gettext('Zur&uuml;ck') %]" onclick="window.history.back(-1);" class="btn btn-outline-secondary"/>
                            </div>
                        </div>
                    </div>

                    <div class="card panel-info shadow-sm rounded">
                        <div class="card-header">
                            <span class="fcs-card-title h3">[%$user->gettext('Allgemeine Informationen')%]</span>
                        </div>
                        <div class="card-body">
                            <div class="form-group row mb-3">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Was") %]
                                </label>
                                <div class="col-lg-9">
                                    <input type="text" value="[% $event.caleventname %]" class="form-control" name="CalEventName" required="required"/>
                                </div>
                            </div>

                            <div class="form-group row mb-3 form-inline">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Wann") %]
                                </label>
                                <div class="col-lg-9">
                                    <input type="text" name="CalEventStartDate" value="[% $dates->_german_date($event.caleventstartdate) %]"  class="form-control datepicker" required="required"/>
                                    <span id="calevent_starttime" [% if $event.caleventdateday == 1 %]style="display:none;" [% /if %]/>
                                    <div class="input-group">
                                        <input type="text" name="CalEventStartTime" value="[% $event.caleventstarttime %]"  class="form-control timepicker" />
                                        <span class="input-group-text">[%$user->gettext('bis')%]</span>
                                        <input type="text" name="CalEventEndTime" value="[% $event.caleventendtime %]"class="form-control timepicker" />

                                    </div>
                                    <br>
                                    <input type="checkbox" name="CalEventDateDay" value="1" onclick="set_daily(this);" [% if $event.caleventdateday == 1 %]checked="checked" [% /if %] style="padding-left:0px; margin-left: 0px;"/> [% $user->gettext("ganzt&auml;gig") %]

                                </div>
                            </div>

                            <div class="form-group row mb-3">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Wo") %]
                                </label>
                                <div class="col-lg-9">
                                    <input type="text" value="[% $event.caleventlocation %]" class="form-control" name="CalEventLocation" />
                                </div>
                            </div>

                            <div class="form-group row mb-3">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Beschreibung") %]
                                </label>
                                <div class="col-lg-9">
                                    <textarea name="CalEventDescription" rows="8" class="form-control">[% $event.caleventdescription %]</textarea>

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

                </div>
                <div class="col-lg-6">
                    <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('Wiederholung')%]</span>
                                </div>
                                <div class="col-lg-6 text-end">
                                    <select size="1" onchange="show_cal_repeat(this[this.selectedIndex].value);" name="CalEventRepeatMode" class="form-control multiple">
                                        <option value="one" [% if $event.caleventrepeatmode == "one" %]selected="selected"[% /if %]>[% $user->gettext("Einmaliger Termin") %]</option>
                                        <option value="daily" [% if $event.caleventrepeatmode == "daily" %]selected="selected"[% /if %]>[% $user->gettext("T&auml;glich") %]</option>
                                        <option value="weekday" [% if $event.caleventrepeatmode == "weekday" %]selected="selected"[% /if %]>[% $user->gettext("An jedem Wochentag (Mo-Fr)") %]</option>
                                        <option value="unpair [% if $event.caleventrepeatmode == "unpair" %]selected="selected"[% /if %]">[% $user->gettext("Jeden Mo., Mi. und Fr.") %]</option>
                                        <option value="pair" [% if $event.caleventrepeatmode == "pair" %]selected="selected"[% /if %]>[% $user->gettext("Jeden Di. und Do.") %]</option>
                                        <option value="weekly" [% if $event.caleventrepeatmode == "weekly" %]selected="selected"[% /if %]>[% $user->gettext("W&ouml;chentlich") %]</option>
                                        <option value="monthly" [% if $event.caleventrepeatmode == "monthly" %]selected="selected"[% /if %]>[% $user->gettext("Monatlich") %]</option>
                                        <option value="yearly" [% if $event.caleventrepeatmode == "yearly" %]selected="selected"[% /if %]>[% $user->gettext("J&auml;hrlich") %]</option>
                                    </select>
                                </div>


                            </div>
                        </div>
                        <div class="card-body" id="repeat_form_inner">
                            <div class="form-group row mb-3" id="repeat_form_interval">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Wiederholung alle") %]
                                </label>
                                <div class="col-lg-9">
                                    <select  name="CalEventRepeatInterval" class="form-control">[% html_options options=$interval selected=$event.caleventrepeatinterval %]</select>
                                    <span id="repeat_form_interval_daily">[% $user->gettext("Tage") %]</span>
                                    <span id="repeat_form_interval_weekly">[% $user->gettext("Wochen") %]</span>
                                    <span id="repeat_form_interval_monthly">[% $user->gettext("Monate") %]</span>
                                    <span id="repeat_form_interval_yearly">[% $user->gettext("Jahre") %]</span>
                                </div>
                            </div>

                            <div class="form-group row mb-3" id="repeat_form_weekday">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Wiederholen am") %]:
                                </label>
                                <div class="col-lg-9">
                                    <input type="checkbox" value="1" name="CalEventWeekday[1]" [% if $event.caleventweekday[1] == 1 %]checked="checked" [% /if %]/> [% $user->gettext("Mo") %]
                                    <input type="checkbox" value="1" name="CalEventWeekday[2]" [% if $event.caleventweekday[2] == 1 %]checked="checked" [% /if %] /> [% $user->gettext("Di") %]
                                    <input type="checkbox" value="1" name="CalEventWeekday[3]" [% if $event.caleventweekday[3] == 1 %]checked="checked" [% /if %] /> [% $user->gettext("Mi") %]
                                    <input type="checkbox" value="1" name="CalEventWeekday[4]" [% if $event.caleventweekday[4] == 1 %]checked="checked" [% /if %] /> [% $user->gettext("Do") %]
                                    <input type="checkbox" value="1" name="CalEventWeekday[5]" [% if $event.caleventweekday[5] == 1 %]checked="checked" [% /if %] /> [% $user->gettext("Fr") %]
                                    <input type="checkbox" value="1" name="CalEventWeekday[6]" [% if $event.caleventweekday[6] == 1 %]checked="checked" [% /if %] /> [% $user->gettext("Sa") %]
                                    <input type="checkbox" value="1" name="CalEventWeekday[0]" [% if $event.caleventweekday[0] == 1 %]checked="checked" [% /if %] /> [% $user->gettext("So") %]
                                </div>
                            </div>

                            <div class="form-group row mb-3" id="repeat_form_month">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Wiederholen") %]:
                                </label>
                                <div class="col-lg-9">
                                    <input type="radio" value="0" name="CalEventRepeatMonth" [% if $event.caleventrepeatmonth != 1 %]checked="checked" [% /if %]/> [% $user->gettext("Tag des Monats") %]
                                    &nbsp;
                                    <input type="radio" value="1" name="CalEventRepeatMonth" [% if $event.caleventrepeatmonth == 1 %]checked="checked" [% /if %] /> [% $user->gettext("Wochentag") %]
                                </div>
                            </div>

                            <div class="form-group row mb-3">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Bereich endet") %]:
                                </label>
                                <div class="col-lg-9">
                                    &nbsp;&nbsp;&nbsp;
                                    <input type="radio" value="0" name="CalEventRepeatEnd" [% if $event.caleventrepeatend != 1 %]checked="checked" [% /if %]/> [% $user->gettext("Nie") %]<br />
                                    &nbsp;&nbsp;&nbsp;
                                    <input type="radio" value="1" name="CalEventRepeatEnd" [% if $event.caleventrepeatend == 1 %]checked="checked" [% /if %]/> [% $user->gettext("Bis") %]
                                    &nbsp;&nbsp;
                                    <input type="text" value="[% $event.caleventrepeatenddate %]" name="CalEventRepeatEndDate" class="form-control datepicker" />

                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="card panel-info shadow-sm rounded">
                        <div class="card-header">
                            <span class="fcs-card-title h3">
                                [%$user->gettext('Gäste')%]:
                            </span>
                        </div>
                        <div class="card-body">
                            <div class="form-group row mb-3">
                                <label class="control-label col-lg-3">
                                    [% $user->gettext("Gäste") %]:
                                </label>
                                <div class="col-lg-9">
                                    <select size="5" name="CalEventGroups[]" multiple="multiple" class="form-control multiple2">
                                        [% html_options options=$Groups selected=$event.caleventgroups %]
                                    </select>

                                </div>


                            </div>
                            <div class="form-group row mb-3">
                                <div class="col-lg-12">
                                    <textarea name="CalEventGuests"  rows="8" class="form-control" placeholder="[% $user->gettext('Bitte trennen Sie mehrere Benutzer durch Kommas.') %]">[% $event.caleventguests %]</textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

<script>
    show_cal_repeat("[% $event.caleventrepeatmode %]");

    $(document).ready(function () {

        $(".dialog").fancybox({
            maxWidth: 800,
            maxHeight: 600,
            closeClick: false
        });

        $(".datepicker").datepicker();


        $(".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>',
    },
            checkAllText: '[% $user->gettext("Alle") %]',
            uncheckAllText: '[% $user->gettext("Keine") %]',
            noneSelectedText: '[% $user->gettext("Wählen Sie") %]',
            selectedText: '# [% $user->gettext("gewählt") %]',
            selectedList: 1,
            header: false,
            multiple: false
        });

        $(".multiple2").multiselect({
            buttonClass: 'form-select',
    templates: {
        button: '<button type="button" class="multiselect dropdown-toggle" data-bs-toggle="dropdown"><span class="multiselect-selected-text"></span></button>',
    },
            checkAllText: '[% $user->gettext("Alle") %]',
            uncheckAllText: '[% $user->gettext("Keine") %]',
            noneSelectedText: '[% $user->gettext("Wählen Sie") %]',
            selectedText: '# [% $user->gettext("gewählt") %]',
            selectedList: 1,
            header: true,
            multiple: true
        });

        $(".datetimepicker").datetimepicker({
            currentText: 'Jetzt',
            closeText: 'OK',
            timeText: 'Zeit',
            hourText: 'Stunde'
        });
        $(".timepicker").timepicker({
            currentText: 'Jetzt',
            closeText: 'OK',
            timeText: 'Zeit',
            hourText: 'Stunde'
        });

    });

</script>
