preselected countries is tax rule edition appliance

This commit is contained in:
Etienne Roudeix
2013-10-09 16:15:53 +02:00
parent a8594ef6af
commit 77c9c596f1
2 changed files with 49 additions and 34 deletions

View File

@@ -76,20 +76,12 @@ class TaxRuleCountry extends BaseI18nLoop
$country = $this->getCountry();
$taxes = $this->getTaxes();
if((null === $country && null === $taxes) || (null !== $country && null !== $taxes)) {
if((null === $country && null === $taxes)) {
throw new \InvalidArgumentException('You must provide either `country` or `taxes` parameter in tax-rule-country loop');
}
if(null !== $country) {
$search->filterByCountryId($country);
/* manage tax translation */
$this->configureI18nProcessing(
$search,
array('TITLE', 'DESCRIPTION'),
TaxTableMap::TABLE_NAME,
'TAX_ID'
);
if((null === $country && null !== $taxes)) {
throw new \InvalidArgumentException('You must provide `country` parameter with `taxes` parameter in tax-rule-country loop');
}
if(null !== $taxes) {
@@ -103,7 +95,7 @@ class TaxRuleCountry extends BaseI18nLoop
$originalCountryJoin->setJoinType(Criteria::LEFT_JOIN);
$search->addJoinObject($originalCountryJoin, 's_to_o');
$search->where('`origin`.`COUNTRY_ID`' . Criteria::EQUAL . '?', 64, \PDO::PARAM_INT);
$search->where('`origin`.`COUNTRY_ID`' . Criteria::EQUAL . '?', $country, \PDO::PARAM_INT);
$search->having('COUNT(*)=?', count($taxes), \PDO::PARAM_INT);
@@ -114,6 +106,16 @@ class TaxRuleCountry extends BaseI18nLoop
CountryTableMap::TABLE_NAME,
'COUNTRY_ID'
);
} elseif(null !== $country) {
$search->filterByCountryId($country);
/* manage tax translation */
$this->configureI18nProcessing(
$search,
array('TITLE', 'DESCRIPTION'),
TaxTableMap::TABLE_NAME,
'TAX_ID'
);
}
$taxRule = $this->getTax_rule();
@@ -130,7 +132,16 @@ class TaxRuleCountry extends BaseI18nLoop
$loopResultRow = new LoopResultRow($loopResult, $taxRuleCountry, $this->versionable, $this->timestampable, $this->countable);
if(null !== $country) {
if(null !== $taxes) {
$loopResultRow
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
->set("COUNTRY" , $taxRuleCountry->getCountryId())
->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_TITLE'))
->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_CHAPO'))
->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM'))
;
}elseif(null !== $country) {
$loopResultRow
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
->set("COUNTRY" , $taxRuleCountry->getCountryId())
@@ -141,16 +152,7 @@ class TaxRuleCountry extends BaseI18nLoop
;
}
if(null !== $taxes) {
$loopResultRow
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
->set("COUNTRY" , $taxRuleCountry->getCountryId())
->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_TITLE'))
->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_CHAPO'))
->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_DESCRIPTION'))
->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM'))
;
}
$loopResult->addRow($loopResultRow);
}

View File

@@ -105,17 +105,23 @@
<div class="form-group">
<label for="" class="label-control">{intl l="Choose a country"} :</label>
<select id="country-selector" data-toggle="selectpicker">
{loop type="country" name="country-list"}
<option value="{$ID}" {if $ID == $asked_country}selected="selected"{/if}>{$TITLE}</option>
{/loop}
</select>
<form id="country-selector-form" action="{url path="/admin/configuration/taxes_rules/update/$tax_rule_id"}" method="GET">
<input type="hidden" name="tab" value="taxes">
<select id="country-selector" name="country" data-toggle="selectpicker">
{loop type="country" name="country-list"}
<option value="{$ID}" {if $ID == $asked_country}selected="selected"{/if}>{$TITLE}</option>
{/loop}
</select>
</form>
</div>
<p><strong>{intl l="Countries that have the same tax rule"} :<strong></p>
<p class="lead">
{loop type="tax-rule-country" name="same-country-list" tax_rule=$ID taxes="1,2,3"}
{$matchedCountries.first=$asked_country}
{loop type="tax-rule-country" name="same-country-list" tax_rule=$ID taxes="1,2,3" country=$asked_country}
{$matchedCountries[]=$COUNTRY}
<span class="label label-info">{$COUNTRY_TITLE}</span>
{/loop}
@@ -204,9 +210,9 @@
<form action="" method="post">
<div class="form-group">
<select name="" id="" data-toggle="selectpicker" multiple>
<option value="1">France</option>
<option value="2">England</option>
<option value="3">Spain</option>
{loop type="country" name="country-list"}
<option value="{$ID}" {if in_array($ID, $matchedCountries)}selected="selected"{/if}>{$TITLE}</option>
{/loop}
</select>
</div>
</form>
@@ -240,10 +246,15 @@
{/javascripts}
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
{literal}
<script>
$(function() {
$('#country-selector').change(function(e) {
$('#country-selector-form').submit();
});
{literal}
// Cache jQuery Objects
var $group = $('#panel');
var $list = $('#panel-list');
@@ -342,8 +353,10 @@
}
});
{/literal}
});
</script>
{/literal}
{/block}