// AdminTaxRules tpl refactoring
This commit is contained in:
@@ -26,119 +26,109 @@
|
|||||||
{extends file="helpers/form/form.tpl"}
|
{extends file="helpers/form/form.tpl"}
|
||||||
|
|
||||||
{block name="label"}
|
{block name="label"}
|
||||||
{if isset($input.label)}
|
{if $input.name == 'zipcode' && isset($input.label)}
|
||||||
<label
|
<label id="zipcode-label">{$input.label}</label>
|
||||||
{if $input.name == 'states[]'}
|
{elseif $input.name == 'states[]'}
|
||||||
id="state-label" style="display: none;"
|
<label id="states-label">{$input.label}</label>
|
||||||
{elseif $input.name == 'zipcode'}
|
{else}
|
||||||
id="zipcode-label"
|
{$smarty.block.parent}
|
||||||
{/if}
|
|
||||||
>{$input.label} </label>
|
|
||||||
{/if}
|
{/if}
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block name="start_field_block"}
|
|
||||||
<div class="margin-form"
|
|
||||||
{if $input.name == 'states[]'}
|
|
||||||
id="state-select" style="display: none;"
|
|
||||||
{/if}
|
|
||||||
>
|
|
||||||
{/block}
|
|
||||||
|
|
||||||
{block name="script"}
|
{block name="script"}
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#country').click(function() {
|
$('#country').click(function() {
|
||||||
populateStates($(this).val(), '');
|
populateStates($(this).val(), '');
|
||||||
});
|
|
||||||
|
|
||||||
{if !isset($smarty.get.create_rule)}
|
|
||||||
$('#tax_rule_form').hide();
|
|
||||||
{/if}
|
|
||||||
$('#desc-tax_rules_group-new').click(function() {
|
|
||||||
initForm();
|
|
||||||
$('#tax_rule_form').slideToggle();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function populateStates(id_country, id_state)
|
{if !isset($smarty.get.create_rule)}
|
||||||
|
$('#tax_rule_form').hide();
|
||||||
|
{/if}
|
||||||
|
$('#desc-tax_rules_group-new').click(function() {
|
||||||
|
initForm();
|
||||||
|
$('#tax_rule_form').slideToggle();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function populateStates(id_country, id_state)
|
||||||
|
{
|
||||||
|
if ($("#country option:selected").size() > 1)
|
||||||
{
|
{
|
||||||
if ($("#country option:selected").size() > 1)
|
$("#zipcode-label").hide();
|
||||||
{
|
$("#zipcode").hide();
|
||||||
$("#zipcode-label").hide();
|
|
||||||
$("#zipcode").hide();
|
|
||||||
|
|
||||||
$("#state-select").hide();
|
$("#states").parent().hide();
|
||||||
$("#state-label").hide();
|
$("#states-label").hide();
|
||||||
} else {
|
} else {
|
||||||
$.ajax({
|
|
||||||
url: "ajax.php",
|
|
||||||
cache: false,
|
|
||||||
data: "ajaxStates=1&id_country="+id_country+"&id_state="+id_state+"&empty_value={l s='All'}",
|
|
||||||
success: function(html){
|
|
||||||
if (html == "false")
|
|
||||||
{
|
|
||||||
$("#state-label").hide();
|
|
||||||
$("#state-select").hide();
|
|
||||||
$("#states").html('');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$("#state-label").show();
|
|
||||||
$("#state-select").show();
|
|
||||||
$("#states").html(html);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#zipcode-label").show();
|
|
||||||
$("#zipcode").show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadTaxRule(id_tax_rule)
|
|
||||||
{
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
url: "ajax.php",
|
||||||
url: 'ajax.php',
|
cache: false,
|
||||||
async: true,
|
data: "ajaxStates=1&id_country="+id_country+"&id_state="+id_state+"&empty_value={l s='All'}",
|
||||||
dataType: 'json',
|
success: function(html){
|
||||||
data: 'ajaxStates=1&ajaxUpdateTaxRule=1&id_tax_rule='+id_tax_rule,
|
if (html == "false")
|
||||||
success: function(data){
|
|
||||||
$('#tax_rule_form').show();
|
|
||||||
$('#id_tax_rule').val(data.id);
|
|
||||||
$('#country').val(data.id_country);
|
|
||||||
$('#state').val(data.id_state);
|
|
||||||
|
|
||||||
zipcode = 0;
|
|
||||||
if (data.zipcode_from != 0)
|
|
||||||
{
|
{
|
||||||
zipcode = data.zipcode_from;
|
$("#states").parent().hide();
|
||||||
|
$("#states-label").hide();
|
||||||
if (data.zipcode_to != 0)
|
$("#states").html('');
|
||||||
zipcode = zipcode +"-"+data.zipcode_to
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$("#states").parent().show();
|
||||||
|
$("#states-label").show();
|
||||||
|
$("#states").html(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#zipcode').val(zipcode);
|
|
||||||
$('#behavior').val(data.behavior);
|
|
||||||
$('#id_tax').val(data.id_tax);
|
|
||||||
$('#description').val(data.description);
|
|
||||||
|
|
||||||
populateStates(data.id_country, data.id_state);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
function initForm()
|
$("#zipcode-label").show();
|
||||||
{
|
$("#zipcode").show();
|
||||||
$('#id_tax_rule').val('');
|
|
||||||
$('#country').val(0);
|
|
||||||
$('#state').val(0);
|
|
||||||
$('#zipcode').val(0);
|
|
||||||
$('#behavior').val(0);
|
|
||||||
$('#tax').val(0);
|
|
||||||
$('#description').val('');
|
|
||||||
|
|
||||||
populateStates(0,0);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadTaxRule(id_tax_rule)
|
||||||
|
{
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: 'ajax.php',
|
||||||
|
async: true,
|
||||||
|
dataType: 'json',
|
||||||
|
data: 'ajaxStates=1&ajaxUpdateTaxRule=1&id_tax_rule='+id_tax_rule,
|
||||||
|
success: function(data){
|
||||||
|
$('#tax_rule_form').show();
|
||||||
|
$('#id_tax_rule').val(data.id);
|
||||||
|
$('#country').val(data.id_country);
|
||||||
|
$('#state').val(data.id_state);
|
||||||
|
|
||||||
|
zipcode = 0;
|
||||||
|
if (data.zipcode_from != 0)
|
||||||
|
{
|
||||||
|
zipcode = data.zipcode_from;
|
||||||
|
|
||||||
|
if (data.zipcode_to != 0)
|
||||||
|
zipcode = zipcode +"-"+data.zipcode_to
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#zipcode').val(zipcode);
|
||||||
|
$('#behavior').val(data.behavior);
|
||||||
|
$('#id_tax').val(data.id_tax);
|
||||||
|
$('#description').val(data.description);
|
||||||
|
|
||||||
|
populateStates(data.id_country, data.id_state);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function initForm()
|
||||||
|
{
|
||||||
|
$('#id_tax_rule').val('');
|
||||||
|
$('#country').val(0);
|
||||||
|
$('#state').val(0);
|
||||||
|
$('#zipcode').val(0);
|
||||||
|
$('#behavior').val(0);
|
||||||
|
$('#tax').val(0);
|
||||||
|
$('#description').val('');
|
||||||
|
|
||||||
|
populateStates(0,0);
|
||||||
|
}
|
||||||
{/block}
|
{/block}
|
||||||
|
|||||||
Reference in New Issue
Block a user