$(document).ready(function () {
  var token = $('body').data('token');

  $("#js-btn-filter").click(function () {

    url = 'index.php?route=sale/coupon&token=' + token;

    var filter_name = $('input[name=\'filter_name\']').attr('value');

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

    var filter_code = $('input[name=\'filter_code\']').attr('value');

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

    var filter_status = $('input[name=\'filter_status\']:checked').attr('value');

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

    var filter_valido = $('input[name=\'filter_valido\']').attr('checked');

    if (filter_valido) {
      url += '&filter_valido=1';
    }

    location = url;

  });
});
