<%# locals: none %>

<div class="row">
  <div class="col-md-12">
    <h2><%= _('Run your own filter') %></h2>
    <p><%= _('Use the filters to run organisational usage statistics for a custom date range.') %></p>
    <%= form_for :usage, url: usage_filter_path, remote: true do |f| %>
      <div class="row">
        <div class="col-md-2">
          <div class="form-group">
            <%= f.label :topic, _('Topic') %>
            <%= f.select :topic, [
              [_('Users'), 'users'], [_('Plans'), 'plans']
            ], {}, { class: "form-control" } %>
          </div>
        </div>
        <div class="col-md-2">
          <div class="form-group">
            <%= f.label :start_date, _('Start date') %>
            <%= f.date_field :start_date, class: 'form-control' %>
          </div>
        </div>
        <div class="col-md-2">
          <div class="form-group">
            <%= f.label :end_date, _('End date') %>
            <%= f.date_field :end_date, class: 'form-control' %>
          </div>
        </div>
        <% if current_user.can_super_admin? %>
            <div class="col-md-5">
              <div class="form-group">
                <%= f.label :org_id, _('Organisation') %>
                <%= f.select :org_id, options_from_collection_for_select(Org.all, :id, :name, current_user.org_id), {}, class: 'form-control' %>
              </div>
            </div>
        <% end %>
        <div class="col-md-1">
          <div class="mt-20">
            <%= f.submit _('Go'), class: 'btn btn-default pull-right' %>
          </div>
        </div>
      </div>

    <% end %>
  </div>
</div>

<div class="row">
  <div class="col-md-12">
    <div>
      <div class="row">
        <div id="filter_ranged" class="col-md-3"></div>
        <div id="filter_total" class="col-md-3"></div>
      </div>
    </div>
  </div>
</div>
