
<style>
    .SimpleField {
        width: auto;
        display: inline-block;
        padding: 0.5em 0.5em 0.5em 0;
        margin-right: 0.5em;
        border-radius: 5px;
    }

    .SimpleField2 {
        width: auto;
        display: inline-block;
        padding: 0.5em 0.5em 0.5em 0;
        margin-right: 0.5em;
        border-radius: 5px;
    }

    .SimpleField:hover {
        /*    background-color: lightgray;*/
        cursor: pointer;
    }
    .removeSField {
        /*margin-left: 1em;*/
        /*line-height: 2em;*/
        position:relative;
        left: -9px;
        top: -8px;
        z-index:999;
        visibility:hidden
    }

    .removeSField2 {
        /*margin-left: 0.5em;*/
        /*line-height: 2em;*/
        position:relative;
        left: 0.5em;
        top: -8px;
        z-index:999;
        visibility:hidden
    }

    .btn-circle {
  width: 15px;
  padding-top:2px;
  height: 15px;
  text-align: center;
  font-size: 0.8em;

    background-color: #ccc !important;
  border-radius: 15px;
}
    .SimpleField:hover .removeSField {
         visibility: visible;
    }

    .SimpleField:hover .removeSField2 {
         visibility: visible;
    }

    .filterform{
        max-width: 200px;
    }

    .ui-datepicker{
        z-index: 9999999 !important;
    }


</style>

<!-- Latest compiled and minified CSS -->

<link rel="stylesheet" href="includes/js/bootstrap-select-1.12.4/dist/css/bootstrap-select.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="includes/js/bootstrap-select-1.12.4/dist/js/bootstrap-select.min.js"></script>

