<div class="show_filter">
  <button id="filter-toggle" type="button" class="btn btn-outline-secondary btn-xs" data-toggle="collapse" data-target="#filterdiv">
    Hide/Show filter
  </button>
  <button id="filter_reset" class="btn btn-outline-danger btn-xs" type="submit"  onclick="reset_filters()">
    Clear filter
  </button>
  <button id="filter_top" class="btn btn-outline-warning btn-xs" type="submit" onclick="if(validateDates()){getFormData()}">
    Filter
  </button>
  <button id="filter_off" class="btn btn-outline-success btn-xs" type="submit">
    No filter active
  </button>
  <button id="filter_on" class="btn btn-success btn-xs d-none" type="submit">
    Filter active
  </button>
</div>


<div id="filterdiv" class="collapse">

  <form method="POST" onsubmit="if(validateDates()){getFormData()};return false" id="filter">
    <div class="card">
      <div class="card-body">
        <div class="row">
          <div class="col-md-1" id="labelTime">
            Time
          </div>
          <div class="col-md-10">
            <div class="input-group">
              <select class="form-control" onChange="timeSelectDisable()" name="timeSelect" id="timeSelect">
                <option value="all">All</option>
                <option value="from">From</option>
                <option value="until">Until</option>
                <option value="between">Between</option>
                <option value="outside">Not During</option>
              </select>
              <input class="form-control" type="date" placeholder="Start date" name="startDate" id="startDate" readOnly Title="Date in dd/mm/yyyy or dd/mm/yy format, using / or -" pattern="^(?:(?:31(-|\/)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(-|\/)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(-|\/)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(-|\/)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$"></input>
              <input class="form-control" type="date" placeholder="End date" name="endDate" id="endDate" readOnly Title="Date in dd/mm/yyyy or dd/mm/yy format, using / or -" pattern="^(?:(?:31(-|\/)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(-|\/)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(-|\/)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(-|\/)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$"></input>
              <select class="form-control" name="timeTypeSelect" id="timeTypeSelect" readOnly>
                <option value="modified">Last Major Update</option>
                <option value="published">Published</option>
                <option value="lastModified">Last Update</option>
              </select>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-md-1" id="labelCVSS">
            CVSS
          </div>
          <div class="col-md-5">
            <div class="input-group">
              <select class="form-control" name="cvssVersion" id="cvssVersion">
                <option value="V2">V2</option>
                <option value="V3">V3</option>
                <option value="V4">V4</option>
              </select>
              <select class="form-control" name="cvssSelect" id="cvssSelect" onChange="cvssSelectDisable()">
                <option value="all">All</option>
                <option value="above">Above</option>
                <option value="equals">Equals</option>
                <option value="below">Below</option>
              </select>
              <input class="form-control" name="cvss" id="cvss" type="number" readOnly min="0" max="10" step="0.1" value="0"></input>
            </div>
          </div>
          <div class="col-md-1" id="labelRejected">
            Rejected
          </div>
          <div class="col-md-3">
            <select class="form-control" name="rejectedSelect" id="rejectedSelect">
              <option value="hide">Hide</option>
              <option value="show">Show</option>
            </select>
          </div>
        </div>
        {% if filters is defined %}
        {% for filterSet in filters %}
        {% if not (filterSet['auth'] and not current_user.is_authenticated()) %}
        <div class="row">
          <div class="col-md-1">
            {{filterSet['id']}}
          </div>
          <div class="col-md-11">
            {% for filter_ in filterSet['filters'] %}
            {% if   filter_['type'] == "select" %}
            <select class="form-control" name="plug_{{filter_['id']}}" id="plug_{{filter_['id']}}">
              {% for entry in filter_['values'] %} <option value="{{entry['id']}}">{{entry['text']}}</option> {% endfor %}
            </select>
            {% elif filter_['type'] == "text" or filter_['type'] == "checkbox"%}
            {% if 'label' in filter_ %}<span>{{filter_['label']}}</span>{% endif %}
            <input class="form-control" name="plug_{{filter_['id']}}" id="plug_{{filter_['id']}}" type="{{filter_['type']}}"></input>
            {% endif %}
            {% endfor %}
          </div>
        </div>
        {% endif %}
        {% endfor %}
        {% endif %}
        <div class="row">
          <div class="col-md-1">
            <button id="filter_send" class="btn btn-outline-warning button_filter" type="submit" value="Search">Filter </button>
          </div>
          <div class="col-md-10">
            <p id="filter_warning"></p>
          </div>
        </div>
      </div>
    </div>
  </form>

</div>
