{{ header }}{{ column_left }}
<!-- Content Wrapper. Contains page content -->
<div id="content" class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <div>
      <div class="pull-right">
        <a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default" id="btn-cancel"><i class="fa fa-reply"></i> {{ button_cancel }}</a>
      </div>
      <h1>
        {{ heading_title }}
      </h1>
    </div>
    <div class="row">
      <div class="col-sm-12">
        <ul class="breadcrumb">
          {% for breadcrumb in breadcrumbs %}
          <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
          {% endfor %}
        </ul>
      </div>
    </div>
  </section>

  <!-- Main content -->
  <section class="content">

    <!-- Default box -->
    <div class="box">
      <div class="box-header with-border">
        <h3 class="box-title">{{ text_edit }}</h3>

        <div class="box-tools pull-right">
          <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="{{ text_collapse }}">
            <i class="fa fa-minus"></i></button>
        </div>
      </div>
      <div class="box-body">
        <div id="page-listing">
          {% if error_warning %}
          <div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}</div>
          {% endif %}
          <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form" class="form-horizontal">
            <input type="hidden" name="etsy_item_id" value="{{ etsy_item_id }}" />
            <input type="hidden" name="product_id" value="{{ product_id }}"/>
            <!-- Custom Tabs -->
            <div class="nav-tabs-custom">
              <ul class="nav nav-tabs">
                <li class="active"><a href="#tab-listing-general" data-toggle="tab">{{ tab_general }}</a></li>
              </ul>
              <div class="tab-content">
                <div id="tab-listing-general" class="tab-pane active">
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-title">{{ entry_title }}</label>
                    <div class="col-sm-10">
                      <input type="text" name="title" value="{{ listing.title }}" placeholder="{{ entry_title }}" id="input-title" class="form-control" />
                    </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-description">{{ entry_description }}</label>
                    <div class="col-sm-10">
                      <textarea name="description" placeholder="{{ entry_description }}" id="input-description" class="form-control">{{ listing.description }}</textarea>
                    </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-price">{{ entry_price }}</label>
                    <div class="col-sm-10">
                      <input type="text" name="price" value="{{ listing.price }}" placeholder="{{ entry_price }}" id="input-price" class="form-control" />
                    </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-state">{{ entry_state }}</label>
                    <div class="col-sm-10">
                      <select name="state" id="input-state" class="form-control">
                        {% for state in setting.state %}
                        <option value="{{ state }}" {% if listing.state == state %} selected{% endif %}>{{ state }}</option>
                        {% endfor %}
                      </select>
                    </div>
                  </div>
                </div>
                <div class="well">
                  <div class="row">
                    <div class="col-sm-12 text-right">
                      <a data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary" id="button-save"><i class="fa fa-save"></i></a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <!-- /.custom tabs -->
          </form>
        </div>
        <div id="page-listing-success" style="display:none;">
          <div class="well">
            <div class="row">
              <div class="col-sm-12">
                <h3>{{ text_updated }}</h3>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- /.box-body -->
    </div>
    <!-- /.box -->

  </section>
  <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script type="text/javascript"><!--
  var image_count = 1;

  $('#button-save').bind('click', function() {
    $.ajax({
      url: 'index.php?route=extension/openbay/etsy_product/editsubmit&user_token={{ user_token }}',
      beforeSend: function(){
        $('#button-submit').empty().html('<i class="fa fa-cog fa-lg fa-spin"></i>').attr('disabled','disabled');
      },
      type: 'post',
      data: $("#form").serialize(),
      dataType: 'json',
      success: function(json) {
        if (json.error) {
          if (json.code) {
            alert(json.error);
          } else {
            $.each(json.error, function( k, v ) {
              alert(v);
            });
          }
          $('#button-submit').empty().html('<span>{{ button_submit }}</span>').removeAttr('disabled');
        } else {
          if (json.listing_id) {
            $('#page-listing').hide();
            $('#page-listing-success').fadeIn();
            $('#button-submit').empty().html('<span>{{ button_submit }}</span>').removeAttr('disabled');
          }
        }
      },
      error: function (xhr, ajaxOptions, thrownError) {
        if (xhr.status != 0) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); }
        $('#button-submit').empty().html('<span>{{ button_submit }}</span>').removeAttr('disabled');
      }
    });
  });

//--></script>
{{ footer }}
