<?php echo $header; ?><?php echo $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="<?php echo $button_update; ?>" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="<?php echo $cancel; ?>" data-toggle="tooltip" title="<?php echo $button_cancel; ?>" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1><?php echo $heading_title . ' (' . ($no_of_products + 1) . ' ' . ($no_of_products == 0 ? $text_product : $text_products) . ')'; ?></h1>
	  <ul class="breadcrumb">
		<?php foreach ($breadcrumbs as $breadcrumb) { ?>
		<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
		<?php } ?>
	  </ul>
    </div>
  </div>
  <div class="container-fluid">
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
	
  <div class="panel panel-default">
    <div class="panel-heading">
      <h3 class="panel-title"><i class="fa fa-pencil"></i> <?php echo $text_edit; ?></h3>
    </div>
    <div class="panel-body">
	<div class="col-sm-12" style="margin-bottom: 15px;">
	  <div class="well">
	    <?php echo $text_instructions_1 . $text_clear_keyword . $text_instructions_2; ?>
	  </div>
	  <hr />
    </div>
	<div class="col-sm-12" style="margin-bottom: 15px;">
      <?php echo $text_general; ?>
    </div>
    <form action="<?php echo $update; ?>" method="post" enctype="multipart/form-data" id="form" name="form" id="form-gpf" class="form-horizontal">
	<input type="hidden" name="selected_products" value="<?php echo $selected_products; ?>" />
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-status"><span data-toggle="tooltip" title="<?php echo $help_list; ?>"><?php echo $entry_list; ?></span></label>
		    <div class="col-sm-7">
			  <select name="gpf_status" id="gpf-status" class="form-control">
                <option value="1" selected="selected"><?php echo $text_yes; ?></option>
                <option value="0"><?php echo $text_no; ?></option>
              </select>
			<div class="col-sm-2"></div>
		    </div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-category"><span data-toggle="tooltip" title="<?php echo $help_google_product_category; ?>"><?php echo $entry_google_product_category; ?></span></label>
		    <div class="col-sm-7">
			  <input type="text" name="google_product_category" id="gpf-category" class="form-control" value="<?php echo $google_product_category; ?>" />
		    </div>
			<div class="col-sm-2"><a onclick="googleTaxonomy()" data-toggle="tooltip" title="<?php echo $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="brand"><?php echo $entry_brand; ?></label>
		    <div class="col-sm-7">
			  <input type="text" name="brand" id="brand" class="form-control" value="<?php echo $brand; ?>" />
		    </div>
			<div class="col-sm-2"><a onclick="clearField('brand')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="mpn"><?php echo $entry_mpn; ?></label>
		    <div class="col-sm-7">
			  <input type="text" name="mpn" id="mpn" class="form-control" value="<?php echo $mpn; ?>" />
		    </div>
			<div class="col-sm-2"><a onclick="clearField('mpn')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="identifier-exists"><?php echo $entry_identifier_exists; ?></label>
		    <div class="col-sm-7">
			  <select name="identifier_exists" id="identifier-exists" class="form-control">
				  <option value="" selected="selected"><?php echo $text_do_not_change; ?></option>
				  <option value="TRUE"><?php echo $text_true; ?></option>
				  <option value="FALSE"><?php echo $text_false; ?></option>
			  </select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gender"><?php echo $entry_gender; ?></label>
		    <div class="col-sm-7">
			  <select name="gender" id="gender" class="form-control">
					  <?php foreach($available_genders as $av_gender) { ?>
					  <?php if ($gender == $av_gender) { ?>
					  <option value="<?php echo $av_gender; ?>" selected="selected"><?php echo $av_gender; ?></option>
					  <?php } else { ?>
					  <option value="<?php echo $av_gender; ?>"><?php echo $av_gender; ?></option>
					  <?php } ?>
					  <?php } ?>
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="agegroup"><?php echo $entry_agegroup; ?></label>
		    <div class="col-sm-7">
			  <select name="agegroup" id="agegroup" class="form-control">
					  <?php foreach($available_agegroup as $av_age) { ?>
					  <?php if ($agegroup == $av_age) { ?>
					  <option value="<?php echo $av_age; ?>" selected="selected"><?php echo $av_age; ?></option>
					  <?php } else { ?>
					  <option value="<?php echo $av_age; ?>"><?php echo $av_age; ?></option>
					  <?php } ?>
					  <?php } ?>
					</select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="colour"><span data-toggle="tooltip" title="<?php echo $help_colour; ?>"><?php echo $entry_colour; ?></span></label>
		    <div class="col-sm-7">
			  <input type="text" name="colour" id="colour" class="form-control" value="<?php echo $colour; ?>" />
		    </div>
			<div class="col-sm-2"><a onclick="clearField('colour')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="size"><span data-toggle="tooltip" title="<?php echo $help_size; ?>"><?php echo $entry_size; ?></span></label>
		    <div class="col-sm-7">
			  <input type="text" name="size" id="size" class="form-control" value="<?php echo $size; ?>" />
		    </div>
			<div class="col-sm-2"><a onclick="clearField('size')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="size-system"><?php echo $entry_size_system; ?></label>
		    <div class="col-sm-7">
			  <select name="gpf_size_system" id="size-system" class="form-control">
					  <?php foreach($available_size_systems as $av_ss) { ?>
					  <?php if ($gpf_size_system == $av_ss) { ?>
					  <option value="<?php echo $av_ss; ?>" selected="selected"><?php echo $av_ss; ?></option>
					  <?php } else { ?>
					  <option value="<?php echo $av_ss; ?>"><?php echo $av_ss; ?></option>
					  <?php } ?>
					  <?php } ?>
					</select>
			</div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="size-type"><span data-toggle="tooltip" title="<?php echo $help_size; ?>"><?php echo $entry_size_type; ?></span></label>
		    <div class="col-sm-7">
			  <select name="gpf_size_type" id="size-type" class="form-control">
					  <?php foreach($available_size_types as $av_st) { ?>
					  <?php if ($gpf_size_type == $av_st) { ?>
					  <option value="<?php echo $av_st; ?>" selected="selected"><?php echo $av_st; ?></option>
					  <?php } else { ?>
					  <option value="<?php echo $av_st; ?>"><?php echo $av_st; ?></option>
					  <?php } ?>
					  <?php } ?>
					</select>
			</div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="condition"><?php echo $entry_condition; ?></label>
		    <div class="col-sm-7">
			  <select name="condition" id="condition" class="form-control">
					  <?php foreach($available_conditions as $av_cond) { ?>
					  <?php if ($condition == $av_cond) { ?>
					  <option value="<?php echo $av_cond; ?>" selected="selected"><?php echo $av_cond; ?></option>
					  <?php } else { ?>
					  <option value="<?php echo $av_cond; ?>"><?php echo $av_cond; ?></option>
					  <?php } ?>
					  <?php } ?>
					</select>
			</div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="size-type"><?php echo $entry_oos_status; ?></label>
		    <div class="col-sm-7">
			  <select name="oos_status" id="oos-status" class="form-control">
					  <?php foreach($available_oos_statuses as $av_oos) { ?>
					  <?php if ($oos_status == $av_oos) { ?>
					  <option value="<?php echo $av_oos; ?>" selected="selected"><?php echo $av_oos; ?></option>
					  <?php } else { ?>
					  <option value="<?php echo $av_oos; ?>"><?php echo $av_oos; ?></option>
					  <?php } ?>
					  <?php } ?>
					</select>
			</div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-availability-date"><span data-toggle="tooltip" title="<?php echo $help_availability_date; ?>"><?php echo $entry_availability_date; ?></span></label>
		    <div class="col-sm-7 date">
			  <input type="text" name="gpf_availability_date" id="gpf-availability-date" class="form-control" placeholder="YYYY-MM-DD" value="<?php echo $gpf_availability_date; ?>" />
		    </div>
			<div class="col-sm-2">
			  <a onclick="clearField('gpf-availability-date')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-availability-time"><?php echo $entry_availability_time; ?></label>
		    <div class="col-sm-7 time">
			  <input type="text" name="gpf_availability_time" id="gpf-availability-time" class="form-control" placeholder="HH:MM" data-format="HH:MM" value="<?php echo $gpf_availability_time; ?>" />
		    </div>
			<div class="col-sm-2">
			  <a onclick="clearField('gpf-availability-time')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="gpf-is-bundle"><span data-toggle="tooltip" title="<?php echo $help_is_bundle; ?>"><?php echo $entry_is_bundle; ?></span></label>
		    <div class="col-sm-7">
			  <select name="gpf_is_bundle" id="gpf-is-bundle" class="form-control">
                <option value="X" selected="selected">Do Not Change</option>
                <option value="TRUE"><?php echo $text_true; ?></option>
                <option value="FALSE"><?php echo $text_false; ?></option>
              </select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
		  <br /><hr />
		  
		  <div class="col-sm-12" style="margin-bottom: 15px;">
			<?php echo $text_variants; ?>
		  </div>
		  <div class="col-sm-12" style="margin-bottom: 15px;">
		    <div class="well">
			  <?php echo $help_variant; ?>
		    </div>
		  </div>
	
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><span data-toggle="tooltip" title="<?php echo $help_clear_variants; ?>"><?php echo $entry_clear_variants; ?></span></label>
		    <div class="col-sm-7">
			  <select name="clear_variants" class="form-control">
                <option value="1"><?php echo $text_ignore; ?></option>
                <option value="0"><?php echo $text_clear; ?></option>
			  </select>
			</div>
			<div class="col-sm-2"></div>
	      </div>
	  <div class="form-group">
	    <div class="col-sm-12">
        <table id="variants" class="table table-striped table-bordered table-hover">
		  <thead>
			<tr>
				<td width="20%" class="text-center">Size</td>
				<td width="20%" class="text-center">Colour</td>
				<td width="20%" class="text-center">Pattern</td>
				<td width="20%" class="text-center">Material</td>
				<td width="12%" class="text-center">&nbsp;</td>
			</tr>
			</thead>
			
			<?php $variants_row = 0; 
			if ($product_variants){
			
			?>
			
			<?php foreach ($product_variants as $product_variant) { ?>

			<tbody id="variants_row<?php echo $variants_row; ?>">
			<tr>
				<td width="20%" class="text-center"><input type="text" name="product_variants[<?php echo $variants_row; ?>][size]" tabindex="<?php echo ($variants_row*4+12); ?>" value="<?php echo $product_variant['size']; ?>" /></td>
				<td width="20%" class="text-center"><input type="text" name="product_variants[<?php echo $variants_row; ?>][colour]" tabindex="<?php echo ($variants_row*4+13); ?>" value="<?php echo $product_variant['colour']; ?>" /></td>
				<td width="20%" class="text-center"><input type="text" name="product_variants[<?php echo $variants_row; ?>][pattern]" tabindex="<?php echo ($variants_row*4+14); ?>" value="<?php echo $product_variant['pattern']; ?>" /></td>
				<td width="20%" class="text-center"><input type="text" name="product_variants[<?php echo $variants_row; ?>][material]" tabindex="<?php echo ($variants_row*4+15); ?>" value="<?php echo $product_variant['material']; ?>" /></td>
				<input type="hidden" name="product_variants[<?php echo $variants_row; ?>][image]" value="" />
		        <td class="text-right">
				  <button type="button"  onclick="$('#variants_row<?php echo $variants_row; ?>').remove();" class="btn btn-danger pull-right"><?php echo $button_remove; ?></button>

				</td>
			</tr>
			</tbody>
			<?php $variants_row++; ?>
			<?php } 
			} ?>
		  <tfoot>
			<tr>
			  <td colspan="4"></td>
			  <td class="text-right">
				<button type="button"  onclick="addVariant();" class="btn btn-primary pull-right"><?php echo $button_add_variant; ?></button>
				
			  </td>
			</tr>
		  </tfoot>
		</table>
	  </div>
	  </div>
	<div class="col-sm-12" style="margin-bottom: 15px;">
      <?php echo $entry_adwords; ?>
    </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="promotion-id"><?php echo $entry_promotion_id; ?></label>
		    <div class="col-sm-7">
			  <input type="text" name="promotion_id" id="promotion-id" class="form-control" value="<?php echo $promotion_id; ?>" />
		    </div>
			<div class="col-sm-2">
			  <a onclick="clearField('promotion-id')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label"><?php echo $entry_custom_labels; ?></label>
		    <div class="col-sm-7">
				<?php for ($i=0; $i<=4; $i++) { ?>
				<strong><?php echo $text_custom_labels_group . $i . ' : ' . $custom_labels_group[$i]; ?></strong><br />
				<select name="custom_labels[<?php echo $i; ?>]" class="form-control">
				<option value="" selected="selected"><?php echo $text_do_not_change; ?></option>
				<?php foreach ($custom_labels[$i] as $label) { ?>
                <option value="<?php echo $label; ?>"><?php echo $label; ?></option>
				<?php } ?>
              </select><br /><br />
				<?php } ?>
				<hr />
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="adwords-grouping"><?php echo $entry_adwords_grouping; ?></label>
		    <div class="col-sm-7">
			  <input type="text" name="adwords_grouping" id="adwords-grouping" class="form-control" value="<?php echo $adwords_grouping; ?>" />
		    </div>
			<div class="col-sm-2">
			  <a onclick="clearField('adwords-grouping')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="adwords-labels"><span data-toggle="tooltip" title="<?php echo $help_adwords_labels; ?>"><?php echo $entry_adwords_labels; ?></label>
		    <div class="col-sm-7">
			  <input type="text" name="adwords_labels" id="adwords-labels" class="form-control" value="<?php echo $adwords_labels; ?>" />
		    </div>
			<div class="col-sm-2">
			  <a onclick="clearField('adwords-grouping')" data-toggle="tooltip" title="<?php echo $text_clear_field; ?>" class="btn btn-danger"><i class="fa fa-minus-circle"></i></a></div>
	      </div>
	      <div class="form-group">
		    <label class="col-sm-3 control-label" for="adwords-redirect"><span data-toggle="tooltip" title="<?php echo $help_adwords_redirect; ?>"><?php echo $entry_adwords_redirect; ?></span></label>
		    <div class="col-sm-7">
			  <select name="adwords_redirect" id="adwords-redirect" class="form-control">
				<option value="" selected="selected"><?php echo $text_do_not_change; ?></option>
                <option value="1"><?php echo $text_yes; ?></option>
                <option value="0"><?php echo $text_no; ?></option>
              </select>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
		  <hr />
	<div class="col-sm-12">
      <?php echo $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">
				<?php echo $entry_information; ?>
			  </div>
		    </div>
			<div class="col-sm-2"></div>
	      </div>
	  <div class="form-group">
	    <div class="col-sm-12">
        <table id="products" class="table table-striped table-bordered table-hover">
		  <thead>
			<tr>
				<td colspan="3"><?php echo ($entry_products . '(' . ($no_of_products + 1) . ')'); ?></td>
			</tr>
			</thead>
			
			<?php $ctr = 0; ?>
			<?php while ($ctr <= $no_of_products) { ?>

			<tr>
				<td width="33%" class="text-center">
				<?php echo ('<span style="color: #00c;"><strong>' . $products[$ctr]['name'] . '</strong></span><br />' . $products[$ctr]['model']); ?></td>

				<td width="34%" class="text-center">
				<?php if(isset($products[$ctr+1])) {echo ('<span style="color: #00c;"><strong>' . $products[$ctr+1]['name'] . '</strong></span><br />' . $products[$ctr+1]['model']);} ?></td>

				<td width="33%" class="text-center">
				<?php if(isset($products[$ctr+2])) {echo ('<span style="color: #00c;"><strong>' . $products[$ctr+2]['name'] . '</strong></span><br />' . $products[$ctr+2]['model']);} ?></td>
			</tr>



			<?php $ctr = $ctr+3 ?>
			<?php } ?>
		</table>
		</div>
	  </div>
	
	</form>
  </div>	
