{{ 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">
  <div class="panel panel-default">
    <div class="panel-heading">
      <h3 class="panel-title"><i class="fa fa-list"></i> {{ text_pull }}</h3>
    </div>
    <div class="panel-body">
        {% if validation == true %}
        <form id="form-ebay-import" class="form-horizontal">
          <p>{{ text_sync_pull_notice }}</p>
          <div class="form-group">
            <label class="col-sm-2 control-label" for="button-import">{{ entry_pull_orders }}</label>
            <div class="col-sm-10">
              <a class="btn btn-primary" id="button-import">{{ button_pull_orders }}</a>
            </div>
          </div>
        </form>
      {% else %}
        <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_validation }}</div>
      {% endif %}
    </div>
  </div>
</div>
<script type="text/javascript"><!--
  $('#button-import').bind('click', function() {
    $.ajax({
      url: 'index.php?route=extension/openbay/ebay/importOrdersManual&user_token={{ user_token }}',
      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('{{ text_complete }}');
        alert('{{ text_ajax_orders_import }}');
      },
      error: function (xhr, ajaxOptions, thrownError) {
        $('#button-import').empty().removeClass('btn-primary').addClass('btn-danger').html('{{ text_failed }}').removeAttr('disabled');
        if (xhr.status != 0) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); }
      }
    });
  });
//--></script>
{{ footer }}
