<div class="form-group">
	<label class="col-sm-2 control-label" for="input-product-scheme-id">{{ entry_product }}</label>
	<div class="col-sm-10">
		<select name="product_scheme_id" class="form-control" id="input-product-scheme-id">
		{% for _sid, _sname in schemes0 %}
			<option value="{{ _sid }}"{% if _sid == product_scheme_id %} selected="selected"{% endif %}>{{ _sname }}</option>
		{% endfor %}
		</select>
	</div>
</div>
<div style="padding:5px;"><a id="product_affiliates_link" href="javascript:;">{{ text_aff_schemes }}</a>
	{% for _sid, _sname in schemes %}
	<input type="hidden" id="product_affiliates_{{ _sid }}" name="_product_affiliates[{{ _sid }}]" value="" />
	{% endfor %}
</div>
<h4>{{ entry_coupons }}</h4>

<table class="table table-striped">
	<thead>
		<tr>
			<td class="text-right">{{ column_coupon }}</td>
			<td class="text-left">{{ column_mta_scheme }}</td>
		</tr>
	</thead>
	<tbody>
	{% for coupon in coupons %}

		<tr>
			<td class="text-right">{{ coupon['description'] }}</td>
			<td class="text-left">				
					<select name="product_coupon_scheme_id[{{ coupon['id'] }}]" class="form-control">
					{% for _sid, _sname in schemes0 %}
						<option value="{{ _sid }}"{% if _sid == coupon.scheme_id %} selected="selected"{% endif %}>{{ _sname }}</option>
					{% endfor %}
					</select>					
				<div style="padding:5px;"><a id="product_coupon_{{ coupon['id'] }}_affiliates_link" href="javascript:;">{{ text_aff_schemes }}</a>
				{% for _sid, _sname in schemes %}
					<input type="hidden" id="product_coupon_{{ coupon['id'] }}_affiliates_{{ _sid }}" name="_product_coupon_affiliates[{{ coupon['id'] }}][{{ _sid }}]" value="" />
				{% endfor %}
				</div>								
			</td>
		</tr>
	{% endfor %}
	{% if pagination %}
		<tr><td colspan="2" class="text-right">{{ pagination }}</td></tr>
	{% endif %}
	</tbody>
</table>
<script type="text/javascript">
$('a[id$="_affiliates_link"]')._make_aff_table();
$('.coupon-page-link').on('click', function() {
	var _page = parseInt($(this).attr('rel'));
	$.ajax({
		url : '{{ link_commission_tab }}&coupon_page='+_page,
		method : 'GET',
		dataType : 'html',
		success : function(_r) {
			$('#tab-scheme').html(_r);
		}
	});
});
</script>