<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_stock }}</h4>
</div>
<div class="modal-body">
  <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-product-stock" class="form-horizontal">
	<div class="form-group">
      <label class="col-sm-3 control-label" for="input-minimum"><span data-toggle="tooltip" title="{{ help_minimum }}">{{ entry_minimum }}</span></label>
      <div class="col-sm-9">
        <input type="text" name="minimum" value="{{ minimum }}" placeholder="{{ entry_minimum }}" id="input-minimum" class="form-control" />
      </div>
    </div>
	<div class="form-group">
      <label class="col-sm-3 control-label" for="input-subtract">{{ entry_subtract }}</label>
      <div class="col-sm-9">
        <select name="subtract" id="input-subtract" class="form-control">
          {% if subtract %}
			<option value="1" selected="selected">{{ text_yes }}</option>
            <option value="0">{{ text_no }}</option>
            {% else %}
			<option value="1">{{ text_yes }}</option>
			<option value="0" selected="selected">{{ text_no }}</option>
          {% endif %}
        </select>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label" for="input-stock-status"><span data-toggle="tooltip" title="{{ help_stock_status }}">{{ entry_stock_status }}</span></label>
      <div class="col-sm-9">
        <select name="stock_status_id" id="input-stock-status" class="form-control">
          {% for stock_status in stock_statuses %}
            {% if stock_status.stock_status_id == stock_status_id %}
			  <option value="{{ stock_status.stock_status_id }}" selected="selected">{{ stock_status.name }}</option>
			  {% else %}
			  <option value="{{ stock_status.stock_status_id }}">{{ stock_status.name }}</option>
			{% endif %}
		  {% endfor %}
        </select>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">{{ entry_shipping }}</label>
      <div class="col-sm-9">
        <label class="radio-inline"> 
		  {% if shipping %}
            <input type="radio" name="shipping" value="1" checked="checked" />
            {{ text_yes }}
            {% else %}
            <input type="radio" name="shipping" value="1" />
            {{ text_yes }}
          {% endif %}
		</label>
        <label class="radio-inline">
		  {% if not shipping %}
            <input type="radio" name="shipping" value="0" checked="checked" />
            {{ text_no }}
            {% else %}
            <input type="radio" name="shipping" value="0" />
            {{ text_no }}
          {% endif %}
		</label>
      </div>
    </div>
  </form>
</div>
<div class="modal-footer">
  <div class="text-center"><a data-form="form-product-stock" 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') + ' input[type=\'radio\']:checked, #' + $(this).data('form') + ' select'),
		success: function(json) {
			if (json['error']) {
				$('#form-product-stock').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-stock').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>