80 lines
2.3 KiB
PHP
80 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* SOTESHOP/stTaxPlugin
|
|
*
|
|
* Ten plik należy do aplikacji stTaxPlugin opartej na licencji (Open License SOTE) Otwarta Licencja SOTE.
|
|
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
|
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
|
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
|
*
|
|
* @package stTaxPlugin
|
|
* @subpackage actions
|
|
* @copyright SOTE (www.sote.pl)
|
|
* @license http://www.sote.pl/license/open (Open License SOTE) Otwarta Licencja SOTE
|
|
* @version $Id$
|
|
* @author Krzysztof Bebło <krzysztof.beblo@sote.pl>
|
|
*/
|
|
|
|
/**
|
|
* Klasa stTaxBackendComponents
|
|
*
|
|
* @package stTaxPlugin
|
|
* @subpackage actions
|
|
*/
|
|
class stTaxBackendComponents extends autoStTaxBackendComponents
|
|
{
|
|
public function executeRatesByCountry()
|
|
{
|
|
$rates = stTax::getEUTaxRates();
|
|
|
|
$countries = stTax::getCountriesForConsumerEuRates();
|
|
|
|
$requiredCountries = stTax::getRequiredCountriesCodes();
|
|
|
|
$requiredRates = array();
|
|
|
|
$moreRates = array();
|
|
|
|
$i18n = $this->getContext()->getI18N();
|
|
|
|
$config = stConfig::getInstance('stShopInfoBackend');
|
|
|
|
foreach ($rates as $countryCode => $rate)
|
|
{
|
|
if ($config->get('country') != $countryCode)
|
|
{
|
|
$allRates = array($rate['normal']);
|
|
|
|
$allRates = array_merge($allRates, $rate['reduced']);
|
|
|
|
$allRates = array_combine($allRates, $allRates);
|
|
|
|
$allRates = array_map(function($value) {
|
|
return $value . ' %';
|
|
}, $allRates);
|
|
|
|
$defaultRate = key($allRates);
|
|
|
|
$allRates[$defaultRate] = $allRates[$defaultRate] . ' ' . $i18n->__('Podstawowa');
|
|
|
|
if (in_array($countryCode, $requiredCountries))
|
|
{
|
|
$requiredRates[$countryCode] = $allRates;
|
|
}
|
|
else
|
|
{
|
|
$moreRates[$countryCode] = $allRates;
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->requiredRates = $requiredRates;
|
|
$this->moreRates = $moreRates;
|
|
$this->countries = $countries;
|
|
|
|
$this->values = $this->tax->getRatesByCountry();
|
|
}
|
|
|
|
|
|
|
|
} |