{{ header }}{{ column_left }}
<div id="content">
<div class="page-header">
	<div class="container-fluid">
		<div class="pull-right">
			<button type="submit" form="form-geo_shipping" data-toggle="tooltip" title="{{ button_save }}" class="btn btn-primary"><i
				class="fa fa-save"></i></button>
			<a href="{{ cancel }}" data-toggle="tooltip" title="{{ button_cancel }}" class="btn btn-default"><i class="fa fa-reply"></i></a>
		</div>
		<h1>{{ heading_title }}</h1>
		<ul class="breadcrumb">
			{% for breadcrumb in breadcrumbs %}
			<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
			{% endfor %}
		</ul>
	</div>
</div>
<div class="container-fluid">
{% if error_warning %}
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
	<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
{% endif %}
{% if success %}
<div class="alert alert-success"><i class="fa fa-check-circle"></i> {{ success }}
	<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
{% endif %}
<div class="panel panel-default">
	<div class="panel-heading">
		<h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_edit }}</h3>
	</div>
	<div class="panel-body">
		<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-geo_shipping" class="form-horizontal">
			<ul class="nav nav-tabs">
				<li class="active"><a href="#tab-general" data-toggle="tab">{{ tab_general }}</a></li>
				<li><a href="#tab-methods" data-toggle="tab">{{ tab_methods }}</a></li>
			</ul>
			<div class="tab-content">
				<div class="tab-pane active" id="tab-general">
					<div class="form-group">
						<label class="control-label col-sm-3" for="shipping_geo_zone_shipping_status">{{ entry_status }}</label>
						<div class="col-sm-9">
							<select name="shipping_geo_zone_shipping_status" class="form-control">
								{% if shipping_geo_zone_shipping_status %}
								<option value="1" selected="selected">{{ text_enabled }}</option>
								<option value="0">{{ text_disabled }}</option>
								{% else %}
								<option value="1">{{ text_enabled }}</option>
								<option value="0" selected="selected">{{ text_disabled }}</option>
								{% endif %}
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label" for="shipping_geo_zone_shipping_sort_order">{{ entry_sort_order }}</label>
						<div class="col-sm-9">
							<input type="text" name="shipping_geo_zone_shipping_sort_order" value="{{ shipping_geo_zone_shipping_sort_order }}" placeholder="{{ entry_sort_order }}" id="shipping_geo_zone_shipping_sort_order" class="form-control" />
						</div>
					</div>
					<div class="row-fluid">
						<div class="pull-right btn btn-primary" onclick="switchToTab('tab-methods');">{{ text_next }} <i class="fa fa-arrow-right"></i></div>
					</div>
				</div>
				<div class="tab-pane" id="tab-methods">
					<table id="shipping_methods" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<td width="30%">{{ column_general }}</td>
								<td width="30%">{{ column_availability }}</td>
								<td>{{ column_cost }}</td>
								<td>&nbsp;</td>
							</tr>
						</thead>
						<tbody>
							{% set row = 0 %}
							{% for method in shipping_geo_zone_shipping_methods %}
							<tr id="shipping-row{{ row }}">
								<td class="text-left">
									<div class="form-group col-sm-12 required">
										<label class="control-label">{{ entry_method_name }}</label>
											{% for language in languages %}
											<div class="input-group">
												<span class="input-group-addon">
													<img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" />
												</span>
												<input type="text" name="shipping_geo_zone_shipping_methods[{{ row }}][name][{{ language.language_id }}]" value="{{ method.name[language.language_id] }}" placeholder="{{ entry_method_name }}" class="form-control" />
											</div>
											{% if error_method[row]['name'][language.language_id] %}
											<div class="text-danger">{{ error_method[row]['name'][language.language_id] }}</div>
											{% endif %}
										{% endfor %}
									</div>
									<div class="form-group col-sm-12">
										<label class="control-label">{{ entry_instruction }}</label>
										{% for language in languages %}
										<div class="input-group">
											<span class="input-group-addon">
												<img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" />
											</span>
											<textarea name="shipping_geo_zone_shipping_methods[{{ row }}][instruction][{{ language.language_id }}]" rows="5" placeholder="{{ entry_instruction }}" class="form-control">{{ method.instruction[language.language_id] }}</textarea>
										</div>
										{% endfor %}
									</div>
								</td>
								<td class="text-left">
									<div class="form-group col-sm-12 required">
										<label class="control-label">{{ entry_status }}</label>
										<select name="shipping_geo_zone_shipping_methods[{{ row }}][status]" class="form-control">
											{% if method.status %}
											<option value="1" selected="selected">{{ text_enabled }}</option>
											<option value="0">{{ text_disabled }}</option>
											{% else %}
											<option value="1">{{ text_enabled }}</option>
											<option value="0" selected="selected">{{ text_disabled }}</option>
											{% endif %}
										</select>
										{% if error_method[row]['status'] %}
										<div class="text-danger">{{ error_method[row]['status'] }}</div>
										{% endif %}
									</div>
									<div class="form-group col-sm-12">
										<label class="control-label">
											<span data-toggle="tooltip" title="{{ entry_total_help }}">{{ entry_total }}</span>
										</label>
										<input type="number" step=".01" name="shipping_geo_zone_shipping_methods[{{ row }}][total]" value="{{ method.total }}" placeholder="{{ entry_total }}" class="form-control"  min="0"/>
										{% if error_method[row]['total'] %}
										<div class="text-danger">{{ error_method[row]['total'] }}</div>
										{% endif %}
									</div>
									<div class="form-group col-sm-12 required">
										<label class="control-label">{{ entry_geo_zone }}</label>
										<select name="shipping_geo_zone_shipping_methods[{{ row }}][geo_zone_id]" class="form-control">
											<option value="0">{{ text_all_zones }}</option>
											{% for geo_zone in geo_zones %}
											{% if geo_zone.geo_zone_id == method.geo_zone_id %}
											<option value="{{ geo_zone.geo_zone_id }}" selected="selected">{{ geo_zone.name }}</option>
											{% else %}
											<option value="{{ geo_zone.geo_zone_id }}">{{ geo_zone.name }}</option>
											{% endif %}
											{% endfor %}
										</select>
										{% if error_method[row]['geo_zone_id'] %}
										<div class="text-danger">{{ error_method[row]['geo_zone_id'] }}</div>
										{% endif %}
									</div>
								</td>
								<td class="text-left">
									<div class="form-group col-sm-12 required">
										<label class="control-label">{{ entry_cost_type }}</label>
										<select name="shipping_geo_zone_shipping_methods[{{ row }}][cost_type]" class="form-control cost_type">
											<option value="flat" {% if method.cost_type == 'flat' %}selected{% endif %}>{{ entry_flat_cost }}</option>
											<option value="price" {% if method.cost_type == 'price' %}selected{% endif %}>{{ entry_price_cost }}</option>
											<option value="weight" {% if method.cost_type == 'weight' %}selected{% endif %}>{{ entry_weight_cost }}</option>
										</select>
										{% if error_method[row]['cost_type'] %}
										<div class="text-danger">{{ error_method[row]['cost_type'] }}</div>
										{% endif %}
									</div>

									{# Flat Cost Shipping #}
									<div class="form-group col-sm-12 required _flat" {% if method.cost_type != 'flat' %}style="display: none;"{% endif %}>
										<label class="control-label">
											<span data-toggle="tooltip" title="{{ entry_flat_cost_help }}">{{ entry_flat_cost }}</span>
										</label>
										<input type="number" step=".01" name="shipping_geo_zone_shipping_methods[{{ row }}][flat_cost]" value="{{ method.flat_cost }}" placeholder="{{ entry_flat_cost }}" class="form-control" min="0" />
										{% if error_method[row]['flat_cost'] %}
										<div class="text-danger">{{ error_method[row]['flat_cost'] }}</div>
										{% endif %}
									</div>
									{# Flat Cost Shipping #}


									{# Total Based Shipping #}
									<div class="form-group col-sm-12 required _price" {% if method.cost_type != 'price' %}style="display: none;"{% endif %}>
										<label class="control-label">
											<span data-toggle="tooltip" title="{{ entry_price_help }}">{{ entry_price }}</span>
										</label>
										<input type="number" step=".01" name="shipping_geo_zone_shipping_methods[{{ row }}][price]" value="{{ method.price }}" placeholder="{{ entry_price }}" class="form-control" min="0" />
										{% if error_method[row]['price'] %}
										<div class="text-danger">{{ error_method[row]['price'] }}</div>
										{% endif %}
									</div>
									<div class="form-group col-sm-12 required _price" {% if method.cost_type != 'price' %}style="display: none;"{% endif %}>
										<label class="control-label">
											<span data-toggle="tooltip" title="{{ entry_price_cost_help2 }}">{{ entry_price_cost }}</span>
										</label>
										<input type="text" name="shipping_geo_zone_shipping_methods[{{ row }}][price_cost]" value="{{ method.price_cost }}" placeholder="{{ entry_price_cost_help1 }}" class="form-control" min="0" />
										{% if error_method[row]['price_cost'] %}
										<div class="text-danger">{{ error_method[row]['price_cost'] }}</div>
										{% endif %}
									</div>
									{# Total Based Shipping #}


									{# Weight Based Shipping #}
									<div class="form-group col-sm-12 required _weight" {% if method.cost_type != 'weight' %}style="display: none;"{% endif %}>
										<label class="control-label">
											<span data-toggle="tooltip" title="{{ entry_weight_help }}">{{ entry_weight }}</span>
										</label>
										<input type="number" step=".01" name="shipping_geo_zone_shipping_methods[{{ row }}][weight]" value="{{ method.weight }}" placeholder="{{ entry_weight }}" class="form-control" min="0" />
										{% if error_method[row]['weight'] %}
										<div class="text-danger">{{ error_method[row]['weight'] }}</div>
										{% endif %}
									</div>
									<div class="form-group col-sm-12 required _weight" {% if method.cost_type != 'weight' %}style="display: none;"{% endif %}>
										<label class="control-label">
											<span data-toggle="tooltip" title="{{ entry_weight_cost_help2 }}">{{ entry_weight_cost }}</span>
										</label>
										<input type="text" name="shipping_geo_zone_shipping_methods[{{ row }}][weight_cost]" value="{{ method.weight_cost }}" placeholder="{{ entry_weight_cost_help1 }}" class="form-control" min="0" />
										{% if error_method[row]['weight_cost'] %}
										<div class="text-danger">{{ error_method[row]['weight_cost'] }}</div>
										{% endif %}
									</div>
									{# Weight Based Shipping #}

									<div class="form-group col-sm-12 required">
										<label class="control-label">{{ entry_tax_class }}</label>
										<select name="shipping_geo_zone_shipping_methods[{{ row }}][tax_class_id]" class="form-control">
											<option value="">{{ entry_no_tax_class }}</option>
											{% for tax_class in tax_classes %}
											{% if tax_class.tax_class_id == method.tax_class_id %}
											<option value="{{ tax_class.tax_class_id }}" selected="selected">{{ tax_class.title }}</option>
											{% else %}
											<option value="{{ tax_class.tax_class_id }}">{{ tax_class.title }}</option>
											{% endif %}
											{% endfor %}
										</select>
										{% if error_method[row]['tax_class_id'] %}
										<div class="text-danger">{{ error_method[row]['tax_class_id'] }}</div>
										{% endif %}
									</div>
								</td>
								<td class="text-left"><button type="button" onclick="$('#shipping-row{{ row }}').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
							</tr>
							{% set row = row + 1 %}
							{% endfor %}
						</tbody>
						<tfoot>
							<tr>
								<td colspan="3"></td>
								<td class="text-left"><button type="button" onclick="addRow();" data-toggle="tooltip" title="{{ button_add }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></td>
							</tr>
						</tfoot>
					</table>
				</div>
			</div>
		</form>
	</div>
</div>
<style type="text/css">
	table#shipping_methods tr:not(:last-child) {
		border-bottom: 2px rgb(192,192,192) solid;
	}
</style>
<script type="text/javascript"><!--
	$(document).ready(function(){
		var active_tab = $(".tab-pane .text-danger").eq(0).parents(".tab-pane").attr("id");
		$("a[href='#"+active_tab+"'").trigger("click");
	});

	$(document).on('change', 'select.cost_type', function(){
		$('._flat', $(this).parents('tr')).hide();
		$('._price', $(this).parents('tr')).hide();
		$('._weight', $(this).parents('tr')).hide();
		if($(this).val() == 'price'){
			$('._price', $(this).parents('tr')).show();
		} else if($(this).val() == 'weight'){
			$('._weight', $(this).parents('tr')).show();
		} else {
			$('._flat', $(this).parents('tr')).show();
		}
	});
	
	function switchToTab(tab_name){
	  $('.nav-tabs a[href="#'+tab_name+'"]').tab('show');
	}
	
	var row = {{ row }};

	function addRow() {
		html =	'<tr id="shipping-row'+row+'">'
			+			'<td class="text-left">'
			+				'<div class="form-group col-sm-12 required">'
			+					'<label class="control-label">{{ entry_method_name }}</label>';
								{% for language in languages %}
		html +=				'<div class="input-group">'
			+						'<span class="input-group-addon">'
			+							'<img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" />'
			+						'</span>'
			+						'<input type="text" name="shipping_geo_zone_shipping_methods['+row+'][name][{{ language.language_id }}]" value="" placeholder="{{ entry_method_name }}" class="form-control" />'
			+					'</div>';
								{% endfor %}
		html +=			'</div>'
			+				'<div class="form-group col-sm-12">'
			+					'<label class="control-label">{{ entry_instruction }}</label>';
								{% for language in languages %}
		html +=				'<div class="input-group">'
			+						'<span class="input-group-addon">'
			+							'<img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" />'
			+						'</span>'
			+						'<textarea name="shipping_geo_zone_shipping_methods['+row+'][instruction][{{ language.language_id }}]" rows="5" placeholder="{{ entry_instruction }}" class="form-control"></textarea>'
			+					'</div>';
								{% endfor %}
		html +=			'</div>'
			+			'</td>'
			+			'<td class="text-left">'
			+				'<div class="form-group col-sm-12 required">'
			+					'<label class="control-label">{{ entry_status }}</label>'
			+					'<select name="shipping_geo_zone_shipping_methods['+row+'][status]" class="form-control">'
			+						'<option value="1" selected="selected">{{ text_enabled }}</option>'
			+						'<option value="0">{{ text_disabled }}</option>'
			+					'</select>'
			+				'</div>'
			+				'<div class="form-group col-sm-12">'
			+					'<label class="control-label">'
			+						'<span data-toggle="tooltip" title="{{ entry_total_help }}">{{ entry_total }}</span>'
			+					'</label>'
			+					'<input type="number" step=".01" name="shipping_geo_zone_shipping_methods['+row+'][total]" value="" placeholder="{{ entry_total }}" class="form-control"  min="0"/>'
			+				'</div>'
			+				'<div class="form-group col-sm-12 required">'
			+					'<label class="control-label">{{ entry_geo_zone }}</label>'
			+					'<select name="shipping_geo_zone_shipping_methods['+row+'][geo_zone_id]" class="form-control">'
			+						'<option value="0" selected="selected">{{ text_all_zones }}</option>';
									{% for geo_zone in geo_zones %}
		html +=					'<option value="{{ geo_zone.geo_zone_id }}">{{ geo_zone.name|e("js") }}</option>';
									{% endfor %}
		html +=				'</select>'
			+				'</div>'
			+			'</td>'
			+			'<td class="text-left">'
			+				'<div class="form-group col-sm-12 required">'
			+					'<label class="control-label">{{ entry_cost_type }}</label>'
			+					'<select name="shipping_geo_zone_shipping_methods['+row+'][cost_type]" class="form-control cost_type">'
			+						'<option value="flat" selected="selected">{{ entry_flat_cost }}</option>'
			+						'<option value="price">{{ entry_price_cost }}</option>'
			+						'<option value="weight">{{ entry_weight_cost }}</option>'
			+					'</select>'
			+				'</div>'


			+				'<div class="form-group col-sm-12 required _flat">'
			+					'<label class="control-label">'
			+						'<span data-toggle="tooltip" title="{{ entry_flat_cost_help }}">{{ entry_flat_cost }}</span>'
			+					'</label>'
			+					'<input type="number" step=".01" name="shipping_geo_zone_shipping_methods['+row+'][flat_cost]" value="" placeholder="{{ entry_flat_cost }}" class="form-control" min="0" />'
			+				'</div>'


			+				'<div class="form-group col-sm-12 required _price" style="display: none;">'
			+					'<label class="control-label">'
			+						'<span data-toggle="tooltip" title="{{ entry_price_help }}">{{ entry_price }}</span>'
			+					'</label>'
			+					'<input type="text" name="shipping_geo_zone_shipping_methods['+row+'][price]" value="" placeholder="{{ entry_price }}" class="form-control" min="0" />'
			+				'</div>'
			+				'<div class="form-group col-sm-12 required _price" style="display: none;">'
			+					'<label class="control-label">'
			+						'<span data-toggle="tooltip" title="{{ entry_price_cost_help2 }}">{{ entry_price_cost }}</span>'
			+					'</label>'
			+					'<input type="text" name="shipping_geo_zone_shipping_methods['+row+'][price_cost]" value="" placeholder="{{ entry_price_cost_help1 }}" class="form-control" min="0" />'
			+				'</div>'


			+				'<div class="form-group col-sm-12 required _weight" style="display: none;">'
			+					'<label class="control-label">'
			+						'<span data-toggle="tooltip" title="{{ entry_weight_help }}">{{ entry_weight }}</span>'
			+					'</label>'
			+					'<input type="text" name="shipping_geo_zone_shipping_methods['+row+'][weight]" value="" placeholder="{{ entry_weight }}" class="form-control" min="0" />'
			+				'</div>'
			+				'<div class="form-group col-sm-12 required _weight" style="display: none;">'
			+					'<label class="control-label">'
			+						'<span data-toggle="tooltip" title="{{ entry_weight_cost_help2 }}">{{ entry_weight_cost }}</span>'
			+					'</label>'
			+					'<input type="text" name="shipping_geo_zone_shipping_methods['+row+'][weight_cost]" value="" placeholder="{{ entry_weight_cost_help1 }}" class="form-control" min="0" />'
			+				'</div>'
			+				'<div class="form-group col-sm-12 required">'
			+					'<label class="control-label">{{ entry_tax_class }}</label>'
			+					'<select name="shipping_geo_zone_shipping_methods['+row+'][tax_class_id]" class="form-control">'
			+						'<option value="">{{ entry_no_tax_class }}</option>';
									{% for tax_class in tax_classes %}
		html +=					'<option value="{{ tax_class.tax_class_id }}">{{ tax_class.title }}</option>';
									{% endfor %}
		html +=				'</select>'
				+			'</div>'
				+		'</td>'
				+		'<td class="text-left"><button type="button" onclick="$(\'#shipping-row'+row+'\').remove();" data-toggle="tooltip" title="{{ button_remove }}" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>'
				+	'</tr>';


		$('#shipping_methods tbody').append(html);
		row++;
	}
	//-->
</script>
{{ footer }}