tax rule set default in back office

This commit is contained in:
Etienne Roudeix
2013-10-17 15:31:09 +02:00
parent dad2591a57
commit dc2de702e8
6 changed files with 97 additions and 18 deletions

View File

@@ -55,9 +55,9 @@
</caption>
<thead>
<tr>
<th>{intl l="Name"}</th>
<th>{intl l="Description"}</th>
<th>{intl l="Actions"}</th>
<th class="col-md-3">{intl l="Name"}</th>
<th class="col-md-5">{intl l="Description"}</th>
<th class="col-md-1">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
@@ -100,9 +100,10 @@
</caption>
<thead>
<tr>
<th>{intl l="Name"}</th>
<th>{intl l="Description"}</th>
<th>{intl l="Actions"}</th>
<th class="col-md-3">{intl l="Name"}</th>
<th class="col-md-4">{intl l="Description"}</th>
<th class="col-md-1">{intl l="Default"}</th>
<th class="col-md-1">{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
@@ -112,13 +113,19 @@
<tr>
<td>{$TITLE}</td>
<td>{$DESCRIPTION}</td>
<td>
{if $IS_DEFAULT == 1}
<span class="glyphicon glyphicon-ok"></span>
{/if}
</td>
<td>
<div class="btn-group">
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes-rules.change"}
<a class="btn btn-default btn-xs" title="{intl l='Change this tax rule'}" href="{url path="/admin/configuration/taxes_rules/update/$ID"}"><span class="glyphicon glyphicon-edit"></span></a>
<a class="btn btn-default btn-xs" title="{intl l='Set as default tax rule'}" href="{url path="/admin/configuration/taxes_rules/update/set_default/$ID"}" {if $IS_DEFAULT == 1}disabled{/if}><span class="glyphicon glyphicon-star"></span></a>
{/loop}
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes-rules.change"}
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes-rules.dele"}
<a class="btn btn-default btn-xs js-delete-tax-rule" title="{intl l='Delete this tax rule'}" href="#tax_rule_delete_dialog" data-id="{$ID}" data-toggle="modal"><span class="glyphicon glyphicon-trash"></span></a>
{/loop}
</div>
@@ -157,12 +164,10 @@
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
{/form_field}
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l=$label} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="form-control" value="{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$TITLE}{/if}{/if}">
<input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="form-control" value="{if $form_error}{$value}{else}{if $IS_TRANSLATED == 1}{$TITLE}{/if}{/if}">
</div>
{/form_field}
@@ -173,7 +178,7 @@
<span class="label-help-block">{intl l="The detailed description."}</span>
</label>
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control wysiwyg">{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$DESCRIPTION}{/if}{/if}</textarea>
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control wysiwyg">{if $form_error}{$value}{else}{if $IS_TRANSLATED == 1}{$DESCRIPTION}{/if}{/if}</textarea>
</div>
{/form_field}
@@ -184,15 +189,37 @@
</label>
<div class="form-group">
<select name="{$name}" data-toggle="selectpicker">
{foreach $choices as $choice}
<option value="{$choice->value}" {if $choice->value == $TYPE}selected="selected" {/if}>{$choice->label}</option>
<select name="{$name}" class="js-change-tax-type" data-toggle="selectpicker">
{$typeValueWithError = $value}
{foreach from=$choices key=key item=choice}
{if $key == 0}
{$typeValue = $choice->value}
{/if}
<option value="{$choice->value}" {if $form_error && $choice->value == $value || !$form_error && $key == 0}selected="selected" {/if}>{$choice->label}</option>
{/foreach}
</select>
</div>
</div>
{/form_field}
{form_tagged_fields form=$form tag='requirements'}
<div class="form-group {if $error}has-error{/if} js-tax-requirements" data-tax-type="{$attr_list.tax_type}" {if !$form_error && $attr_list.tax_type != $typeValue || $form_error && $attr_list.tax_type != $typeValueWithError}style="display: none"{/if}>
<label for="{$label_attr.for}" class="control-label">
{intl l=$label}
</label>
{if $formType == 'choice'}
<select name="{$name}" data-toggle="selectpicker" {if !$form_error && $attr_list.tax_type != $typeValue || $form_error && $attr_list.tax_type != $typeValueWithError}disabled="disabled"{/if}>
{foreach $choices as $choice}
<option value="{$choice->value}" {if !$form_error && $REQUIREMENTS.$label == $choice->value || $form_error && $value == $choice->value}selected="selected" {/if}>{$choice->label}</option>
{/foreach}
</select>
{/if}
{if $formType == 'text'}
<input type="text" {if !$form_error && $attr_list.tax_type != $typeValue || $form_error && $attr_list.tax_type != $typeValueWithError}disabled="disabled"{/if} id="{$label_attr.for}" name="{$name}" required="required" class="form-control" value="{if $form_error}{$value}{else}{$REQUIREMENTS.$label}{/if}">
{/if}
</div>
{/form_tagged_fields}
{/capture}
{include
@@ -322,6 +349,7 @@
{/javascripts}
<script type="text/javascript">
jQuery(function($) {
{if $taxRuleCreateError == true}
$('#tax_rule_create_dialog').modal();
@@ -338,6 +366,15 @@
$(".js-delete-tax").click(function(e){
$('#tax_delete_id').val($(this).data('id'))
});
$('.js-change-tax-type').change(function(e){
$('.js-tax-requirements').children('select, input').attr('disabled', true);
$('.js-tax-requirements').hide();
$('.js-tax-requirements[data-tax-type="' + $(this).val() + '"]').children('select, input').attr('disabled', false);
$('.js-tax-requirements[data-tax-type="' + $(this).val() + '"]').children('select').selectpicker("refresh");
$('.js-tax-requirements[data-tax-type="' + $(this).val() + '"]').show();
});
})
</script>
{/block}