<div class="modal-header">
  <button type="button" class="pull-right btn btn-danger btn-sm" data-dismiss="modal" aria-hidden="true"><i class="fa fa-close"></i></button>
  <h4 class="modal-title">{{ text_form }}</h4>
</div>
<div class="modal-body">
  <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-url-alias" class="form-horizontal">	
	<div class="form-group required">
      <label class="col-sm-2 control-label" for="input-query"><span data-toggle="tooltip" title="{{ help_query }}">{{ entry_query }}</span></label>
      <div class="col-sm-10">
        <input type="text" name="query" value="{{ query }}" placeholder="{{ entry_query }}" id="input-query" class="form-control" />         
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label" for="input-keyword"><span data-toggle="tooltip" title="{{ help_keyword }}">{{ entry_keyword }}</span></label>
      <div class="col-sm-10">
        <input type="text" name="keyword" value="{{ keyword }}" placeholder="{{ entry_keyword }}" id="input-keyword" class="form-control" />          
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label" for="input-store">{{ entry_store }}</label>
      <div class="col-sm-10">
        <select name="store_id" id="input-store" class="form-control">
          {% for store in stores %}
            {% if store.store_id == store_id %}
              <option value="{{ store.store_id }}" selected="selected">{{ store.name }}</option>
              {% else %}
              <option value="{{ store.store_id }}">{{ store.name }}</option>
            {% endif %}
          {% endfor %}
        </select>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label" for="input-language">{{ entry_language }}</label>
      <div class="col-sm-10">
        <select name="language_id" id="input-language" class="form-control">
          {% for language in languages %}
            {% if language.language_id == language_id %}
              <option value="{{ language.language_id }}" selected="selected">{{ language.name }}</option>
              {% else %}
              <option value="{{ language.language_id }}">{{ language.name }}</option>
            {% endif %}
          {% endfor %}
        </select>
      </div>
    </div>
  </form>
</div>
<div class="modal-footer">
  <div class="text-center"><a data-form="form-url-alias" class="button-save btn btn-primary"><i class="fa fa-save"></i> {{ button_save }}</a></div>
</div>
<script type="text/javascript"><!--
$(".button-save").on('click', function(){
	$.ajax({
		url: $('#' + $(this).data('form')).attr('action'),
		type: 'post',
		dataType: 'json',
		data: $('#' + $(this).data('form') + ' input[type=\'text\'], #' + $(this).data('form') + ' select'),
		success: function(json) {
			if (json['error']) {
				$('#form-url-alias').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
				
				$('.alert-danger').delay(1500).fadeOut(500);
			}
			
			if (json['success']) {
				$('#form-url-alias').before('<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> ' + json['success'] + '</div>');			
									
				setTimeout(function(){			
					location.reload(true);
				}, 500);
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
});   
//--></script>