<style>
    .ui-widget {
        z-index: 8500 !important;
    }    
</style>

<!-- ###SEARCHFORM### -->
<form action="index.php?module=project" method="post" name="hm" id="hm" enctype="multipart/form-data" class="form-horizontal form-label-left">

    <input type="hidden" name="search[pos]" id="pos" value="[% $pos %]" />
    <input type="hidden" name="search[orderby]" id="sort" value="[% $sort %]" />
    <input type="hidden" name="search[ordering]" id="sortorder" value="[% $ordering %]" />

    <div class="card panel-info shadow-sm rounded">
        <div class="card-header">
            <h3 class="card-title">[% $user->gettext('Suchformular') %]</h3>
        </div>
        <div class="card-body">

            <div class="form-group row mb-3">
                <label class="col-lg-4 control-label">[% $user->gettext('Name') %]</label>
                <div class="col-lg-8">
                    <input type="text" name="search[projectdescr]" class="form-control" value="[% $search.projectdescr %]" />
                </div>
            </div>
            <div class="form-group row mb-3">
                <div class="col-lg-4">
                    <select name="search[DateField]" class="form-control notClear">
                        <option value="CreateDate"[% if $search.DateField == 'CreateDate' %] selected="selected"[% /if %]>[% $user->gettext("Erstellt") %]</option>
                        <option value="UpdateDate"[% if $search.DateField == 'UpdateDate' %] selected="selected"[% /if %]>[% $user->gettext("Letzte &Auml;nderung") %]</option>
                        <option value="StartDate"[% if $search.DateField == 'StartDate' %] selected="selected"[% /if %]>[% $user->gettext("Projektstart") %]</option>
                        <option value="EndDate"[% if $search.DateField == 'EndDate' %] selected="selected"[% /if %]>[% $user->gettext("Projektende") %]</option>
                    </select>
                </div>
                <div class="col-lg-4"><input type="text" maxlength="10" name="search[DateFrom]" id="DateFrom" placeholder="[% $user->gettext('von') %]" value="[% $search.DateFrom %]" class="form-control datepicker"  /></div>
                <div class="col-lg-4"><input type="text" maxlength="10" name="search[DateTo]" id="DateTo" placeholder="[% $user->gettext('bis') %]" value="[% $search.DateTo %]" class="form-control datepicker"  /></div>
            </div>
            <div class="form-group row mb-3">
                <label class="col-lg-4 control-label">[% $user->gettext('Projekttyp') %]</label>
                <div class="col-lg-8">
                    <select size="1" name="search[ProjectTypeID]" class="form-control">
                        <option value="0"[% if 0 <= $search.ProjectTypeID %] selected="selected"[% /if %]>[% $user->gettext('Keine Auswahl') %]</option>
                        [% html_options options=$projecttypes selected=$search.ProjectTypeID %]
                    </select>
                </div>
            </div>

            <div class="form-group row mb-3">
                <label class="col-lg-4 control-label">[% $user->gettext('Ansprechpartner') %]</label>
                <div class="col-lg-8">
                    <select size="1" name="search[EmployeeID]" class="form-control">
                        <option value="0"[% if 0 <= $search.EmployeeID %] selected="selected"[% /if %]>[% $user->gettext('Keine Auswahl') %]</option>
                        [% html_options options=$employees selected=$search.EmployeeID %]
                    </select>
                </div>
            </div>

            <div class="form-group row mb-3">
                <label class="col-lg-4 control-label">[% $user->gettext('Firma') %]</label>
                <div class="col-lg-8">
                    <select size="1" name="search[Company]" class="form-control">
                        <option value=""[% if "" == $search.Company %] selected="selected"[% /if %]>[% $user->gettext('Keine Auswahl') %]</option>
                        [% html_options options=$companies selected=$search.Company %]
                    </select>
                </div>
            </div>
            [% if $ref_level1_name != '' %]
                <div class="form-group row mb-3">
                    <label class="col-lg-4 control-label">[% $user->gettext($ref_level1_name) %]</label>
                    <div class="col-lg-8">
                        <select size="1" name="search[RefLevel1]" class="form-control">
                            <option value=""[% if $search.RefLevel1|trim == "" %] selected="selected"[% /if %]>[% $user->gettext('Keine Auswahl') %]</option>
                            [% html_options options=$ref_level1 selected=$search.RefLevel1 %]
                        </select>
                    </div>
                </div>
            [% /if %]

            <div class="form-group row mb-3">
                <label class="col-lg-4 control-label">[% $user->gettext('Einträge pro Seite') %]</label>
                <div class="col-lg-8">
                    <select size="1" name="search[EntriesPerPage]" class="form-control" id="EntriesPerPage" onchange="submitForm();">
                        <option value="1" [% if $entries_per_page == 1 %]selected="selected"[% /if %]>1</option>
                        <option value="5" [% if $entries_per_page == 5 %]selected="selected"[% /if %]>5</option>
                        <option value="10" [% if $entries_per_page == 10 %]selected="selected"[% /if %]>10</option>
                        <option value="20" [% if $entries_per_page == 20 %]selected="selected"[% /if %]>20</option>
                        <option value="50" [% if $entries_per_page == 50 %]selected="selected"[% /if %]>50</option>
                        <option value="100" [% if $entries_per_page == 100 %]selected="selected"[% /if %]>100</option>
                    </select>
                </div>
            </div>

            <div class="form-group row mb-3">
                <div class="col-lg-12">
                    <label> [% $user->gettext('Nur aktive Projekte anzeigen') %] <input type="checkbox" id="justActive" name="search[Active]" value="1" [% if $search.Active == 1 %]checked="checked"[% /if %]/></label>
                </div>
            </div>

            <input type="submit" value="[% $user->gettext('Suchen') %]" class="btn btn-outline-primary"  />
            
            <span class="btn btn-outline-primary" id="clearForm">[% $user->gettext('Zurücksetzen') %]</span>
            

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

<script>

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

    function keyEvent(event)
    {
        if (event.keyCode == 13)
            submitForm();
    }
    
    $('#clearForm').on('click', function(){
        $(':input').not(' :submit, .notClear').val('');
        $('option').not('.notClear').attr('selected', false);
        $('#justActive').attr('checked', false);
        $('#EntriesPerPage').val('10');
    })

</script>
<!-- ###SEARCHFORM### -->