<div class="form-container">

    {$has_at_least_one_combination = false}
    {$default_product_sale_element_id = 0}

    {loop name="product.sales.elements.test" type="product_sale_elements" product=$product_id currency=$edit_currency_id backend_context="1"}
        {loop name="product.combinations" type="attribute_combination" product_sale_elements="$ID"}
            {$has_at_least_one_combination = true}
        {/loop}

        {elseloop rel="product.combinations"}
            {$default_product_sale_element_id = $ID}
        {/elseloop}
    {/loop}

    {if $has_at_least_one_combination == false}
	    {form name="thelia.admin.product_default_sale_element.update"}
	    <form method="POST" action="{url path='/admin/product/default-price/update'}" {form_enctype form=$form} class="clearfix">

		    {include
		        file = "includes/inner-form-toolbar.html"
	            hide_submit_buttons = false
	            show_currencies = true

		        page_url  = "{url path='/admin/products/update' product_id=$ID}"
		        close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
		    }

	        {* Be sure to get the product ID and current tab, even if the form could not be validated *}
            <input type="hidden" name="product_id" value="{$product_id}" />
	        <input type="hidden" name="current_tab" value="prices" />

	        {form_hidden_fields form=$form}

            {form_field form=$form field='product_id'}
                <input type="hidden" name="{$name}" value="{$value}" />
            {/form_field}

            {form_field form=$form field='product_sale_element_id'}
                <input type="hidden" name="{$name}" value="{$default_product_sale_element_id}" />
            {/form_field}

            {form_field form=$form field='isdefault'}
                <input type="hidden" name="{$name}" value="{$value}" />
            {/form_field}

            {form_field form=$form field='reference'}
                <input type="hidden" name="{$name}" value="{$value}" />
            {/form_field}

	        {form_field form=$form field='success_url'}
	            <input type="hidden" name="{$name}" value="{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" />
	        {/form_field}

	        {loop type="currency" name="product-currency" id=$edit_currency_id backend_context="1"}

	            {$currency_symbol = $SYMBOL}
	            {$currency_name = $NAME}

	            {form_field form=$form field='currency'}
	                <input type="hidden" name="{$name}" value="{$ID}" />
	            {/form_field}

	            {$current_currency_is_default = $IS_DEFAULT}
	        {/loop}


            {if $form_error}
            <div class="row">
                <div class="col-md-12">
                    <div class="alert alert-danger">{$form_error_message}</div>
                </div>
            </div>
            {/if}

			<div class="row">
			    <div class="col-md-4">
			        {form_field form=$form field='tax_rule'}
			            <div class="form-group {if $error}has-error{/if}">
			                <label for="tax_rule_field" class="control-label">{$label} : </label>
			                <div class="form-group">
			                    <select id="tax_rule_field" required="required" name="{$name}" class="form-control">
			                        <option value="">{intl l="Select a tax tule"}</option>
			                        {loop name="tax" type="tax-rule" backend_context="1"}
			                            <option value="{$ID}" {if $ID == $TAX_RULE_ID}selected="selected"{/if}>{$TITLE}</option>
			                        {/loop}
			                    </select>
			                </div>

			            </div>
			        {/form_field}
			    </div>
			</div>

	        <p class="title title-without-tabs">{intl l='Pricing'}</p>

	        <p>{intl l="The default pricing is used when no combination is defined."}</p>

		    <div class="row">

		        {* -- Pricing ------------------------------------------------------- *}

		        <div class="col-md-4">
	                <div class="well well-sm">
			            <p class="title title-without-tabs">{intl l='Pricing'}</p>

			              <p></p> <!-- LAME !!! FIXME -->

	                      {form_field form=$form field='use_exchange_rate'}
	                          {if $current_currency_is_default}
	                             <input type="hidden" name="{$name}" value="0">
	                             {$show_pricing_fields = true}
	                          {else}
			                      <div class="form-group {if $error}has-error{/if}">
			                          <div class="checkbox">
			                              <label>
			                                  <input type="checkbox" data-pse-id="{$default_product_sale_element_id}" class="use_exchange_rate_box" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
			                                  {$label}
			                              </label>
			                          </div>
			                      </div>
			                      {$show_pricing_fields = ($value == 0)}
			                  {/if}
	                      {/form_field}

			              {form_field form=$form field='price'}
			                  <div class="form-group {if $error}has-error{/if}">
			                      <label for="price_without_tax" class="control-label">{$label} : </label>

			                         <div class="input-group">
			                             <input {if !$show_pricing_fields}readonly{/if} data-pse-id="{$default_product_sale_element_id}" data-price-type="price-without-tax" data-rel-price="price_with_tax" type="text" id="price_without_tax" required="required" name="{$name}" class="price_field automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Price excl. taxes'}">
			                             <span class="input-group-addon">{$currency_symbol}</span>
			                         </div>
			                  </div>
			              {/form_field}

                          {form_field form=$form field='price_with_tax'}
			                  <div class="form-group">
			                      <label for="price_with_tax" class="control-label">{intl l="Product price including taxes"} : </label>
			                      <div class="input-group">
			                          <input {if !$show_pricing_fields}readonly{/if} data-pse-id="{$default_product_sale_element_id}" data-price-type="price-with-tax" data-rel-price="price_without_tax" type="text" id="price_with_tax" name="{$name}" class="price_field automatic_price_field form-control" value="{$value}" title="{$value}" placeholder="{intl l='Price incl. taxes'}">
			                          <span class="input-group-addon">{$currency_symbol}</span>
			                      </div>
			                  </div>
                          {/form_field}

			              {module_include location='product_details_pricing_form'}
			          </div>
		        </div>


                 {* -- Détails -------------------------------------------------- *}

                 <div class="col-md-4">
                     <div class="well well-sm">
                        <p class="title title-without-tabs">{intl l='Stock'}</p>

						{form_field form=$form field='ean_code'}
						   <div class="form-group {if $error}has-error{/if}">
						       <label for="{$label_attr.for}" class="control-label">{$label} : </label>

						       <div class="form-group">
						           <input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product EAN Code'}">
						       </div>
						   </div>
						{/form_field}

                         {form_field form=$form field='weight'}
                            <div class="form-group {if $error}has-error{/if}">
                                <label for="{$label_attr.for}" class="control-label">{$label} : </label>

                                <div class="input-group">
                                    <input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product weight'}">
                                    <span class="input-group-addon">{intl l="Kg"}</span>
                                </div>
                            </div>
                         {/form_field}

                         {form_field form=$form field='quantity'}
                            <div class="form-group {if $error}has-error{/if}">
                                <label for="{$label_attr.for}" class="control-label">{$label} : </label>

                                <div class="form-group">
                                    <input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Current quantity'}">
                                </div>
                            </div>
                         {/form_field}

                         {module_include location='product_details_details_form'}
                    </div>
                </div>


		        {* -- Promotion ------------------------------------------------- *}

		        <div class="col-md-4">
	                <div class="well well-sm">
			            <p class="title title-without-tabs">{intl l='Promotion'}</p>

			            {form_field form=$form field='sale_price'}
			                <div class="form-group {if $error}has-error{/if}">
			                    <label for="sale_price_without_tax" class="control-label">{$label} : </label>

			                    <div class="input-group">
			                        <input {if !$show_pricing_fields}readonly{/if} data-pse-id="{$default_product_sale_element_id}" data-price-type="sale-price-without-tax" data-rel-price="sale_price_with_tax" type="text" id="sale_price_without_tax" required="required" name="{$name}" class="price_field automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}">
			                        <span class="input-group-addon">{$currency_symbol}</span>
			                    </div>
			               </div>
			            {/form_field}

                        {form_field form=$form field='sale_price_with_tax'}
                        <div class="form-group">
                            <label for="sale_price_with_tax" class="control-label">{$label} : </label>
                            <div class="input-group">
                                <input {if !$show_pricing_fields}readonly{/if} data-pse-id="{$default_product_sale_element_id}" data-price-type="sale-price-with-tax" data-rel-price="sale_price_without_tax" type="text" id="sale_price_with_tax" name="sale_price_with_tax" class="price_field automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Sale price incl. taxes'}">
                                <span class="input-group-addon">{$currency_symbol}</span>
                            </div>
                        </div>
                        {/form_field}

						{form_field form=$form field='onsale'}
						<div class="form-group {if $error}has-error{/if}">
						    <div class="checkbox">
						        <label>
						            <input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
						            {$label}
						        </label>
						    </div>
						</div>
						{/form_field}

			            {form_field form=$form field='isnew'}
			            <div class="form-group {if $error}has-error{/if}">
			                <div class="checkbox">
			                    <label>
			                        <input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
			                        {$label}
			                    </label>
			                </div>
			            </div>
			            {/form_field}

			            {module_include location='product_details_promotion_form'}
			        </div>
		         </div>
	        </div>
	    </form>
	    {/form}
    {/if}

    {* -- Attribute combinations -------------------------------------------- *}

    {if $has_at_least_one_combination}

       {form name="thelia.admin.product_sale_element.update"}
       <form method="POST" action="{url path='/admin/product/combinations/update'}" {form_enctype form=$form}>
            <div class="row">
                <div class="col-md-12">

					{include
					    file = "includes/inner-form-toolbar.html"
					    hide_submit_buttons = false
					    show_currencies = true
					    page_url  = "{url path='/admin/products/update' product_id=$ID}"
					    close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
					}

					{* Be sure to get the product ID and current tab, even if the form could not be validated *}
					<input type="hidden" name="product_id" value="{$product_id}" />
					<input type="hidden" name="current_tab" value="prices" />

					{form_hidden_fields form=$form}

					{form_field form=$form field='product_id'}
					    <input type="hidden" name="{$name}" value="{$value}" />
					{/form_field}

					{form_field form=$form field='success_url'}
					    <input type="hidden" name="{$name}" value="{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" />
					{/form_field}

	                {if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}

                    {loop type="currency" name="get-currency-symbol" id=$edit_currency_id backend_context="1"}
                        {$currency_symbol = $SYMBOL}
                        {$current_currency_is_default = $IS_DEFAULT}

                        {form_field form=$form field='currency'}
                            <input type="hidden" name="{$name}" value="{$ID}" />
                        {/form_field}
                    {/loop}

					<div class="row">
					    <div class="col-md-4">
					        {form_field form=$form field='tax_rule'}
					            <div class="form-group {if $error}has-error{/if}">
					                <label for="tax_rule_field" class="control-label">{$label} : </label>
					                <div class="form-group">
					                   <select id="tax_rule_field" required="required" name="{$name}" class="form-control">
					                        <option value="">{intl l="Select a tax tule"}</option>
					                        {loop name="tax" type="tax-rule" backend_context="1"}
					                            <option value="{$ID}" {if $ID == $TAX_RULE_ID}selected="selected"{/if}>{$TITLE}</option>
					                        {/loop}
					                    </select>
					                </div>
					            </div>
					        {/form_field}
					    </div>
					    <div class="col-md-4">
                          {form_field form=$form field='use_exchange_rate'}
                              {if $current_currency_is_default}
                                 <input type="hidden" name="{$name}" value="0">
                                 {$show_pricing_fields = true}
                              {else}
                                  <div class="form-group {if $error}has-error{/if}">
                                      <label>&nbsp;</label>
                                      <div class="checkbox">
                                          <label>
                                              <input type="checkbox" class="use_exchange_rate_box" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}>
                                              {$label}
                                          </label>
                                      </div>
                                  </div>
                                  {$show_pricing_fields = ($value == 0)}
                              {/if}
                          {/form_field}
					    </div>
					</div>

	                {module_include location='product_before_combinations'}

					<table class="table table-striped table-condensed" id="category_list">
					    <caption>
					        {intl l='Attribute Combinations'}

					        {module_include location='product_combinations_list_caption'}

					        {loop type="auth" name="can_create" role="ADMIN" resource="admin.product" access="UPDATE"}
                            <a class="btn btn-default btn-primary action-btn" id="open_combination_builder" title="{intl l='Quickly create combinations using the combination builder'}" href="#combination_builder_dialog" data-toggle="modal">
                                {intl l='Combination builder'}
                            </a>
					        <a class="btn btn-default btn-primary action-btn" title="{intl l='Add a new combination'}" href="#combination_creation_dialog" data-toggle="modal">
					            <span class="glyphicon glyphicon-plus-sign"></span>
					        </a>
					        {/loop}
					    </caption>

					    <thead>
					        <tr>
                                <th class="text-center">{intl l='Reference'}</th>
                                <th class="text-center">{intl l='EAN Code'}</th>
                                <th class="text-center">{intl l='Stock'}</th>
								<th class="text-center">{intl l='Price<br />w/o taxes (%currency)' currency={$currency_symbol}}</th>
								<th class="text-center">{intl l='Price<br />w/ taxes (%currency)' currency={$currency_symbol}}</th>
								<th class="text-center">{intl l='Weight<br />(Kg)'}</th>
                                <th class="text-center">{intl l='Default'}</th>
                                <th class="text-center">{intl l='Sale'}</th>
                                <th class="text-center">{intl l='New'}</th>
								<th class="text-center">{intl l='Sale price<br />w/o taxes (%currency)' currency={$currency_symbol}}</th>
								<th class="text-center">{intl l='Sale price<br />w/ taxes (%currency)' currency={$currency_symbol}}</th>
								<th class="actions">&nbsp;</th>
					        </tr>
					    </thead>

					    <tbody>
	                        {* Get number of PSE defined, assumin the form have the same number of values for each fields *}

	                        {form_field form=$form field='product_sale_element_id' value_key=0}
	                           {$pse_count = $total_value_count}
	                        {/form_field}

	                        {for $idx = 0 to $total_value_count-1}
	                        <tr>
                                <td colspan="10">

			                    {form_field form=$form field='product_sale_element_id' value_key=$idx}
			                        <input type="hidden" name="{$name}" value="{$value}" />

                                    {$current_pse_id = $value}

	                                {loop name="product.sales.elements.combinations" type="attribute_combination" product_sale_elements=$current_pse_id backend_context="1"}
	                                    {if $LOOP_COUNT > 1} - {/if}{$ATTRIBUTE_TITLE}
	                                {/loop}
                                {/form_field}
                                </td>

                                <td colspan="2" class="text-right">ID: {$current_pse_id}</td>
	                        </tr>

                            <tr>
                                {form_field form=$form field='reference' value_key=$idx}
                                <td {if $error}class="has-error"{/if}><input class="form-control" type="text" name="{$name}" value="{$value}" /></td>
                                {/form_field}

                                {form_field form=$form field='ean_code' value_key=$idx}
                                <td {if $error}class="has-error"{/if}><input class="form-control" type="text" name="{$name}" value="{$value}" /></td>
                                {/form_field}

                                {form_field form=$form field='quantity' value_key=$idx}
                                <td {if $error}class="has-error"{/if}>
                                    <input class="form-control text-right" required type="text" name="{$name}" value="{$value}" />
                                </td>
                                {/form_field}

                                {form_field form=$form field='price' value_key=$idx}
                                <td {if $error}class="has-error"{/if}><input {if !$show_pricing_fields}readonly{/if} required data-price-type="price-without-tax" data-rel-price="price_with_tax_{$idx}" id="price_without_tax_{$idx}" class="price_field automatic_price_field form-control text-right" required type="text" name="{$name}" value="{$value}" /></td>
                                {/form_field}

                                {form_field form=$form field='price_with_tax' value_key=$idx}
                                <td {if $error}class="has-error"{/if}><input {if !$show_pricing_fields}readonly{/if} data-price-type="price-with-tax" data-rel-price="price_without_tax_{$idx}" id="price_with_tax_{$idx}" class="price_field automatic_price_field form-control text-right" type="text" name="{$name}" value="{$value}" /></td>
                                {/form_field}

                                {form_field form=$form field='weight' value_key=$idx}
                                <td {if $error}class="has-error"{/if}><input required class="form-control text-right" type="text" name="{$name}" value="{$value}" /></td>
                                {/form_field}


                                {form_field form=$form field='default_pse'}
                                <td class="{if $error}has-error {/if}text-center">
                                    <input class="form-control" type="radio" name="{$name}" value="{$current_pse_id}" {if $value == $current_pse_id}checked="checked"{/if}/>
                                </td>
                                {/form_field}

                                {form_field form=$form field='onsale' value_key=$idx}
                                <td class="{if $error}has-error {/if}text-center">
                                    <input class="form-control" type="checkbox" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}/>
                                </td>
                                {/form_field}

                                {form_field form=$form field='isnew' value_key=$idx}
                                <td class="{if $error}has-error {/if}text-center">
                                     <input class="form-control" type="checkbox" name="{$name}" value="1" {if $value != 0}checked="checked"{/if}/>
                                </td>
                                {/form_field}

                                {form_field form=$form field='sale_price' value_key=$idx}
                                <td {if $error}class="has-error"{/if}>
                                    <input {if !$show_pricing_fields}readonly{/if} required data-price-type="sale-price-without-tax" data-rel-price="sale_price_with_tax_{$idx}" id="sale_price_without_tax_{$idx}" class="price_field automatic_price_field form-control text-right" type="text" name="{$name}" value="{$value}"  />
                                </td>
                                {/form_field}

                                {form_field form=$form field='sale_price_with_tax' value_key=$idx}
                                <td {if $error}class="has-error"{/if}>
                                    <input {if !$show_pricing_fields}readonly{/if} data-price-type="sale-price-with-tax" data-rel-price="sale_price_without_tax_{$idx}" id="sale_price_with_tax_{$idx}" class="price_field automatic_price_field form-control text-right" type="text" name="{$name}" value="{$value}"  />
                                </td>
                                {/form_field}

                                <td class="actions">
                                    <a class="btn btn-default btn-xs combination-delete" title="{intl l='Delete this combination'}"  href="#combination_delete_dialog" data-id="{$current_pse_id}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
                                </td>
                            </tr>
	                        {/for}
					    </tbody>
					</table>

	                {module_include location='product_after_combinations'}
	            </div>
	        </div>

        </form>
        {/form}
    {/if}

    {if $has_at_least_one_combination == false}
       <div class="row">
           <div class="col-md-12">
		        <p class="title title-without-tabs">{intl l='Attribute Combinations'}</p>

		        <div class="alert alert-info">
			        <p>{intl
			             l='This product has no combination. The default price is used. <a data-toggle="modal" href="%url">Click here to create a new combination</a>.'
			             url='#combination_creation_dialog'
			        }</p>
			        <p>
			          {intl
			             l='You may also quickly create combinations from products attributes using the  <a href="%url" data-toggle="modal">Combination Builder</a>.'
			             url='#combination_builder_dialog'
			          }
			        </p>
		        </div>
		    </div>
		</div>
    {/if}

