{{ header }}
<div class="container">
  <header>
    <div class="row">
      <div class="col-sm-6">
        <h1 class="pull-left">1<small>/2</small></h1>
        <h3>{{ heading_title }}<br>
          <small>{{ text_upgrade }}</small></h3>
      </div>
      <div class="col-sm-6">
        <div id="logo" class="pull-right hidden-xs"><img src="view/image/logo.png" alt="OpenCart" title="OpenCart" /></div>
      </div>
    </div>
  </header>
  <div class="row">
    <div class="col-sm-9">
      <h3>{{ text_server }}</h3>
      <fieldset>
        <ol>
          <li>{{ text_error }}</li>
          <li>{{ text_clear }}</li>
          <li>{{ text_admin }}</li>
          <li>{{ text_user }}</li>
          <li>{{ text_setting }}</li>
          <li>{{ text_store }}</li>
        </ol>
      </fieldset>
      <h3>{{ text_steps }}</h3>
      <fieldset>
        <div class="form-group">
          {% if false %}
          <label class="col-sm-2 control-label">{{ entry_progress }}</label>
          <div class="col-sm-10">
            <div class="progress">
              <div id="progress-bar" class="progress-bar" style="width: 0%;"></div>
            </div>
            <div id="progress-text"></div>
          </div>
          {% else %}
            <label class="col-sm-12 control-label">升级功能暂不可用，如需重新，请先清空 config.php 文件。</label>
          {% endif %}
        </div>
      </fieldset>
      {% if false %}
      <div class="buttons">
        <div class="text-right">
          <input type="submit" value="{{ button_continue }}" data-loading="{ text_loading }}" id="button-continue" class="btn btn-primary" />
        </div>
      </div>
      {% endif %}
    </div>
    <div class="col-sm-3">{{ column_left }}</div>
  </div>
  <script type="text/javascript"><!--
var step = 0;

$('#button-continue').on('click', function() {
	$('#progress-bar').addClass('progress-bar-success').css('width', '0%').removeClass('progress-bar-danger');
	$('#progress-text').html('');
	$('#button-continue').button('loading');

	start('index.php?route=upgrade/upgrade/next');
});

function start(url) {
	setTimeout(function(){
		$.ajax({
			url: url,
			type: 'post',
			dataType: 'json',
			success: function(json) {
				if (json['error']) {
					$('#progress-bar').addClass('progress-bar-danger');
					$('#progress-text').html('<div class="text-danger">' + json['error'] + '</div>');

					$('#button-continue').prop('disabled', false);
					$('#button-continue').button('reset');
				}

				if (json['success']) {
					$('#progress-text').html('<span class="text-success">' + json['success'] + '</span>');
					$('#progress-bar').css('width', ((step / {{ total }}) * 100) + '%');
				}

				if (json['next']) {
					start(json['next']);
				} else if (!json['error']) {
					$('#button-continue').replaceWith('<a href="{{ store }}" class="btn btn-primary">{{ button_continue }}</a>');
					$('#button-continue').button('reset');
				}

				step++;
			},
			error: function(xhr, ajaxOptions, thrownError) {
				$('#progress-bar').addClass('progress-bar-danger');
				$('#progress-text').html('<div class="text-danger">' + (thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText) + '</div>');
				$('#button-continue').button('reset');

			}
		});
	}, 1000);
}
//--></script></div>
{{ footer }}