{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form" 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" form="form-backup" 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">
	
	<!-- General -->
	<div class="col-sm-12" style="margin-bottom: 15px;">
      {{ text_general }}
    </div>
    <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form" name="form" id="form-gpf" class="form-horizontal">
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="google-product-feed-status">{{ entry_status }}</label>
		    <div class="col-sm-7">
		      <select name="gpf_status" id="google-product-feed-status" class="form-control">
					  {% if gpf_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 class="col-sm-2"></div>
		    </div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="button-enable-disable"><span data-toggle="tooltip" title="{{ help_enable_all_products }}">{{ entry_enable_all_products }}</span></label>
		    <div class="col-sm-7" id="button-enable-disable">
            <a onclick="enableAllProducts()" class="button"><button type="button" id="button-enable" class="btn btn-primary">{{ button_enable_all_products }}</button></a>
            <a onclick="disableAllProducts()" class="button"><button type="button" id="button-disable" class="btn btn-danger">{{ button_disable_all_products }}</button></a>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-split-feed"><span data-toggle="tooltip" title="{{ help_split_feed }}">{{ entry_split_feed }}</span></label>
		    <div class="col-sm-7">
		      <select name="gpf_split" class="form-control" onchange="splitFeed();">
					  {% for split in splits %}
					  {% if split == 0 %}
						{% set split_name = 'No Split' %}
					  {% else %}
						{% set split_name = split %}
					  {% endif %}
					  {% if gpf_split == split %}
					  <option value="{{ split }}" selected="selected">{{ split_name }}</option>
					  {% else %}
					  <option value="{{ split }}">{{ split_name }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_data_feed }}">{{ entry_data_feed }}</span></label>
		    <div class="col-sm-7">
			  <div  class="well" id="data-feed">
		        {{ data_feed }}
			  </div>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-currency"><span data-toggle="tooltip" title="{{ help_currency }}">{{ entry_currency }}</span></label>
		    <div class="col-sm-7">
			  <select name="gpf_currency" id="gpf-currency" class="form-control">
					  {% for currency in currencies %}
					  {% if gpf_currency == currency %}
					  <option value="{{ currency }}" selected="selected">{{ currency }}</option>
					  {% else %}
					  <option value="{{ currency }}">{{ currency }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-lang"><span data-toggle="tooltip" title="{{ help_language }}">{{ entry_language }}</span></label>
		    <div class="col-sm-7">
			<select name="gpf_lang" id="gpf-lang" class="form-control">
					  {% for language in languages %}
					  {% if gpf_lang == language.value %}
					  <option value="{{ language.value }}" selected="selected">{{ language.selection }}</option>
					  {% else %}
					  <option value="{{ language.value }}">{{ language.selection }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="default-gpf-category">{{ entry_default_google_product_category }}</label>
		    <div class="col-sm-7">
			  <input type="text" name="gpf_default_google_product_category" id="default-gpf-category" class="form-control" value="{{ gpf_default_google_product_category }}" />
		    </div>
			<div class="col-sm-2"><a onclick="googleTaxonomy()" data-toggle="tooltip" title="{{ button_gpf_taxonomy }}" class="btn btn-primary"><i class="fa fa-plus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-gtin"><span data-toggle="tooltip" title="{{ help_gtin }}">{{ entry_gtin }}</span></label>
		    <div class="col-sm-7">
			  <select name="gpf_gtin" id="gpf-gtin" class="form-control">
					  {% for key, value in gtins %}
					  {% if gpf_gtin == key %}
					  <option value="{{ key }}" selected="selected">{{ value }}</option>
					  {% else %}
					  <option value="{{ key }}">{{ value }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-condition"><span data-toggle="tooltip" title="{{ help_condition }}">{{ entry_condition }}</span></label>
		    <div class="col-sm-7">
			  <select name="gpf_condition" id="gpf-condition" class="form-control">
					  {% for av_cond in available_conditions %}
					  {% if gpf_condition == av_cond %}
					  <option value="{{ av_cond }}" selected="selected">{{ av_cond }}</option>
					  {% else %}
					  <option value="{{ av_cond }}">{{ av_cond }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-oos-status"><span data-toggle="tooltip" title="{{ help_oos_status }}">{{ entry_oos_status }}</span></label>
		    <div class="col-sm-7">
			  <select name="gpf_oos_status" id="gpf-oos-status" class="form-control">
					  {% for av_oos in available_oos_statuses %}
					  {% if gpf_oos_status == av_oos %}
					  <option value="{{ av_oos }}" selected="selected">{{ av_oos }}</option>
					  {% else %}
					  <option value="{{ av_oos }}">{{ av_oos }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-size-system"><span data-toggle="tooltip" title="{{ help_size_system }}">{{ entry_size_system }}</span></label>
		    <div class="col-sm-7">
			  <select name="gpf_size_system" id="gpf-size-system" class="form-control">
					  {% for av_ss in available_size_systems %}
					  {% if gpf_size_system == av_ss %}
					  <option value="{{ av_ss }}" selected="selected">{{ av_ss }}</option>
					  {% else %}
					  <option value="{{ av_ss }}">{{ av_ss }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-identifier-exists"><span data-toggle="tooltip" title="{{ help_identifier_exists }}">{{ entry_identifier_exists }}</span></label>
		    <div class="col-sm-7">
			  <select name="gpf_identifier_exists" id="gpf-identifier-exists" class="form-control">		  
					  {% if gpf_identifier_exists == 'FALSE' %}
						  <option value="TRUE">{{ text_true }}</option>
						  <option value="FALSE" selected="selected">{{ text_false }}</option>
					  {% else %}
						  <option value="TRUE" selected="selected">{{ text_true }}</option>
						  <option value="FALSE">{{ text_false }}</option>
					  {% endif %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-mobile-url"><span data-toggle="tooltip" title="{{ help_gpf_mobile_url }}">{{ entry_gpf_mobile_url }}</span></label>
		    <div class="col-sm-7">
			  <input type="text" name="gpf_mobile_url" id="gpf-mobile-url" class="form-control" value="{{ gpf_mobile_url }}" />
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-copy-manufacturer"><span data-toggle="tooltip" title="{{ help_copy_manufacturer }}">{{ entry_copy_manufacturer }}</span></label>
		    <div class="col-sm-7">
			  <select name="gpf_copy_manufacturer" id="gpf-copy-manufacturer" class="form-control">
					  {% for y_n in yes_no %}
					  {% if gpf_copy_manufacturer == y_n %}
					  <option value="{{ y_n }}" selected="selected">{{ y_n }}</option>
					  {% else %}
					  <option value="{{ y_n }}">{{ y_n }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
		  <hr />
	
	<!-- Custom Labels -->
		  <div class="col-sm-12">
		   {{ text_custom_labels }}
		  </div>
		  {% for i in 0..4 %}
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_custom_labels }}">{{ entry_custom_labels }}</span></label>
		    <div class="col-sm-7">
			  {{ text_custom_labels_group ~ ' : ' ~ (i + 1) }}<br />
			  <input type="text" name="gpf_custom_labels_group[{{ i }}]" id="gpf-custom-label-{{ i }}" class="form-control" value="{{ gpf_custom_labels_group.i }}" />
			  <br />
				{{ entry_custom_labels }}<br />
				<textarea name="gpf_custom_labels[{{ i }}]" rows="5" class="form-control">{{ gpf_custom_labels.i }}</textarea>
				<br />
		    </div>
			<div class="col-sm-2"></div>
	      </div>
			  {% endfor %}
		  <hr />
	
	<!-- Product Variants -->
		<div class="col-sm-12">
		  {{ text_variants }}
		  {{ entry_variants }}
		</div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_gpf_size_options }}">{{ entry_gpf_size_options }}</span></label>
		    <div class="col-sm-7">
			  <div class="col-sm-4">
			    <select name="gpf_size_option1" class="form-control">
					  <option value="-1"> </option>
					  {% for option in options %}
					  {% if gpf_size_option1 == option.option_id %}
					  <option value="{{ option.option_id }}" selected="selected">{{ option.option }}</option>
					  {% else %}
					  <option value="{{ option.option_id }}">{{ option.option }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
			  </div>
			  <div class="col-sm-4">
			    <select name="gpf_size_option2" class="form-control">
					  <option value="-1"> </option>
					  {% for option in options %}
					  {% if gpf_size_option2 == option.option_id %}
					  <option value="{{ option.option_id }}" selected="selected">{{ option.option }}</option>
					  {% else %}
					  <option value="{{ option.option_id }}">{{ option.option }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
			  </div>
			  <div class="col-sm-4">
			    <select name="gpf_size_option3" class="form-control">
					  <option value="-1"> </option>
					  {% for option in options %}
					  {% if gpf_size_option3 == option.option_id %}
					  <option value="{{ option.option_id }}" selected="selected">{{ option.option }}</option>
					  {% else %}
					  <option value="{{ option.option_id }}">{{ option.option }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
			  </div>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_gpf_colour_options }}">{{ entry_gpf_colour_options }}</span></label>
		    <div class="col-sm-7">
			    <select name="gpf_colour_option" class="form-control">
					  <option value="-1"> </option>
					  {% for option in options %}
					  {% if gpf_colour_option == option.option_id %}
					  <option value="{{ option.option_id }}" selected="selected">{{ option.option }}</option>
					  {% else %}
					  <option value="{{ option.option_id }}">{{ option.option }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_gpf_pattern_options }}">{{ entry_gpf_pattern_options }}</span></label>
		    <div class="col-sm-7">
			    <select name="gpf_pattern_option" class="form-control">
					  <option value="-1"> </option>
					  {% for option in options %}
					  {% if gpf_pattern_option == option.option_id %}
					  <option value="{{ option.option_id }}" selected="selected">{{ option.option }}</option>
					  {% else %}
					  <option value="{{ option.option_id }}">{{ option.option }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_gpf_material_options }}">{{ entry_gpf_material_options }}</span></label>
		    <div class="col-sm-7">
			    <select name="gpf_material_option" class="form-control">
					  <option value="-1"> </option>
					  {% for option in options %}
					  {% if gpf_material_option == option.option_id %}
					  <option value="{{ option.option_id }}" selected="selected">{{ option.option }}</option>
					  {% else %}
					  <option value="{{ option.option_id }}">{{ option.option }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_all_variants }}">{{ entry_all_variants }}</span></label>
		    <div class="col-sm-7">
			  <select name="all_variants" id="all-variants" class="form-control">
					  {% for y_n in yes_no %}
					  {% if y_n == 'No' %}
					  <option value="{{ y_n }}" selected="selected">{{ y_n }}</option>
					  {% else %}
					  <option value="{{ y_n }}">{{ y_n }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"></label>
		    <div class="col-sm-7">
            <a onclick="generateProductVariants()" class="button"><button type="button" id="button-enable" class="btn btn-primary">{{ button_generate_variants }}</button></a>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
		  <hr />
	
	<!-- Copy Data -->
		  <div class="col-sm-12">
		    {{ text_copy }}
		  </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_copy_fields }}">{{ entry_copy_fields }}</span></label>
		    <div class="col-sm-7">
			  <div class="well well-sm">
                  {% set class = 'odd' %}
                  {% for field in fields %}
                  {% set class = (class == 'even' ? 'odd' : 'even') %}
					<div class="checkbox">
					  <label>
						<input type="checkbox" name="copy_field[]" value="{{ field }}" />
						{{ field }}</label>
					</div>
                  {% endfor %}
                </div>
                <a onclick="$(this).parent().find(':checkbox').attr('checked', true);">{{ text_select_all }}</a> / <a onclick="$(this).parent().find(':checkbox').attr('checked', false);">{{ text_unselect_all }}</a>		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_replace_av_for_order }}">{{ entry_replace_av_for_order }}</span></label>
		    <div class="col-sm-7">
			  <div class="well well-sm">
					<div class="checkbox">
					  <label>
						<input type="checkbox" name="replace_av_for_order" value="1" />
						</label>
					</div>
                </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_copy_gtin }}">{{ entry_copy_gtin }}</span></label>
		    <div class="col-sm-7">
		      <select name="gpf_copy_gtin" id="gpf-copy-gtin" class="form-control">
					  {% for gtin in original_gtin %}
					  {% if gpf_copy_gtin == gtin %}
					  <option value="{{ gtin }}" selected="selected">{{ gtin }}</option>
					  {% else %}
					  <option value="{{ gtin }}">{{ gtin }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_copy_mpn }}">{{ entry_copy_mpn }}</span></label>
		    <div class="col-sm-7">
		      <select name="gpf_copy_mpn" id="gpf-copy-mpn" class="form-control">
					  {% for mpn in original_mpn %}
					  {% if gpf_copy_mpn == mpn %}
					  <option value="{{ mpn }}" selected="selected">{{ mpn }}</option>
					  {% else %}
					  <option value="{{ mpn }}">{{ mpn }}</option>
					  {% endif %}
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="{{ help_copy_to }}">{{ entry_copy_to }}</span></label>
		    <div class="col-sm-7">
		      <select name="gpf_copy_to" id="gpf-copy-to" class="form-control">
					  {% for option in copy_options %}
					  <option value="{{ option }}">{{ option }}</option>
					  {% endfor %}
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"></label>
		    <div class="col-sm-7">
            <a onclick="copyData()" class="button"><button type="button" class="btn btn-primary">{{ button_copy_data }}</button></a>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
		  <hr />
		</form>
		
	<!-- Export / Import -->
		  <div class="col-sm-12">
		    {{ text_import_export }}
		  </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label">{{ entry_export_csv }}</label>
		    <div class="col-sm-7">
            <a href="{{ export_csv }}" class="button"><button type="button" id="button-enable" class="btn btn-primary">{{ button_export_csv }}</button></a>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
		  <hr />
		  <form action="{{ import_csv }}" method="post" enctype="multipart/form-data" id="import">
	      <div class="form-group">
		    <label class="col-sm-3 control-label">{{ entry_import_csv }}</label>
		    <div class="col-sm-3">
			  <br />
              <input type="file" name="import" /><br /><br />
			  <a onclick="$('#import').submit();" class="button"><button type="button" id="button-enable" class="btn btn-primary">{{ button_import_csv }}</button></a>
		    </div>
		    <div class="col-sm-4">
			  {{ text_import_csv }}
		    </div>
			<div class="col-sm-2"></div>
		  </div>
	      </form>
		  <hr />
			
	<!-- Troubleshooting -->
		  <div class="col-sm-12">
		    {{ text_troubleshooting }}
		  </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"></label>
		    <div class="col-sm-7">
		      <div class="well well-lg">
				{{ entry_troubleshooting }}
			  </div>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
		  <hr />
	
	<!-- Other Information -->
		  <div class="col-sm-12">
		    {{ text_information }}
		  </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"></label>
		    <div class="col-sm-7">
		      <div class="well well-lg">
				{{ entry_information }}
			  </div>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
		  		  
	  <input type="hidden" name="copy_data" value="0" />
	  <input type="hidden" name="enable_all_products" value="0" /> 
	  <input type="hidden" name="generate_product_variants" value="0" /> 
	  
	  <input type="hidden" name="split_feed" value="0" /> 
			 

  </div>