{module_include location='product_after_combinations'}
	</div>

{* -- Adding a new combination ------------------------------------------------- *}

{* Capture the dialog body, to pass it to the generic dialog *}

{capture "combination_creation_dialog"}

    <input type="hidden" name="product_id" value="{$product_id}" />
    <input type="hidden" name="current_tab" value="prices" />

	<div class="form-group">
	   <label class="control-label">{intl l="Attribute"} : </label>
	   <select  name="attribute_id" id="attribute_id" class="form-control">
	       <option value="">{intl l='Select an attribute...'}</option>
	       {loop name="product-attributes" type="attribute" order="manual" product=$product_id backend_context="1" lang=$edit_language_id}
	           <option value="{$ID}">{$TITLE}</option>
	       {/loop}
	   </select>
	   <span class="help-block">{intl l='Select an attribute and click (+) to view available values'}</span>
	</div>


	<div id="attribute_value_selector" class="hide">
	    <div class="input-group">
	        {* <label class="control-label">{intl l="Attribute values"} : </label> *}

	        <select name="attribute_value_id" id="attribute_value_id" class="form-control">
	            <option value="">{intl l='Select an attribute value...'}</option>
	        </select>

	        <span class="input-group-btn" id="add_attr_value_button">
	           <button class="btn btn-default btn-primary action-btn add-value-to-combination" type="button"><span class="glyphicon glyphicon-plus-sign"></span></button>
	        </span>
	    </div>

	    <span class="help-block">{intl l='Select a value click (+) to add it to the combination'}</span>
	</div>

	<div id="attribute_value_selector_empty" class="hide">
	    <div class="alert alert-info">
	       {intl l="No available value for this attribute"}
	   </div>
	</div>

	<div class="form-group">
	    <div class="alert alert-danger hide" id="combination_attributes_error"></div>

	    <select required="required" multiple="multiple" size="5" name="combination_attributes[]" id="combination_attributes" class="form-control">
	    </select>

	    <div class="help-block">
	        {intl l='To remove a value from the combination, select it and click "remove"'}

	        <div class="pull-right">
	            <button class="btn btn-info btn-xs remove-value-from-combination" type="button">
	                {intl l="Remove selected values"} <span class="glyphicon glyphicon-minus-sign"></span>
	            </button>
	        </div>
	    </div>
	</div>

