{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="button" data-toggle="tooltip" title="{{ button_filter }}" onclick="$('#filter-customer').toggleClass('hidden-sm hidden-xs');" class="btn btn-default hidden-md hidden-lg"><i class="fa fa-filter"></i></button></div>
      <h1>{{ heading_title }}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
          <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
      <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
        <button type="button" class="close" data-dismiss="alert">&times;</button>
      </div>
    {% endif %}
    {% if success %}
      <div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> {{ success }}
        <button type="button" class="close" data-dismiss="alert">&times;</button>
      </div>
    {% endif %}
    <div class="row">
      <div id="filter-customer" class="col-md-3 col-md-push-9 col-sm-12 hidden-sm hidden-xs">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-filter"></i> {{ text_filter }}</h3>
          </div>
          <div class="panel-body">
            <div class="form-group">
              <label class="control-label" for="input-email">{{ entry_email }}</label>
              <input type="text" name="filter_email" value="{{ filter_email }}" placeholder="{{ entry_email }}" id="input-email" class="form-control"/>
            </div>
            <div class="form-group">
              <label class="control-label" for="input-action">{{ entry_action }}</label>
              <select name="filter_action" id="input-action" class="form-control">
                <option value=""></option>
                {% if filter_action == 'export' %}
                  <option value="export" selected="selected">{{ text_export }}</option>
                {% else %}
                  <option value="export">{{ text_export }}</option>
                {% endif %}
                {% if filter_action == 'remove' %}
                  <option value="remove" selected="selected">{{ text_remove }}</option>
                {% else %}
                  <option value="remove">{{ text_remove }}</option>
                {% endif %}
              </select>
            </div>
            <div class="form-group">
              <label class="control-label" for="input-status">{{ entry_status }}</label>
              <select name="filter_status" id="input-status" class="form-control">
                <option value=""></option>
                {% if filter_status == '0' %}
                  <option value="0" selected="selected">{{ text_unverified }}</option>
                {% else %}
                  <option value="0">{{ text_unverified }}</option>
                {% endif %}
                {% if filter_status == '1' %}
                  <option value="1" selected="selected">{{ text_pending }}</option>
                {% else %}
                  <option value="1">{{ text_pending }}</option>
                {% endif %}
                {% if filter_status == '2' %}
                  <option value="2" selected="selected">{{ text_processing }}</option>
                {% else %}
                  <option value="2">{{ text_processing }}</option>
                {% endif %}
                {% if filter_status == '3' %}
                  <option value="3" selected="selected">{{ text_complete }}</option>
                {% else %}
                  <option value="3">{{ text_complete }}</option>
                {% endif %}
                {% if filter_status == '-1' %}
                  <option value="-1" selected="selected">{{ text_denied }}</option>
                {% else %}
                  <option value="-1">{{ text_denied }}</option>
                {% endif %}
              </select>
            </div>
            <div class="form-group">
              <label class="control-label" for="input-date-from">{{ entry_date_from }}</label>
              <div class="input-group date">
                <input type="text" name="filter_date_from" value="{{ filter_date_from }}" placeholder="{{ entry_date_from }}" data-date-format="YYYY-MM-DD" id="input-date-from" class="form-control"/>
                <span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span>
              </div>
            </div>
            <div class="form-group">
              <label class="control-label" for="input-date-to">{{ entry_date_to }}</label>
              <div class="input-group date">
                <input type="text" name="filter_date_to" value="{{ filter_date_to }}" placeholder="{{ entry_date_to }}" data-date-format="YYYY-MM-DD" id="input-date-to" class="form-control"/>
                <span class="input-group-btn"><button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button></span>
              </div>
            </div>
            <div class="form-group text-right">
              <button type="button" id="button-filter" class="btn btn-default"><i class="fa fa-filter"></i> {{ button_filter }}</button>
            </div>
          </div>
        </div>
      </div>
      <div class="col-md-9 col-md-pull-3 col-sm-12">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i> {{ text_list }}</h3>
          </div>
          <div class="panel-body">
            <div class="table-responsive">
              <table class="table table-bordered table-hover">
                <thead>
                <tr>
                  <td class="text-center">{{ column_email }}</td>
                  <td class="text-left">{{ column_request }}</td>
                  <td class="text-left">{{ column_status }}</td>
                  <td class="text-left">{{ column_date_added }}</td>
                  <td class="text-right">{{ column_action }}</td>
                </tr>
                </thead>
                <tbody>
                {% if gdprs %}
                  {% for gdpr in gdpr %}
                    <tr>
                      <td style="width: 1px;" class="text-center"><input type="checkbox" onclick="$('input[name*=\'selected\']').prop('checked', this.checked);"/></td>
                      <td class="text-center">
                        {% if gdpr.edit %}
                          <a href="{{ gdpr.edit }}">{{ gdpr.email }}</a>
                        {% else %}
                          {{ gdpr.email }}
                        {% endif %}
                      </td>
                      <td class="text-left">{{ gdpr.action }}</td>
                      <td class="text-left">
                        {% if gdpr.status == '-1' %}
                          {{ text_denied }}
                        {% elseif gdpr.status == '0' %}
                          {{ text_unverified }}
                        {% elseif gdpr.status == '1' %}
                          {{ text_pending }}
                        {% elseif gdpr.status == '2' %}
                          {{ text_processing }}
                        {% elseif gdpr.status == '3' %}
                          {{ text_complete }}
                        {% endif %}
                      </td>
                      <td class="text-left">{{ customer.date_added }}</td>
                      <td class="text-right">{{ column_action }}</td>
                    </tr>
                  {% endfor %}
                {% else %}
                  <tr>
                    <td class="text-center" colspan="5">{{ text_no_results }}</td>
                  </tr>
                {% endif %}
                </tbody>
              </table>
            </div>
            <div class="row">
              <div class="col-sm-6 text-left">{{ pagination }}</div>
              <div class="col-sm-6 text-right">{{ results }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script type="text/javascript"><!--
      $('#button-filter').on('click', function () {
          url = 'index.php?route=customer/gdpr&user_token={{ user_token }}';

          var filter_email = $('input[name=\'filter_email\']').val();

          if (filter_email) {
              url += '&filter_email=' + encodeURIComponent(filter_email);
          }

          var filter_action = $('select[name=\'filter_action\']').val();

          if (filter_action !== '') {
              url += '&filter_action=' + encodeURIComponent(filter_action);
          }

          var filter_status = $('select[name=\'filter_status\']').val();

          if (filter_status !== '') {
              url += '&filter_status=' + encodeURIComponent(filter_status);
          }

          var filter_date_from = $('input[name=\'filter_date_from\']').val();

          if (filter_date_from) {
              url += '&filter_date_from=' + encodeURIComponent(filter_date_from);
          }

          var filter_date_to = $('input[name=\'filter_date_to\']').val();

          if (filter_date_to) {
              url += '&filter_date_to=' + encodeURIComponent(filter_date_to);
          }

          location = url;
      });
  //--></script>
  <script type="text/javascript"><!--
      $('input[name=\'filter_email\']').autocomplete({
          'source': function (request, response) {
              $.ajax({
                  url: 'index.php?route=customer/customer/autocomplete&user_token={{ user_token }}&filter_email=' + encodeURIComponent(request),
                  dataType: 'json',
                  success: function (json) {
                      response($.map(json, function (item) {
                          return {
                              label: item['email'],
                              value: item['customer_id']
                          }
                      }));
                  }
              });
          },
          'select': function (item) {
              $('input[name=\'filter_email\']').val(item['label']);
          }
      });
  //--></script>
  <script type="text/javascript"><!--
      $('.date').datetimepicker({
          language: '{{ datepicker }}',
          pickTime: false
      });
  //--></script>
</div>
{{ footer }}