Finished product combination basic function

This commit is contained in:
franck
2013-09-23 18:36:55 +02:00
parent 4e8f4061af
commit 67bf7bb989
8 changed files with 387 additions and 260 deletions

View File

@@ -1,259 +1,290 @@
<div class="form-container">
{form name="thelia.admin.product.details.modification"}
<form method="POST" action="{url path='/admin/products/details/save'}" {form_enctype form=$form} class="clearfix">
{loop name="product.sales.elements.test" type="product_sale_elements" product=$product_id currency=$edit_currency_id backend_context="1"}
{/loop}
{include
file = "includes/inner-form-toolbar.html"
hide_submit_buttons = false
show_currencies = true
{elseloop rel="product.sales.elements.test"}
{form name="thelia.admin.product.details.modification"}
<form method="POST" action="{url path='/admin/product/default-price/update'}" {form_enctype form=$form} class="clearfix">
page_url = "{url path='/admin/products/update' product_id=$ID}"
close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
}
{include
file = "includes/inner-form-toolbar.html"
hide_submit_buttons = false
show_currencies = true
{* Be sure to get the product ID, even if the form could not be validated *}
<input type="hidden" name="product_id" value="{$product_id}" />
page_url = "{url path='/admin/products/update' product_id=$ID}"
close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}"
}
<input type="hidden" name="current_tab" value="details" />
{* Be sure to get the product ID, even if the form could not be validated *}
<input type="hidden" name="product_id" value="{$product_id}" />
{form_hidden_fields form=$form}
<input type="hidden" name="current_tab" value="details" />
{form_field form=$form field='id'}
<input type="hidden" name="{$name}" value="{$value}" />
{/form_field}
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" />
{/form_field}
{form_field form=$form field='id'}
<input type="hidden" name="{$name}" value="{$value}" />
{/form_field}
{loop type="currency" name="product-currency" id=$edit_currency_id backend_context="1"}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" />
{/form_field}
{$currency_symbol = $SYMBOL}
{$currency_name = $NAME}
{loop type="currency" name="product-currency" id=$edit_currency_id backend_context="1"}
{form_field form=$form field='currency'}
<input type="hidden" name="{$name}" value="{$ID}" />
{/form_field}
{/loop}
{$currency_symbol = $SYMBOL}
{$currency_name = $NAME}
<p class="title title-without-tabs">{intl l='Default pricing'}</p>
{form_field form=$form field='currency'}
<input type="hidden" name="{$name}" value="{$ID}" />
{/form_field}
{/loop}
<p>{intl l="The default pricing is used with product that do not have any combinations. It is also used for product with combinations which share the same pricing information"}</p>
<p class="title title-without-tabs">{intl l='Default pricing'}</p>
<div class="row">
<p>{intl l="The default pricing is used with product that do not have any combinations. It is also used for product with combinations which share the same pricing information"}</p>
{* -- Pricing ------------------------------------------------------- *}
<div class="row">
<div class="col-md-4">
<div class="well well-sm">
<p class="title title-without-tabs">{intl l='Pricing'}</p>
{* -- Pricing ------------------------------------------------------- *}
<p></p> <!-- LAME !!! FIXME -->
<div class="col-md-4">
<div class="well well-sm">
<p class="title title-without-tabs">{intl l='Pricing'}</p>
{form_field form=$form field='price'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
<p></p> <!-- LAME !!! FIXME -->
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="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='price'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
{form_field form=$form field='tax_rule'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
<div class="form-group">
<select id="{$label_attr.for}" 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 $IS_DEFAULT}selected="selected"{/if}>{$TITLE}</option>
{/loop}
</select>
</div>
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}">
<span class="input-group-addon">{$currency_symbol}</span>
</div>
</div>
{/form_field}
</div>
{/form_field}
{form_field form=$form field='tax_rule'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
<div class="form-group">
<select id="{$label_attr.for}" 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 $IS_DEFAULT}selected="selected"{/if}>{$TITLE}</option>
{/loop}
</select>
</div>
{form_field form=$form field='price_with_tax'}
<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}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}">
<span class="input-group-addon">{$currency_symbol}</span>
</div>
</div>
{/form_field}
</div>
{/form_field}
{module_include location='product_details_pricing_form'}
</div>
{form_field form=$form field='price_with_tax'}
<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}" required="required" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Product price'}">
<span class="input-group-addon">{$currency_symbol}</span>
</div>
</div>
{/form_field}
{module_include location='product_details_pricing_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="{$label_attr.for}" class="control-label">{$label} : </label>
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="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" {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>
{* -- Shipping -------------------------------------------------- *}
<div class="col-md-4">
<div class="well well-sm">
<p class="title title-without-tabs">{intl l='Shipping'}</p>
{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}" required="required" 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}
{module_include location='product_details_shipping_form'}
<p class="title title-without-tabs">{intl l='Quantity'}</p>
{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_quantity_form'}
</div>
</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="{$label_attr.for}" class="control-label">{$label} : </label>
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" class="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" {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>
{* -- Shipping -------------------------------------------------- *}
<div class="col-md-4">
<div class="well well-sm">
<p class="title title-without-tabs">{intl l='Shipping'}</p>
{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}" required="required" 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}
{module_include location='product_details_shipping_form'}
<p class="title title-without-tabs">{intl l='Quantity'}</p>
{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_quantity_form'}
</div>
</div>
</div>
</form>
{/form}
</form>
{/form}
{/elseloop}
{* -- Attribute combinations -------------------------------------------- *}
{module_include location='product_before_combinations'}
<div class="row">
<div class="col-md-12">
<div class="well well-sm">
<table class="table table-striped table-condensed" id="category_list">
<caption>
{intl l='Attribute Combinations'}
{ifloop rel="product.sales.elements"}
<form method="POST" action="{url path='/admin/product/combinations/update'}">
{module_include location='product_combinations_list_caption'}
{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}"
}
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.products.update"}
<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>
{module_include location='product_before_combinations'}
<thead>
<tr>
<th>{intl l='Attributes'}</th>
<th class="text-center">{intl l='Quantity'}</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 (Kg)'}</th>
<th class="text-center">{intl l='Is new'}</th>
<th class="text-center">{intl l='On 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">{intl l='Actions'}</th>
</tr>
</thead>
<table class="table table-striped table-condensed" id="category_list">
<caption>
{intl l='Attribute Combinations'}
<tbody>
{loop name="product.sales.elements" type="product_sale_elements" product=$product_id currency=$edit_currency_id}
<tr>
<td>
{loop name="product.sales.elements.combinations" type="attribute_combination" product_sale_elements=$ID}
{$ATTRIBUTE_TITLE}&nbsp;
{/loop}
</td>
{module_include location='product_combinations_list_caption'}
<td><input class="form-control text-right" type="text" name="quantity[{$ID}]" value="{format_number number=$QUANTITY}" /></td>
<td><input class="form-control text-right" type="text" name="price_wo_taxes[{$ID}]" value="{format_number number=$PRICE_TAX}" /></td>
<td><input class="form-control text-right" type="text" name="price_w_taxes[{$ID}]" value="{format_number number=$TAXED_PRICE}" /></td>
<td><input class="form-control text-right" type="text" name="weight[{$ID}]" value="{format_number number=$WEIGHT}" /></td>
{loop type="auth" name="can_create" roles="ADMIN" permissions="admin.products.update"}
<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>
<td>
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input class="change-default" type="radio" name="on_sale[{$ID}]" value="{$ID}" {if $IS_PROMO}checked="checked"{/if}/>
</div>
</td>
<thead>
<tr>
<th>{intl l='Attributes'}</th>
<th class="text-center">{intl l='Quantity'}</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 (Kg)'}</th>
<th class="text-center">{intl l='Default'}</th>
<th class="text-center">{intl l='Is new'}</th>
<th class="text-center">{intl l='On 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">{intl l='Actions'}</th>
</tr>
</thead>
<td>
<div class="make-switch switch-small" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input class="change-default" type="radio" name="is_new[{$ID}]" value="{$ID}" {if $IS_NEW}checked="checked"{/if}/>
</div>
</td>
<tbody>
{loop name="product.sales.elements" type="product_sale_elements" product=$product_id currency=$edit_currency_id backend_context="1"}
<tr>
<td>
{loop name="product.sales.elements.combinations" type="attribute_combination" product_sale_elements=$ID backend_context="1"}
{$ATTRIBUTE_TITLE}&nbsp;
{/loop}
</td>
<td><input class="form-control text-right" type="text" name="sale_price_wo_taxes[{$ID}]" value="{format_number number=$PROMO_PRICE_TAX}" /></td>
<td><input class="form-control text-right" type="text" name="sale_price_w_taxes[{$ID}]" value="{format_number number=$TAXED_PROMO_PRICE}" /></td>
<td><input class="form-control text-right" type="text" name="quantity[{$ID}]" value="{$QUANTITY}" /></td>
<td><input class="form-control text-right" type="text" name="price_wo_taxes[{$ID}]" value="{format_number number=$PRICE}" /></td>
<td><input class="form-control text-right" type="text" name="price_w_taxes[{$ID}]" value="{format_number number=$TAXED_PRICE}" /></td>
<td><input class="form-control text-right" type="text" name="weight[{$ID}]" value="{$WEIGHT}" /></td>
<td class="text-center">
<input class="form-control" type="radio" name="default" value="{$ID}" {if $IS_DEFAULT}checked="checked"{/if}/>
</td>
<td class="text-center">
<input class="form-control" type="checkbox" name="on_sale[{$ID}]" value="{$ID}" {if $IS_PROMO}checked="checked"{/if}/>
</td>
<td class="text-center">
<input class="form-control" type="checkbox" name="is_new[{$ID}]" value="{$ID}" {if $IS_NEW}checked="checked"{/if}/>
</td>
<td><input class="form-control text-right" type="text" name="sale_price_wo_taxes[{$ID}]" value="{format_number number=$PROMO_PRICE}" /></td>
<td><input class="form-control text-right" type="text" name="sale_price_w_taxes[{$ID}]" value="{format_number number=$TAXED_PROMO_PRICE}" /></td>
<td class="actions">
<a class="btn btn-default btn-xs combination-delete" title="{intl l='Delete this combination'}" href="#combination_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
</td>
</tr>
{/loop}
</tbody>
</table>
{module_include location='product_after_combinations'}
</form>
{/ifloop}
{elseloop rel="product.sales.elements"}
<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'
}
</div>
{/elseloop}
{module_include location='product_after_combinations'}
<td class="actions">
<a class="btn btn-default btn-xs combination-delete" title="{intl l='Delete this combination'}" href="#combination_delete_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
</div>
</div>
{module_include location='product_after_combinations'}
</div>
{* -- Adding a new combination ------------------------------------------------- *}
{* Capture the dialog body, to pass it to the generic dialog *}
@@ -314,17 +345,6 @@
</div>
</div>
{form_field form=$form field='isnew'}
<div class="form-group {if $error}has-error{/if}">
<div class="checkbox">
<label>
<input type="checkbox" id="use_default_princing" name="use_default_princing" value="1">
{intl l="Use default princing for this combination (you can change this later)"}
</label>
</div>
</div>
{/form_field}
{/capture}
{include
@@ -351,7 +371,7 @@
<input type="hidden" name="product_id" value="{$product_id}" />
<input type="hidden" name="current_tab" value="details" />
<input type="hidden" name="combination_id" id="combination_delete_id" value="" />
<input type="hidden" name="product_sale_element_id" id="combination_delete_id" value="" />
{module_include location='category_delete_form'}
@@ -364,6 +384,6 @@
dialog_title = {intl l="Delete a combunation"}
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}
form_action = {url path='/admin/product/combination/delete'}
form_content = {$smarty.capture.combination_delete_dialog nofilter}
}