Combination creation management
This commit is contained in:
@@ -30,6 +30,13 @@ $('#{$dialog_id}').on('hidden.bs.modal', function() {
|
||||
// Clear error status
|
||||
$("#{$dialog_id} .error").removeClass('error');
|
||||
|
||||
$('#{$dialog_id} .form-group').removeClass('has-error')
|
||||
|
||||
// Empty field values
|
||||
$("#{$dialog_id} input[type=text], #{$dialog_id} select").val('');
|
||||
|
||||
// Uncheck boxes
|
||||
$("#{$dialog_id} input[type=checkbox]").removeAttr('checked');
|
||||
|
||||
{$additionnal_js_code|default:''}
|
||||
});
|
||||
@@ -26,9 +26,8 @@
|
||||
close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
|
||||
}
|
||||
|
||||
{* Be sure to get the product ID, even if the form could not be validated *}
|
||||
{* 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="details" />
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
@@ -177,8 +176,6 @@
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{module_include location='product_details_shipping_form'}
|
||||
|
||||
{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>
|
||||
@@ -189,7 +186,7 @@
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{module_include location='product_details_quantity_form'}
|
||||
{module_include location='product_details_details_form'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -268,9 +265,8 @@
|
||||
close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
|
||||
}
|
||||
|
||||
{* Be sure to get the product ID, even if the form could not be validated *}
|
||||
{* 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="details" />
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
@@ -340,7 +336,7 @@
|
||||
{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" title="{intl l='Quickly create combinations using the combination builder'}" href="#combination_generator_dialog" data-toggle="modal">
|
||||
<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">
|
||||
@@ -358,8 +354,8 @@
|
||||
<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'}</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"> </th>
|
||||
@@ -375,18 +371,20 @@
|
||||
|
||||
{for $idx = 0 to $total_value_count-1}
|
||||
<tr>
|
||||
<td colspan="12">
|
||||
<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}
|
||||
|
||||
{$current_pse_id}: {loop name="product.sales.elements.combinations" type="attribute_combination" product_sale_elements=$current_pse_id backend_context="1"}
|
||||
{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>
|
||||
@@ -469,10 +467,16 @@
|
||||
<p class="title title-without-tabs">{intl l='Attribute Combinations'}</p>
|
||||
|
||||
<div class="alert alert-info">
|
||||
{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>{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>
|
||||
@@ -494,7 +498,7 @@
|
||||
<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" product=$product_id backend_context="1" lang=$edit_language_id}
|
||||
{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>
|
||||
@@ -583,3 +587,184 @@
|
||||
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="details" />
|
||||
|
||||
{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='details'}" />
|
||||
{/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='Quantity'} : </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}
|
||||
|
||||
Reference in New Issue
Block a user