<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">{{ product_name }} - {{ text_size }}</h4>
</div>
<div class="modal-body">
  <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-product-size" class="form-horizontal">
    <div class="form-group">
      <label class="col-sm-2 control-label" for="input-length">{{ entry_dimension }}</label>
      <div class="col-sm-10">
        <div class="row">
          <div class="col-sm-4">
            <input type="text" name="length" value="{{ length }}" placeholder="{{ entry_length }}" id="input-length" class="form-control" />
          </div>
          <div class="col-sm-4">
            <input type="text" name="width" value="{{ width }}" placeholder="{{ entry_width }}" id="input-width" class="form-control" />
          </div>
          <div class="col-sm-4">
            <input type="text" name="height" value="{{ height }}" placeholder="{{ entry_height }}" id="input-height" class="form-control" />
          </div>
        </div>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label" for="input-length-class">{{ entry_length_class }}</label>
      <div class="col-sm-10">
        <select name="length_class_id" id="input-length-class" class="form-control">
          {% for length_class in length_classes %}
            {% if length_class.length_class_id == length_class_id %}
			  <option value="{{ length_class.length_class_id }}" selected="selected">{{ length_class.title }}</option>
              {% else %}
			  <option value="{{ length_class.length_class_id }}">{{ length_class.title }}</option>
            {% endif %}
          {% endfor %}
        </select>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label" for="input-weight">{{ entry_weight }}</label>
      <div class="col-sm-10">
        <input type="text" name="weight" value="{{ weight }}" placeholder="{{ entry_weight }}" id="input-weight" class="form-control" />
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-2 control-label" for="input-weight-class">{{ entry_weight_class }}</label>
      <div class="col-sm-10">
        <select name="weight_class_id" id="input-weight-class" class="form-control">
          {% for weight_class in weight_classes %}
            {% if weight_class.weight_class_id == weight_class_id %}
			  <option value="{{ weight_class.weight_class_id }}" selected="selected">{{ weight_class.title }}</option>
			  {% else %}
			  <option value="{{ weight_class.weight_class_id }}">{{ weight_class.title }}</option>
			{% endif %}
          {% endfor %}
        </select>
      </div>
    </div>
  </form>
</div>
<div class="modal-footer">
  <div class="text-center"><a data-form="form-product-size" 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-product-size').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-product-size').before('<div class="alert alert-success"><i class="fa fa-exclamation-circle"></i> ' + json['success'] + '</div>');
			
				setTimeout(function(){
					$('#modal-product-edit').modal('hide');
				}, 1000)
			}
		}
	});
}); 
//--></script>