{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right"><a href="{{ return }}" data-toggle="tooltip" title="{{ button_back }}" class="btn btn-default"><i class="fa fa-reply"></i></a></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 validation == true %}
      {% if image_import > 0 %}
      <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ image_import }} {{ text_import_images_msg1 }} <a href="{{ image_import_link }}" target="_blank">{{ text_import_images_msg2 }}</a> {{ text_import_images_msg3 }}</div>
      {% endif %}
      {% if maintenance == 1 %}
      <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_maintenance }} </div>
      {% endif %}
      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title"><i class="fa fa-list"></i> {{ heading_title }}</h3>
        </div>
        <div class="panel-body">
          <p>{{ text_sync_import_line1 }}</p>
          <p>{{ text_sync_import_line3 }}</p>
          <div class="attention">{{ text_sync_server_size }} <strong>{{ ini_setting_post_max_size }}</strong> </div>
          <div class="attention">{{ text_sync_memory_size }} <strong>{{ ini_setting_memory_limit }}</strong> </div>
          <form id="form-ebay-import" class="form-horizontal">
            <div class="form-group">
              <label class="col-sm-2 control-label"><span data-toggle="tooltip" title="{{ help_import_categories }}">{{ entry_import_categories }}</span></label>
              <div class="col-sm-10">
                <input type="checkbox" name="import_categories" id="import_categories" value="1" />
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label"><span data-toggle="tooltip" title="{{ help_import_description }}">{{ entry_import_description }}</span></label>
              <div class="col-sm-10">
                <input type="checkbox" name="import_description" id="import-description" value="1" />
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label"><span data-toggle="tooltip" title="{{ help_import_item_advanced }}">{{ entry_import_item_advanced }}</span></label>
              <div class="col-sm-10">
                <input type="checkbox" name="import_advanced" id="import_advanced" value="1" />
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label" for="button-import">{{ entry_import }}</label>
              <div class="col-sm-10"> <a class="btn btn-primary" id="button-import">{{ button_import }}</a> </div>
            </div>
          </form>
        </div>
      </div>
    {% else %}
      <div class="alert alert-danger alert-dismissible"> <i class="fa fa-exclamation-circle"></i> {{ error_validation }} </div>
    {% endif %}
  </div>
</div>
<script type="text/javascript"><!--
  $('#button-import').bind('click', function() {
    var answer = confirm("{{ text_import_confirm }}");

    if (answer) {
      var note_import = 0;
      var import_description = $('#import-description:checked').val();
      var import_advanced = $('#import_advanced:checked').val();
      var import_categories = $('#import_categories:checked').val();
      if (import_description == undefined){ import_description = 0; }else{ import_description = 1; }
      if (import_advanced == undefined){ import_advanced = 0; }else{ import_advanced = 1; }
      if (import_categories == undefined){ import_categories = 0; }else{ import_categories = 1; }

      $.ajax({
        url: 'index.php?route=extension/openbay/ebay/importItems&user_token={{ user_token }}&desc='+import_description+'&note='+note_import+'&advanced='+import_advanced+'&categories='+import_categories,
        beforeSend: function(){
          $('#button-import').empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled');
        },
        type: 'post',
        dataType: 'json',
        success: function(json) {
          $('#button-import').empty().removeClass('btn-primary').addClass('btn-success').html('{{ button_complete }}');
          alert('{{ text_import_notify }}');
        },
        error: function (xhr, ajaxOptions, thrownError) {
          $('#button-import').empty().removeClass('btn-primary').addClass('btn-danger').html('{{ error_import }}').removeAttr('disabled');
          if (xhr.status != 0) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); }
        }
      });
    } else {
      return 0;
    }
  });
//--></script>
{{ footer }}
