preselected countries is tax rule edition appliance
This commit is contained in:
@@ -76,20 +76,12 @@ class TaxRuleCountry extends BaseI18nLoop
|
|||||||
$country = $this->getCountry();
|
$country = $this->getCountry();
|
||||||
$taxes = $this->getTaxes();
|
$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');
|
throw new \InvalidArgumentException('You must provide either `country` or `taxes` parameter in tax-rule-country loop');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(null !== $country) {
|
if((null === $country && null !== $taxes)) {
|
||||||
$search->filterByCountryId($country);
|
throw new \InvalidArgumentException('You must provide `country` parameter with `taxes` parameter in tax-rule-country loop');
|
||||||
|
|
||||||
/* manage tax translation */
|
|
||||||
$this->configureI18nProcessing(
|
|
||||||
$search,
|
|
||||||
array('TITLE', 'DESCRIPTION'),
|
|
||||||
TaxTableMap::TABLE_NAME,
|
|
||||||
'TAX_ID'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(null !== $taxes) {
|
if(null !== $taxes) {
|
||||||
@@ -103,7 +95,7 @@ class TaxRuleCountry extends BaseI18nLoop
|
|||||||
$originalCountryJoin->setJoinType(Criteria::LEFT_JOIN);
|
$originalCountryJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||||
|
|
||||||
$search->addJoinObject($originalCountryJoin, 's_to_o');
|
$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);
|
$search->having('COUNT(*)=?', count($taxes), \PDO::PARAM_INT);
|
||||||
|
|
||||||
@@ -114,6 +106,16 @@ class TaxRuleCountry extends BaseI18nLoop
|
|||||||
CountryTableMap::TABLE_NAME,
|
CountryTableMap::TABLE_NAME,
|
||||||
'COUNTRY_ID'
|
'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();
|
$taxRule = $this->getTax_rule();
|
||||||
@@ -130,7 +132,16 @@ class TaxRuleCountry extends BaseI18nLoop
|
|||||||
|
|
||||||
$loopResultRow = new LoopResultRow($loopResult, $taxRuleCountry, $this->versionable, $this->timestampable, $this->countable);
|
$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
|
$loopResultRow
|
||||||
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
|
->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId())
|
||||||
->set("COUNTRY" , $taxRuleCountry->getCountryId())
|
->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);
|
$loopResult->addRow($loopResultRow);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,17 +105,23 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="" class="label-control">{intl l="Choose a country"} :</label>
|
<label for="" class="label-control">{intl l="Choose a country"} :</label>
|
||||||
<select id="country-selector" data-toggle="selectpicker">
|
<form id="country-selector-form" action="{url path="/admin/configuration/taxes_rules/update/$tax_rule_id"}" method="GET">
|
||||||
{loop type="country" name="country-list"}
|
<input type="hidden" name="tab" value="taxes">
|
||||||
<option value="{$ID}" {if $ID == $asked_country}selected="selected"{/if}>{$TITLE}</option>
|
<select id="country-selector" name="country" data-toggle="selectpicker">
|
||||||
{/loop}
|
{loop type="country" name="country-list"}
|
||||||
</select>
|
<option value="{$ID}" {if $ID == $asked_country}selected="selected"{/if}>{$TITLE}</option>
|
||||||
|
{/loop}
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><strong>{intl l="Countries that have the same tax rule"} :<strong></p>
|
<p><strong>{intl l="Countries that have the same tax rule"} :<strong></p>
|
||||||
<p class="lead">
|
<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>
|
<span class="label label-info">{$COUNTRY_TITLE}</span>
|
||||||
{/loop}
|
{/loop}
|
||||||
|
|
||||||
@@ -204,9 +210,9 @@
|
|||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<select name="" id="" data-toggle="selectpicker" multiple>
|
<select name="" id="" data-toggle="selectpicker" multiple>
|
||||||
<option value="1">France</option>
|
{loop type="country" name="country-list"}
|
||||||
<option value="2">England</option>
|
<option value="{$ID}" {if in_array($ID, $matchedCountries)}selected="selected"{/if}>{$TITLE}</option>
|
||||||
<option value="3">Spain</option>
|
{/loop}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -240,10 +246,15 @@
|
|||||||
{/javascripts}
|
{/javascripts}
|
||||||
|
|
||||||
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||||
{literal}
|
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
|
$('#country-selector').change(function(e) {
|
||||||
|
$('#country-selector-form').submit();
|
||||||
|
});
|
||||||
|
|
||||||
|
{literal}
|
||||||
// Cache jQuery Objects
|
// Cache jQuery Objects
|
||||||
var $group = $('#panel');
|
var $group = $('#panel');
|
||||||
var $list = $('#panel-list');
|
var $list = $('#panel-list');
|
||||||
@@ -342,8 +353,10 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
{/literal}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{/literal}
|
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
Reference in New Issue
Block a user