{/capture}

{include
    file = "includes/generic-create-dialog.html"

    dialog_id    = "combination_creation_dialog"
    dialog_title = {intl l="Create a new combination"}
    dialog_body  = {$smarty.capture.combination_creation_dialog nofilter}

    dialog_ok_label     = {intl l="Create this combination"}

    form_action        = {url path='/admin/product/combination/add'}
    form_enctype       = ''
    form_error_message = ''

    ok_button_id = "combination_creation_dialog_ok"
}


{* -- Delete combination confirmation dialog ----------------------------------- *}

{capture "combination_delete_dialog"}

    <input type="hidden" name="product_id" value="{$product_id}" />
    <input type="hidden" name="current_tab" value="prices" />

    <input type="hidden" name="product_sale_element_id" id="combination_delete_id" value="" />

    {module_include location='category_delete_form'}

{/capture}

{include
    file = "includes/generic-confirm-dialog.html"

    dialog_id       = "combination_delete_dialog"
    dialog_title    = {intl l="Delete a combination"}
    dialog_message  = {intl l="Do you really want to delete this combination ?"}

    form_action     = {url path='/admin/product/combination/delete'}
    form_content    = {$smarty.capture.combination_delete_dialog nofilter}
}

{* -- Combination builder dialog -------------------------------------------- *}