<!-- (Optional) Latest compiled and minified JavaScript translation files -->
<script src="includes/js/bootstrap-select-1.12.4/dist/js/i18n/defaults-[% if $user->language_type == "de" %]de_DE[% else %]en_US[% /if %].min.js"></script>





    <div class="row" id="SearchForm">
        <div class="col-12" id="additionalFilterField">
            <input type="hidden" name="pos" value="0" id="pos" />

            <input type="hidden" name="FilterNames" id="FilterNames" value="" />
            <input type="hidden" name="ContactID" id="" value="[% $contactid %]" />
            <input type="hidden" name="EntriesPerPage" value="20" />
            <input type="hidden" name="listtype" value="[% $listtype %]" />

              <input type="hidden" name="SortingTable" id="sort" value="[% $sort %]" />
              <input type="hidden" name="SortOrderTable" id="sortorder" value="[% $sortorder %]" />


            <div class="SimpleField  visible bg-default" id="Search_Filter"  style="display: inline-block">
                <div class="btn-group">
                    <input type="text" data-style="btn-info" class="form-control" id="filter" name="Filter" value="[% $filter %]" placeholder="[% $user->gettext('Volltext') %]" title="[% $user->gettext('Volltextsuche') %]" size="20" onkeyup="nkeyEvent(event)" />
                </div>
            </div>

            <div class="SimpleField  visible bg-default" id="Search_TicketID" style="display: inline-block">
                <div class="btn-group">
                    <input type="text" data-style="btn-info" class="form-control" id="TicketID" name="TicketID" value="[% $TicketID %]" placeholder="#" style = "width: 100px;" title="[% $user->gettext('Ticketnummer') %]" onkeyup="nkeyEvent(event)" />
                </div>
            </div>

                    <div class="SimpleField bg-default" id="Search_StatusID">
                        <select data-style="btn-outline-secondary" name="StatusID[]" id="StatusID"  multiple class="selectpicker" data-live-search="true" data-selected-text-format="count>0"
                                data-count-selected-text= "[%$user->gettext('Status')%] ({0} [%$user->gettext('gewählt')%])" data-title="[% $user->gettext('Status wählen') %]" title="[% $user->gettext('Status') %]">

                            <option value="0" [% if !$statusid || $Tools->FCS_InArray(0, $statusid) %]selected="selected" [% /if %]>[% $user->gettext('Nur Aktive') %] ([% $user->gettext('mit OnHold') %])</option>
                            <option value="98" [% if $Tools->FCS_InArray(98, $statusid) %]selected="selected" [% /if %]>[% $user->gettext('Nur Aktive ') %] ([% $user->gettext('ohne OnHold') %])</option>
                            <option value="97" [% if $Tools->FCS_InArray(97, $statusid) %]selected="selected" [% /if %]>[% $user->gettext('Nur Aktive ') %] ([% $user->gettext('ohne OnHold und Erledigt') %])</option>
                            <option value="96" [% if $Tools->FCS_InArray(96, $statusid) %]selected="selected" [% /if %]>[% $user->gettext('Nur Aktive ') %] ([% $user->gettext('mit OnHold, ohne Erledigt') %])</option>
                            <option value="99" [% if $Tools->FCS_InArray(99, $statusid) %]selected="selected" [% /if %]>[% $user->gettext('Alle') %]</option>

                            [% foreach from=$stats item=stat %]
                                [% if $stat.descr %]
                                    <option value="[% $stat.tstatus %]" [% if $Tools->FCS_InArray($stat.tstatus, $statusid) %]selected="selected" [% /if %]>[% $stat.descr %] ([% $stat.anzahl %])</option>
                                [% /if %]
                            [% /foreach %]
                        </select>

                        [% if $hmcompany == 'BHS BAD HOMBURGER SERVICEGESELLSCHAFT' %]
                            <br />
                            <label for="WithoutStatus" title="Nur Tickets anzeigen, welche NICHT den gewählten Prioritäten zugeordnet sind.">Auswahl negieren<input type="checkbox" value="1" id="WithoutStatus" class="reset-checkbox" name="WithoutStatus" [% if $SearchArray.WithoutStatus %]checked="checked"[% /if %]></label>
                            [% /if %]
                    </div>
                    <script>

                        function disableDropdownExcept(select, selectedValue) {
                            var selectobject;
                            selectobject = document.getElementById(select).getElementsByTagName("option");
                            for (z = 0; z < selectobject.length; z++) {
                                if (selectobject[z].value != selectedValue) {
                                    selectobject[z].removeAttribute("selected");
                                    //selectobject[z].checked=false;
                                }
                            }
                            let optArr = [selectedValue];
                            $('#' + select).selectpicker('val', optArr);
                            $('#' + select).selectpicker('refresh');
                        }

                        function disableDropdown(select, selectedValue) {

                            let optArr = $('#' + select).val();
                            for (z = 0; z < selectedValue.length; z++) {
                                if (optArr.indexOf(selectedValue[z]) != -1) {
                                    optArr.splice(optArr.indexOf(selectedValue[z]), 1)
                                }
                            }
                            $('#' + select).selectpicker('val', optArr);
                            $('#' + select).selectpicker('refresh');


                        }

                        function enableDropdownAll(select) {
                            var selectobject;
                            selectobject = document.getElementById(select).getElementsByTagName("option");
                            for (z = 0; z < selectobject.length; z++) {
                                selectobject[z].addAttribute("selected");
                                //selectobject[z].checked=true;
                            }

                        }

                        $("#StatusID").on("changed.bs.select",
                                function (e, clickedIndex, newValue, oldValue) {
                                    var selectedVal = $(this).find('option').eq(clickedIndex).val();
                                    if (newValue) {
                                        if (selectedVal == "0" || selectedVal == "98" || selectedVal == "99") {
                                            disableDropdownExcept("StatusID", selectedVal);
                                        } else {
                                            disableDropdown("StatusID", ["0", "98", "99"]);

                                            //$('#StatusID').selectpicker('val', selectedVal);
                                            $('#StatusID').selectpicker('refresh');
                                        }
                                    } else if (!newValue) {
                                        //enableDropdownAll("StatusID");
                                        /*
                                            if(selectedVal == "-2"){
                                            disableDropdown("TCGroupID", "-2");
                                            $('#optUnChanged').show();

                                            }
                                            if(selectedVal=="-1"){
                                            disableDropdown("TCGroupID", "-1");
                                            $('#optUnChanged').show();
                                            }
                                            */
                                    }
                                });
                    </script>

            <button type="button" id="SubmitbuttonMiniSearch" onclick="reloadPage()" class="btn btn-outline-primary minisearch" > <span class="fa fa-search"></span></button>
        </div>
        </div>

<script type="text/javascript" language="javascript">
<!--


$('input[type=text]').keydown(function (e) {

  if (e.keyCode == 13) {
      reloadPage();
  }
});
/*
$('.btn-date').focusout(function() {
  reloadPage();
});
*/

function reloadPage(){
    $.ajax({
        type: "POST",
        url: "index.php?module=ticketlist&event=ContactTicketTableBody",
        data: $("#hm3").serializeArray(),
    })
    .done(function( content ) {

            $('#TBody').hide().html(content).fadeIn();
            $( "#cntTickets" ).load("index.php?module=ticketlist&event=getTicketCount" );
            doAjaxTooltip();
            initTicketPopovers();

    });

}
//-->
</script>