</div>
</div>
</div>

<script type="text/javascript"><!--
var variants_row = <?php echo $variants_row; ?>;

function addVariant() {
	html  = '<tbody id="variants_row' + variants_row + '">';
	html += '<tr>'; 
    html += '<td width="20%" class="text-center"><input type="text" name="product_variants[' + variants_row + '][size]" tabindex="' + (variants_row*4+12) +'" /></td>';
	html += '<td width="20%" class="text-center"><input type="text" name="product_variants[' + variants_row + '][colour]" tabindex="' + (variants_row*4+12) +'" /></td>';
    html += '<td width="20%" class="text-center"><input type="text" name="product_variants[' + variants_row + '][pattern]" tabindex="' + (variants_row*4+12) +'" /></td>';
	html += '<td width="20%" class="text-center"><input type="text" name="product_variants[' + variants_row + '][material]" tabindex="' + (variants_row*4+12) +'" /></td>';
	html += '<input type="hidden" name="product_variants[' + variants_row + '][image]" value="" />';
	html += '<input type="hidden" name="product_variants[' + variants_row + '][mpn]" value="" />';
	html += '<td class="text-right"><button type="button"  onclick="$(\'#variants_row' + variants_row + '\').remove();" class="btn btn-danger pull-right"><?php echo $button_remove; ?></button></td>';
	html += '</tr>';	
    html += '</tbody>';
	$('#variants tfoot').before(html);
		
	variants_row++;
}

//--></script>

<script type="text/javascript">
<!--
function clearField(fld) {
		var el = document.getElementById(fld);
		el.value = '<?php echo $text_clear_keyword; ?>';
}
//--></script>
<script type="text/javascript">
<!--
	function encode_variants(size_data, colour_data, pattern_data, material_data) {
		separator = '|';
		variant = '';
		for (var i = 0; i < size_data.length; i++) {
			if(size_data[i] != '' || colour_data[i] !='' || pattern_data[i] !='' || material_data[i] !='') {
				if(variant != '') {
					variant += separator;
				}
				variant += size + separator + colour_data[i] + separator + pattern_data[i] + separator + material_data[i];
				i++;
			}
		}
		return variant;
	}

	
//--></script>
<script type="text/javascript"><!--
$('.date').datetimepicker({
	pickTime: false
});

$('.time').datetimepicker({
	pickDate: false
});

$('.datetime').datetimepicker({
	pickDate: true,
	pickTime: true
});
//--></script> 
<script type="text/javascript">
<!--
function googleTaxonomy() {
	var href='http://www.google.com/basepages/producttype/taxonomy.<?php echo $gpf_lang; ?>.txt';
	window.open(href,"GoogleTaxonomy");
}
</script>

	
<?php echo $footer; ?>