</div>
</div>
</div>


<script type="text/javascript">
<!--
function googleTaxonomy() {
	if (document.form.gpf_lang.value == 'ch-US') {
		var href='http://www.google.com/basepages/producttype/taxonomy.en-US.txt';
	} else {
		var href='http://www.google.com/basepages/producttype/taxonomy.' + document.form.gpf_lang.value + '.txt';
	}
	window.open(href,"GoogleTaxonomy");
}
</script>

<script type="text/javascript">
<!--
function viewFeed() {
	var href='{{ view_feed }}'
	window.open(href,"GoogleProductFeed");
}
</script>

<script type="text/javascript">
<!--
function copyData() {
	var r = confirm('{{ alert_copy_data }}');
	if(r==true) {
		document.form.copy_data.value = "1";
		$('#form').submit();
	}
}
</script>

<script type="text/javascript">
<!--
function generateProductVariants() {

	if(document.form.all_variants.value == 'Yes') {	
		var r = confirm('{{ alert_all_variants }}');
		if(r==true) {
			document.form.generate_product_variants.value = "1";
			$('#form').submit();
		}
	} else {
		var r = confirm('{{ alert_variants }}');
		if(r==true) {
			document.form.generate_product_variants.value = "1";
			$('#form').submit();
		}
	}
}
</script>

<script type="text/javascript">
<!--
function viewSplitFeed(href) {
	window.open(href,"GoogleProductFeed");
}
</script>
			
<script type="text/javascript">
<!--
function enableAllProducts() {
	var r = confirm('{{ alert_enable }}');
	if (r == true) {
		document.form.enable_all_products.value = "1";
		$('#form').submit();
	}
}
</script>

<script type="text/javascript">
<!--
function disableAllProducts() {
	var r = confirm('{{ alert_disable }}');
	if (r == true) {
		document.form.enable_all_products.value = "2";
		$('#form').submit();
	}
}
//-->
</script>

<script type="text/javascript">
<!--
function splitFeed() {
	document.form.split_feed.value = "1";
	$('#form').submit();
}
//-->
</script>

{{ footer }}