{* Capture the dialog body, to pass it to the generic dialog *}

{form name="thelia.admin.product_combination.build"}

{capture "combination_builder_dialog"}

    {* Be sure to get the product ID and current tab, even if the form could not be validated *}
    <input type="hidden" name="product_id" value="{$product_id}" />
    <input type="hidden" name="current_tab" value="prices" />

    {form_hidden_fields form=$form}

    {form_field form=$form field='product_id'}
        <input type="hidden" name="{$name}" value="{$product_id}" />
    {/form_field}

    {if $form_error}<div class="alert alert-danger" id="combination_builder_dialog_error">{$form_error_message}</div>{/if}

    {loop type="currency" name="get-currency-symbol" id=$edit_currency_id backend_context="1"}
        {$currency_symbol = $SYMBOL}

        {form_field form=$form field='currency'}
            <input type="hidden" name="{$name}" value="{$ID}" />
        {/form_field}
    {/loop}

    {form_field form=$form field='success_url'}
         <input type="hidden" name="{$name}" value="{url path='/admin/products/update' product_id=$product_id current_tab='prices'}" />
    {/form_field}

    <div class="alert alert-info">
        {intl l='Select attribute values to combine. You may enter a default value for some of the fields of the generated combinations.'}
    </div>

    <div class="row">
        <div class="col-md-6">
		    <div class="scrollable">
		        <ul class="list-unstyled">
		        {$index = 0}
		        {loop name="product-attributes" type="attribute" order="manual" product=$product_id backend_context="1" lang=$edit_language_id}
		            {ifloop rel="product-attributes-av"}
		            <li>
		                <strong>{$TITLE}</strong>
		                <ul class="list-unstyled">
		                {loop name="product-attributes-av" type="attribute_availability" attribute="{$ID}" order="manual" backend_context="1" lang=$edit_language_id}
		                    <li>
			                    <div class="checkbox">
			                        <label>
			                            {form_field form=$form field='attribute_av' value_key=$index}
			                            <input data-attribute-id="{$ATTRIBUTE_ID}" class="attribute_av_value" type="checkbox" name="{$name}" value="{$ATTRIBUTE_ID}:{$ID}" {if $value == "$ATTRIBUTE_ID:$ID"}checked="checked"{/if}>{$TITLE}
			                            {/form_field}
			                        </label>
			                    </div>
		                    </li>
		                    {$index = $index + 1}
		                {/loop}
		                </ul>
		            </li>
		            {/ifloop}
		        {/loop}
		        </ul>
		    </div>
		</div>

		<div class="col-md-6">
         {form_field form=$form field='price'}
             <div class="form-group {if $error}has-error{/if}">
                 <label for="price_without_tax" class="control-label">{$label} : </label>

                    <div class="input-group">
                        <input type="text" id="price_without_tax" name="{$name}" class="price_field automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Price excl. taxes'}">
                        <span class="input-group-addon">{$currency_symbol}</span>
                    </div>
             </div>
         {/form_field}

         {form_field form=$form field='reference'}
            <div class="form-group {if $error}has-error{/if}">
                <label for="{$label_attr.for}" class="control-label">{$label} : </label>

                <div class="form-group">
                    <input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Combination reference'}">
                </div>
            </div>
         {/form_field}

         {form_field form=$form field='ean_code'}
            <div class="form-group {if $error}has-error{/if}">
                <label for="{$label_attr.for}" class="control-label">{$label} : </label>

                <div class="form-group">
                    <input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Combination EAN Code'}">
                </div>
            </div>
         {/form_field}

         <div class="row">
            <div class="col-md-6">
	            {form_field form=$form field='weight'}
	            <div class="form-group {if $error}has-error{/if}">
	                <label for="{$label_attr.for}" class="control-label">{$label} : </label>

	                <div class="input-group">
	                    <input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product weight'}">
	                    <span class="input-group-addon">{intl l="Kg"}</span>
	                </div>
	            </div>
	            {/form_field}
	         </div>

	          <div class="col-md-6">
	          {form_field form=$form field='quantity'}
	             <div class="form-group {if $error}has-error{/if}">
	                 <label for="{$label_attr.for}" class="control-label">{intl l='Stock'} : </label>

	                 <div class="form-group">
	                     <input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Current quantity'}">
	                 </div>
	             </div>
	          {/form_field}
	          </div>
	     </div>

         {form_field form=$form field='sale_price'}
             <div class="form-group {if $error}has-error{/if}">
                 <label for="sale_price_without_tax" class="control-label">{$label} : </label>
                 <div class="input-group">
                     <input type="text" id="sale_price_without_tax" name="{$name}" class="price_field automatic_price_field form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}">
                     <span class="input-group-addon">{$currency_symbol}</span>
                 </div>
            </div>
         {/form_field}

		 {form_field form=$form field='onsale'}
	     <div class="form-group {if $error}has-error{/if}">
	        <div class="checkbox">
	            <label>
	                <input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1">
	                {$label}
	            </label>
	        </div>
	     </div>
	     {/form_field}

         {form_field form=$form field='isnew'}
         <div class="form-group {if $error}has-error{/if}">
             <div class="checkbox">
                 <label>
                     <input type="checkbox" id="{$label_attr.for}" name="{$name}" value="1">
                     {$label}
                 </label>
             </div>
         </div>
         {/form_field}

         <div class="well well-sm" style="margin-bottom: 0"><b>{intl l='<span id="number_of_generated_combinations">0</span> combinations'}</b></div>
    </div>
</div>

{/capture}

{include
    file = "includes/generic-create-dialog.html"

    dialog_id    = "combination_builder_dialog"
    dialog_title = {intl l="Create combinations"}
    dialog_body  = {$smarty.capture.combination_builder_dialog nofilter}

    dialog_ok_label     = {intl l="Create combinations"}

    form_action        = {url path='/admin/product/combination/build'}
    form_enctype       = {form_enctype form=$form}
    form_error_message = ''

    ok_button_id = "combination_builder_dialog_ok"
}

{/form}
