[*] Project : US + CA TaxSystem

This commit is contained in:
fBrignoli
2011-08-18 10:10:50 +00:00
parent 50e9f03719
commit 8f8ac0670d
33 changed files with 1665 additions and 1168 deletions
+16 -40
View File
@@ -358,7 +358,7 @@ if (isset($_GET['ajaxStates']) AND isset($_GET['id_country']))
LEFT JOIN '._DB_PREFIX_.'country c ON (s.`id_country` = c.`id_country`)
WHERE s.id_country = '.(int)(Tools::getValue('id_country')).' AND s.active = 1 AND c.`contains_states` = 1
ORDER BY s.`name` ASC');
if (is_array($states) AND !empty($states))
{
$list = '';
@@ -504,30 +504,6 @@ if (Tools::isSubmit('toggleScreencast'))
$context->employee->save();
}
if (Tools::isSubmit('ajaxAddZipCode') OR Tools::isSubmit('ajaxRemoveZipCode'))
{
require_once(PS_ADMIN_DIR.'/tabs/AdminCounty.php');
$zipcodes = Tools::getValue('zipcodes');
$id_county = (int)Tools::getValue('id_county');
$county = new County($id_county);
if (!Validate::isLoadedObject($county))
die('error');
if (Tools::isSubmit('ajaxAddZipCode'))
{
if ($county->isZipCodeRangePresent($zipcodes))
die('error:'.Tools::displayError('This Zip Code is already in use.'));
if ($county->addZipCodes($zipcodes))
die(AdminCounty::renderZipCodeList($county->getZipCodes()));
}
else if (Tools::isSubmit('ajaxRemoveZipCode') AND $county->removeZipCodes($zipcodes))
die(AdminCounty::renderZipCodeList($county->getZipCodes()));
die('error');
}
if (Tools::isSubmit('helpAccess'))
{
$item = Tools::getValue('item');
@@ -562,14 +538,14 @@ if (Tools::isSubmit('getHookableList'))
if ($moduleInstance->isHookableOn($hook_name))
array_push($hookableList[$hook_name], $module);
}
}
die(Tools::jsonEncode($hookableList));
}
if (Tools::isSubmit('getHookableModuleList'))
{
include('../init.php');
$hook_name = Tools::getValue('hook');
$hookableModulesList = array();
@@ -582,9 +558,9 @@ if (Tools::isSubmit('getHookableModuleList'))
$mod = new $module['name']();
if ($mod->isHookableOn($hook_name))
$hookableModulesList[] = array('id' => (int)$mod->id, 'name' => $mod->displayName, 'display' => Module::hookExec($hook_name, array(), (int)$mod->id));
}
}
}
die(Tools::jsonEncode($hookableModulesList));
die(Tools::jsonEncode($hookableModulesList));
}
if (Tools::isSubmit('saveHook'))
@@ -599,7 +575,7 @@ if (Tools::isSubmit('saveHook'))
$hook = trim($hook);
if (!$hook)
continue;
$sql = 'DELETE FROM '._DB_PREFIX_.'hook_module
WHERE id_hook = (SELECT id_hook FROM '._DB_PREFIX_.'hook WHERE `name` = \''.pSQL($hook).'\' LIMIT 1)
AND id_shop = '.$id_shop;
@@ -615,7 +591,7 @@ if (Tools::isSubmit('saveHook'))
}
$value = rtrim($value, ',');
Db::getInstance()->Execute('INSERT INTO '._DB_PREFIX_.'hook_module (id_module, id_shop, id_hook, position) VALUES '.$value);
}
}
die('{"hasError" : false, "errors" : ""}');
@@ -624,18 +600,18 @@ if (Tools::isSubmit('saveHook'))
if (Tools::isSubmit('getAdminHomeElement'))
{
$result = array();
$protocol = Tools::usingSecureMode() ? 'https' : 'http';
$isoUser = Context::getContext()->language->iso_code;
$isoCountry = Context::getContext()->country->iso_code;
$stream_context = stream_context_create(array('http' => array('method'=>"GET", 'timeout' => 5)));
// SCREENCAST
if (@fsockopen('www.prestashop.com', 80, $errno, $errst, 3))
$result['screencast'] = 'OK';
else
$result['screencast'] = 'NOK';
// PREACTIVATION
$content = @file_get_contents($protocol.'://www.prestashop.com/partner/preactivation/preactivation-block.php?version=1.0&shop='.urlencode(Configuration::get('PS_SHOP_NAME')).'&protocol='.$protocol.'&url='.urlencode($_SERVER['HTTP_HOST']).'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)Context::getContext()->language->id.'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&date_creation='._PS_CREATION_DATE_.'&v='._PS_VERSION_.'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context);
if (!$content)
@@ -661,7 +637,7 @@ if (Tools::isSubmit('getAdminHomeElement'))
else
$result['partner_preactivation'] = 'NOK';
}
// PREACTIVATION PAYPAL WARNING
$content = @file_get_contents('https://www.prestashop.com/partner/preactivation/preactivation-warnings.php?version=1.0&partner=paypal&iso_country='.Tools::strtolower(Context::getContext()->country->iso_code).'&iso_lang='.Tools::strtolower(Context::getContext()->language->iso_code).'&id_lang='.(int)Context::getContext().'&email='.urlencode(Configuration::get('PS_SHOP_EMAIL')).'&security='.md5(Configuration::get('PS_SHOP_EMAIL')._COOKIE_IV_), false, $stream_context);
$content = explode('|', $content);
@@ -681,20 +657,20 @@ if (Tools::isSubmit('getAdminHomeElement'))
$result['discover_prestashop'] = $content[1];
else
$result['discover_prestashop'] = 'NOK';
if (@fsockopen('www.prestashop.com', 80, $errno, $errst, 3))
$result['discover_prestashop'] .= '<iframe frameborder="no" style="margin: 0px; padding: 0px; width: 315px; height: 290px;" src="'.$protocol.'://www.prestashop.com/rss/news2.php?v='._PS_VERSION_.'&lang='.$isoUser.'"></iframe>';
$content = @file_get_contents($protocol.'://www.prestashop.com/partner/paypal/paypal-tips.php?protocol='.$protocol.'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser).'&id_lang='.(int)Context::getContext()->language->id, false, $stream_context);
$content = explode('|', $content);
if ($content[0] == 'OK')
$result['discover_prestashop'] .= $content[1];
}
}
die(Tools::jsonEncode($result));
}
if (Tools::isSubmit('getChildrenCategories') && Tools::getValue('id_category_parent'))
if (Tools::isSubmit('getChildrenCategories') && Tools::getValue('id_category_parent'))
{
$children_categories = Category::getChildrenWithNbSelectedSubCat(Tools::getValue('id_category_parent'), Tools::getValue('selectedCat', array()), Context::getContext()->language->id);
die(Tools::jsonEncode($children_categories));
+1 -1
View File
@@ -228,7 +228,7 @@ class AdminAttributeGenerator extends AdminTab
i18n_tax_exc = "'.$this->l('Tax Excl.:').'";
i18n_tax_inc = "'.$this->l('Tax Incl.:').'";
var product_tax = "'.Tax::getProductTaxRate($this->product->id, NULL).'";
var product_tax = "'.$this->product->getTaxesRate().'";
function calcPrice(element, element_has_tax)
{
+22 -22
View File
@@ -131,7 +131,7 @@ class AdminProducts extends AdminTab
$nb = count($this->_list);
if ($this->_list)
{
/* update product final price */
for ($i = 0; $i < $nb; $i++)
@@ -1059,7 +1059,7 @@ class AdminProducts extends AdminTab
else
{
$image = new Image($id_image);
if (!$new_path = $image->getPathForCreation())
$this->_errors[] = Tools::displayError('An error occurred during new folder creation');
if (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName))
@@ -1179,7 +1179,7 @@ class AdminProducts extends AdminTab
$this->updateAccessories($object);
$this->updateDownloadProduct($object);
$this->updateAssoShop((int)$object->id);
if (!$this->updatePackItems($object))
$this->_errors[] = Tools::displayError('An error occurred while adding products to the pack.');
elseif (!$object->updateCategories($_POST['categoryBox'], true))
@@ -1662,7 +1662,7 @@ class AdminProducts extends AdminTab
$specificPrices = SpecificPrice::getByProductId((int)($obj->id));
$specificPricePriorities = SpecificPrice::getPriority((int)($obj->id));
$taxRate = TaxRulesGroup::getTaxesRate($obj->id_tax_rules_group, $this->context->country->id, 0, 0);
$taxRate = $obj->getTaxesRate(Tax::initializeAddress());
$tmp = array();
foreach ($shops as $shop)
@@ -2613,11 +2613,11 @@ class AdminProducts extends AdminTab
</td>
</tr>
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>';
if ((int)Configuration::get('PS_STOCK_MANAGEMENT'))
{
if (!$has_attribute)
{
if ($obj->id)
@@ -2675,7 +2675,7 @@ class AdminProducts extends AdminTab
echo '<tr>
<td colspan="2">'.$this->l('The stock management is disabled').'</td>
</tr>';
echo '
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
<tr>
@@ -2751,23 +2751,23 @@ class AdminProducts extends AdminTab
else
$selectedCat = Product::getProductCategoriesFull($obj->id, $this->_defaultFormLanguage);
}
echo '<select id="id_category_default" name="id_category_default">';
foreach($selectedCat AS $cat)
echo '<option value="'.$cat['id_category'].'" '.($obj->id_category_default == $cat['id_category'] ? 'selected' : '').'>'.$cat['name'].'</option>';
echo '</select>
</td>
</td>
</tr>
<tr id="tr_categories">
<td colspan="2">
';
// Translations are not automatic for the moment ;)
$trads = array(
'Home' => $this->l('Home'),
'selected' => $this->l('selected'),
'Collapse All' => $this->l('Collapse All'),
'Expand All' => $this->l('Expand All'),
'Check All' => $this->l('Check All'),
'Home' => $this->l('Home'),
'selected' => $this->l('selected'),
'Collapse All' => $this->l('Collapse All'),
'Expand All' => $this->l('Expand All'),
'Check All' => $this->l('Check All'),
'Uncheck All' => $this->l('Uncheck All')
);
echo Helper::renderAdminCategorieTree($trads, $selectedCat).'
@@ -2840,7 +2840,7 @@ class AdminProducts extends AdminTab
echo ' <div class="lang_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').';float: left;">
<textarea class="rte" cols="100" rows="10" id="description_short_'.$language['id_lang'].'" name="description_short_'.$language['id_lang'].'">'.htmlentities(stripslashes($this->getFieldValue($obj, 'description_short', $language['id_lang'])), ENT_COMPAT, 'UTF-8').'</textarea>
</div>';
echo '<p class="clear">'.($obj->id ? $this->youEditFieldFor() : '').'</p>
echo '<p class="clear">'.($obj->id ? $this->youEditFieldFor() : '').'</p>
</td>
</tr>
<tr>
@@ -2959,7 +2959,7 @@ class AdminProducts extends AdminTab
unitPriceWithTax(\'unit\');
</script>';
$categoryBox = Tools::getValue('categoryBox', array());
}
function displayFormImages($obj, $token = NULL)
@@ -3070,7 +3070,7 @@ class AdminProducts extends AdminTab
</script>';
foreach ($shops as $shop)
echo '<th>'.$shop['name'].'</th>';
}
}
echo '
<th>'.$this->l('Cover').'</th>
<th>'.$this->l('Action').'</th>
@@ -3111,7 +3111,7 @@ class AdminProducts extends AdminTab
if (Shop::isMultiShopActivated())
foreach ($shops AS $shop)
echo '<td class="center"><input type="checkbox" class="image_shop" name="'.(int)$image['id_image'].'" value="'.(int)$shop['id_shop'].'" '.($imgObj->isAssociatedToShop($shop['id_shop']) ? 'checked="1"' : '').' /></td>';
echo '
echo '
<td class="center"><a href="'.self::$currentIndex.'&id_image='.$image['id_image'].'&coverImage&token='.($token ? $token : $this->token).'"><img src="../img/admin/'.($image['cover'] ? 'enabled.gif' : 'forbbiden.gif').'" alt="" /></a></td>
<td class="center">
<a href="'.self::$currentIndex.'&id_image='.$image['id_image'].'&editImage&tabs=1&token='.($token ? $token : $this->token).'"><img src="../img/admin/edit.gif" alt="'.$this->l('Modify this image').'" title="'.$this->l('Modify this image').'" /></a>
@@ -3172,7 +3172,7 @@ class AdminProducts extends AdminTab
function displayFormAttributes($obj, $languages, $defaultLanguage)
{
$attributeJs = array();
$attributes = Attribute::getAttributes($this->context->language->id, true);
foreach ($attributes AS $k => $attribute)
@@ -3181,7 +3181,7 @@ class AdminProducts extends AdminTab
$attributes_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
$default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
$images = Image::getImages($this->context->language->id, $obj->id);
if ($obj->id)
{
@@ -3726,7 +3726,7 @@ class AdminProducts extends AdminTab
}
else if ($(\'#curPackItemId\').val() == \'\' || $(\'#curPackItemQty\').val() == \'\')
{
alert(\''.$this->l('Thanks to set a quantity to add a product.').'\');
alert(\''.$this->l('Thanks to set a quantity to add a product.').'\');
return false;
}
+398 -479
View File
@@ -25,543 +25,462 @@
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminTaxRulesGroup extends AdminTab
class
AdminTaxRulesGroup extends AdminTab
{
public $tax_rule;
public $_errors_tax_rule;
public function __construct()
{
global $cookie;
$this->table = 'tax_rules_group';
$this->className = 'TaxRulesGroup';
$this->edit = true;
$this->delete = true;
$this->ajax = false;
$this->fieldsDisplay = array(
'id_tax_rules_group' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'name' => array('title' => $this->l('Name'), 'width' => 140),
'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
parent::__construct();
parent::__construct();
}
public function displayTop()
/**
* retrieve a tax rule via ajax
* @return tax rule in json format
*/
public function ajaxProcessGetTaxRule()
{
echo '<div class="hint clear" style="display:block;">
'.$this->l('The tax rules allow you to define a product or a carrier with different taxes depending on their location (country, state, etc.).').'
$id_rule = (int)Tools::getValue('id_tax_rule');
<b>'.$this->l('In the majority of cases, the rules created by default by PrestaShop should be enough.').'</b> '.
$this->l('If, however, you need to change them, here is an example that will help you understand how it works:').
'<br /><br />'
.$this->l('You want to apply a tax of 19.6% to a product in France and Europe, but not apply this tax to other countries. Follow these steps:').'
<ul>
<li>'.$this->l('Click "Add New".').'</li>
<li>'.$this->l('Give a name to your tax rule (ex: "19.6% tax rule).').'</li>
<li>'.$this->l('Set the \'active\' field to true.').'</li>
<li>'.$this->l('Edit its configuration by country by associating a 19.6% tax with France and with European countries, and a tax of 0% to other countries.').'</li>
<li>'.$this->l('Click on Save.').'</li>
<li>'.$this->l('Go to your product page (Catalog tab) and associate the "19.6% tax rule" to your product.').'</li>
</ul>
<br />
'.$this->l('Later, if you need to apply a different tax to Spain, you can simply edit the rule "19.6% tax rule" and change the tax associated with Spain.').'<br />
'.$this->l('Note: The default rate applied to your product will be based on your store\'s default country.').'
</div><br />';
if ($tax_rule = TaxRule::retrieveById($id_rule))
die(Tools::jsonEncode($tax_rule));
else
die('error');
}
public function displayForm($isMainTab = true)
public function ajaxPreProcess() {}
public function postProcess()
{
$action = Tools::getValue('action');
if ($action == 'delete_rule')
{
$id_rule = (int)Tools::getValue('id_tax_rule');
$tax_rule = new TaxRule($id_rule);
if (Validate::isLoadedObject($tax_rule))
{
$tax_rule->delete();
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$tax_rule->id_tax_rules_group.'&conf=4&update'.$this->table.'&token='.$this->token);
}
}
else if ($action == 'create_rule')
{
$zipcode = Tools::getValue('zipcode');
$id_rule = (int)Tools::getValue('id_tax_rule');
$tr = new TaxRule();
// update or creation?
if (isset($id_rule))
$tr->id = $id_rule;
$tr->id_tax = (int)Tools::getValue('tax');
$tr->id_tax_rules_group = (int)Tools::getValue('id_tax_rules_group');
$tr->id_country = (int)Tools::getValue('country');
$tr->id_state = (int)Tools::getValue('states');
list($tr->zipcode_from, $tr->zipcode_to) = $tr->breakDownZipCode($zipcode);
$tr->behavior = (int)Tools::getValue('behavior');
$tr->description = Tools::getValue('description');
$this->_errors_tax_rule = $this->validateTaxRule($tr);
if (sizeof($this->_errors_tax_rule) == 0)
{
if (!$tr->save())
die('error');
}
$this->tax_rule = $tr;
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$tr->id_tax_rules_group.'&conf=4&update'.$this->table.'&token='.$this->token);
} else
parent::postProcess();
}
/**
* check if the tax rule could be added in the database
* @param TaxRule $tr
*/
protected function validateTaxRule(TaxRule $tr)
{
parent::displayForm();
// TODO: check if the rule already exists
return $tr->validateController();
}
protected function displayJS()
{
global $cookie;
$javascript = <<<EOT
<script type="text/javascript">
function populateStates(id_country, id_state)
{
$.ajax({
url: "ajax.php",
cache: false,
data: "ajaxStates=1&id_country="+id_country+"&id_state="+id_state,
success: function(html){
if (html == "false")
{
$("#state-label").hide();
$("#state-select").hide();
}
else
{
$("#state-label").show();
$("#state-select").show();
$("#states").html(html);
}
}
});
}
function loadTaxRule(id_tax_rule)
{
$.ajax({
url: "ajax-tab.php",
cache: false,
dataType: "json",
data: "action=get_tax_rule&id_tax_rule="+id_tax_rule+"&tab=AdminTaxRulesGroup&token=$this->token",
success: function(data){
$('#rule_form').show();
$('#id_tax_rule').val(data.id_tax_rule);
$('#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);
$('#tax').val(data.id_tax);
$('#description').val(data.description);
populateStates(data.id_country, data.id_state);
},
error: function(data)
{
}
});
}
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);
}
</script>
EOT;
echo $javascript;
}
public function displayTaxRulesErrors()
{
if ($nbErrors = count($this->_errors_tax_rule) AND $this->_includeContainer)
{
echo '<script type="text/javascript">
$(document).ready(function() {
$(\'#hideErrorTaxRules\').unbind(\'click\').click(function(){
$(\'.error\').hide(\'slow\', function (){
$(\'.error\').remove();
});
return false;
});
});
$(document).ready(function() {
$(\'#rule_form\').show();
populateStates("'.(int)$this->tax_rule->id_country.'", "'.(int)$this->tax_rule->id_state.'")
});
</script>
<div class="error"><span style="float:right"><a id="hideErrorTaxRules" href=""><img alt="X" src="../img/admin/close.png" /></a></span><img src="../img/admin/error2.png" />';
if (count($this->_errors_tax_rule) == 1)
echo $this->_errors_tax_rule[0];
else
{
echo $nbErrors.' '.$this->l('errors').'<br /><ol>';
foreach ($this->_errors_tax_rule AS $error)
echo '<li>'.$error.'</li>';
echo '</ol>';
}
echo '</div>';
}
}
public function display()
{
if ((Tools::getValue('submitAdd'.$this->table) AND sizeof($this->_errors_tax_rule)) OR isset($_GET['add'.$this->table]))
{
if ($this->tabAccess['add'] === '1')
$this->displayForm();
else
echo $this->l('You do not have permission to add here');
}
else parent::display();
}
/**
* displays the tax rules group form
*/
protected function displayRuleGroupForm()
{
global $cookie, $currentIndex;
parent::displayForm();
if (!($obj = $this->loadObject(true)))
return;
$tax_rules = isset($obj->id) ? $tax_rules = TaxRule::getTaxRulesByGroupId($obj->id) : array();
$param_product = Tools::getValue('id_product') ? '&id_product='.Tools::getValue('id_product') : '';
// if the user come from the product page
$param_product = Tools::getValue('id_product') ? '&id_product='.Tools::getValue('id_product') : '';
echo '<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.$param_product.'" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/dollar.gif" />'.$this->l('Tax Rules').'</legend>
<input type="hidden" name="tabs" id="tabs" value="0" />
';
echo '<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.$param_product.'" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<fieldset><legend><img src="../img/admin/dollar.gif" />'.$this->l('Tax Rules').'</legend>
<input type="hidden" name="tabs" id="tabs" value="0" />
';
echo '<label>'.$this->l('Name').'</label>
<div class="margin-form">
echo '<label>'.$this->l('Name').'</label>
<div class="margin-form">
<input size="33" type="text" name="name" value="'.Tools::htmlentitiesUTF8($this->getFieldValue($obj, 'name')).'" /><sup> *</sup>
<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
<p class="clear"></p>
</div>';
<p class="clear"></p>
</div>';
echo '
<label>'.$this->l('Enable:').' </label>
echo '
<label>'.$this->l('Enable:').' </label>
<div class="margin-form">
<input type="radio" name="active" id="active_on" value="1" '.($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
<input type="radio" name="active" id="active_off" value="0" '.(!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>
<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
</div>';
if (Shop::isMultiShopActivated())
{
echo '<label>'.$this->l('Shop association:').'</label><div class="margin-form">';
$this->displayAssoShop('group_shop');
echo '</div>';
}
echo '
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />&nbsp;
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l('Save and stay').'" name="submitAdd'.$this->table.'AndStay" class="button" />
</div>';
echo '<br />';
</div>
</form>';
}
echo '<div class="tab-panet-tax" id="tab-pane-1">
<script type="text/javascript">
var pos_select = '.(($tab = Tools::getValue('tabs')) ? $tab : '0').';
function loadTab(id)
{}
/**
* Display the tax rule form
*
* @param int $id_rule_group
*/
protected function displayRuleForm($id_rule_group)
{
global $cookie, $currentIndex;
function applyTax(id_zone)
{
cur_tax = $("#zone_"+id_zone).val();
$(".tax_"+id_zone).val(cur_tax);
return false;
}
if (Validate::isLoadedObject($this->tax_rule))
die(Tools::displayError('Unable to load the tax rule!'));
function disableStateTaxRate(id_country, id_state)
{
if ($("#behavior_state_"+id_state).val() == '.PS_PRODUCT_TAX.')
$("#tax_"+id_country+"_"+id_state).attr("disabled", true);
else
$("#tax_"+id_country+"_"+id_state).attr("disabled", false);
}
$country_select = Helper::selectInput(Country::getCountries((int)$cookie->id_lang),
array('id' => 'country', 'name' => 'country', 'onclick' => 'populateStates($(this).val(), \'\')'),
array('key' => 'id_country', 'value' => 'name'));
function disableCountyTaxRate(id_country, id_state, id_county)
{
if ($("#behavior_county_"+id_county).val() == '.County::USE_STATE_TAX.')
$("#tax_"+id_country+"_"+id_state+"_"+id_county).attr("disabled", true);
else
{
$tax_select = Helper::selectInput(Tax::getTaxes((int)$cookie->id_lang),
array('id' => 'tax', 'name' => 'tax'),
array('key' => 'id_tax',
'value' => 'name',
'empty' => $this->l('No Tax')));
$("#tax_"+id_country+"_"+id_state+"_"+id_county).attr("disabled", false);
}
}
$behavior_select = Helper::selectInput(array(0 => $this->l('This tax only'),
1 => $this->l('Combine'),
2 => $this->l('One After Another')
),
array('id' => 'behavior', 'name' => 'behavior'));
$(\'document\').ready(function (){
$(\'.states\').hide();
$(\'.counties\').hide();
echo '<a href="#" onclick="initForm();$(\'#rule_form\').slideToggle();return false;"><img src="../img/admin/add.gif" alt="" /> '.$this->l('Add a new tax rule').'</a>
<form action="'.$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'" method="post">
<div id="rule_form" style="display: none">
<label>'.$this->l('Country').'</label>
<div class="margin-form">
'.$country_select.'
</div>
$(\'.open_state\').click(function (){
if ($(\'.\'+$(this).attr(\'id\')).is(\':hidden\'))
{
$(\'.\'+$(this).attr(\'id\')).show();
$(\'#\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/less.png");
}
else
{
$(\'.\'+$(this).attr(\'id\')).hide();
$(\'.county_\'+$(this).attr(\'id\')).hide();
$(\'.county_\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/more.png");
$(\'#\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/more.png");
}
});
<label id="state-label">'.$this->l('State').'</label>
<div id="state-select" class="margin-form">
<select id="states" name="states">
</select>
</div>
$(\'.open_county\').click(function (){
if ($(\'.\'+$(this).attr(\'id\')).is(\':hidden\'))
{
$(\'.\'+$(this).attr(\'id\')).show();
$(\'#\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/less.png");
}
else
{
$(\'.\'+$(this).attr(\'id\')).hide();
$(\'#\'+$(this).attr(\'id\')+\'_button\').attr("src","../img/admin/more.png");
}
});
});
</script>
<script src="../js/tabpane.js" type="text/javascript"></script>
<script type="text/javascript">
var tabPane1 = new WebFXTabPane( document.getElementById( "tab-pane-1" ) );
</script>
<link type="text/css" rel="stylesheet" href="../css/tabpane.css" />'.$this->renderZones($tax_rules, $this->context->language->id);
echo '
<div class="margin-form" style="margin-top: 10px">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />&nbsp;&nbsp;
<input type="submit" value="'.$this->l('Save and stay').'" name="submitAdd'.$this->table.'AndStay" class="button" />
<label>'.$this->l('ZipCode range').'</label>
<div class="margin-form">
<input type="hidden" name="action" value="create_rule" />
<input type="hidden" id="id_tax_rules_group" name="id_tax_rules_group" value="'.(int)$id_rule_group.'" />
<input type="hidden" id="id_tax_rule" name="id_tax_rule" />
<input type="text" id="zipcode" name="zipcode" />&nbsp;
<div class="hint" style="display: block">'.$this->l('You can define a range (eg: 75000-75015) or a simple zipcode').'</div>
</div>
<label>'.$this->l('Behavior').'</label>
<div class="margin-form">
'.$behavior_select.'
<div class="hint" style="display: block">
'.$this->l('Define the behavior if an address matches multiple rules:').'<br />
<b>'.$this->l('This Tax Only:').'</b> '.$this->l('Will apply only this tax').'<br />
<b>'.$this->l('Combine:').'</b> '.$this->l('Combine taxes (eg: 10% + 5% => 15%)').'<br />
<b>'.$this->l('One After Another:').'</b> '.$this->l('Apply taxes one after another (eg: 100€ + 10% => 110€ + 5% => 115.5€)').
'</div>
</div>
<label>'.$this->l('Tax').'</label>
<div class="margin-form">
'.$tax_select.' '.$this->l('(Total tax:').'9%'.')
</div>
<label>'.$this->l('Description').'</label>
<div class="margin-form">
<input type="text" id="description" name="description" />&nbsp;
</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="create_rule" class="button" />
</div>
</div>
</fieldset>
</form>';
}
</form>
<br /><br />
';
}
/**
* display the list of rules
*
* @param int $id_rule_group
*/
protected function displayRulesList($id_rule_group)
{
echo '<table class="table" cellspacing="0" cellpadding="0" style="text-align: center; width: 100%;">
<thead>
<tr>
<th>'.$this->l('Country').'</th>
<th>'.$this->l('State').'</th>
<th>'.$this->l('ZipCodes').'</th>
<th>'.$this->l('Behavior').'</th>
<th>'.$this->l('Tax').'</th>
<th>'.$this->l('Description').'</th>
<th>'.$this->l('Actions').'</th>
</tr>
</thead>
<tbody>
'.$this->displayTaxRules((int)$id_rule_group).'
</tbody>
</table>';
}
public function renderZones($tax_rules, $id_lang)
{
$html = '';
$zones = Zone::getZones(true);
foreach ($zones AS $key => $zone)
{
$html .= '<div class="tab-page" id="tab-page-'.$key.'">
<h4 class="tab">'.$zone['name'].'</h4>
<script type="text/javascript">
tabPane1.addTabPage( document.getElementById( "tab-page-'.$key.'" ) );
</script>
'.$this->renderCountries($tax_rules, $zone['id_zone'], $id_lang).'
</div>';
}
/**
* display the tax rules list table body
*
* @param int $id_rule_group
*/
protected function displayTaxRules($id_rule_group)
{
global $currentIndex, $cookie;
return $html;
}
$html = '';
$tax_rules = TaxRule::getTaxRulesByGroupId((int)$cookie->id_lang, (int)$id_rule_group);
if (sizeof($tax_rules) == 0)
{
$html .= '<tr>
<td colspan="7">'.$this->l('No rules defined').'</td>
</tr>';
} else {
foreach ($tax_rules as $tax_rule)
{
// format fields for display
$state_name = ($tax_rule['state_name'] == '' ? '*' : $tax_rule['state_name']);
public function renderCountries($tax_rules, $id_zone, $id_lang)
{
$zipcodes = '*';
if (isset($tax_rule['zipcode_from']) && $tax_rule['zipcode_from'] != 0)
{
$zipcodes = $tax_rule['zipcode_from'];
if (isset($tax_rule['zipcode_to']) && $tax_rule['zipcode_to'] != 0 && $tax_rule['zipcode_to'] != $tax_rule['zipcode_from'])
{
$zipcodes .= '-'.$tax_rule['zipcode_to'];
}
}
$html = '
<table>
<tr>
<td width="260px" style="font-weight:bold">'.$this->l('All').'</td>
<td>'.$this->renderTaxesSelect($id_lang, '', array('id' => 'zone_'.(int)$id_zone)).' <input type="submit" onclick="return applyTax(\''.(int)$id_zone.'\')" class="button" value="'.$this->l('Apply').'"/></td>
</tr>
</table><hr />';
$tax = ((float)$tax_rule['rate'] == 0 ? '-' : (float)$tax_rule['rate'].'%');
$html .= '
<table class="table" cellpadding="0" cellspacing="0" style="width: 100%;">
<thead>
<tr>
<th style="width: 3%;"></th>
<th style="width: 40%;">'.$this->l('Country / State / County').'</th>
<th style="width: 57%;">'.$this->l('Tax to apply').'</th>
</tr>
</thead>
<tbody>
';
$countries = Country::getCountriesByZoneId((int)$id_zone, (int)$id_lang);
$countCountries = sizeof($countries);
$i = 1;
$behavior = ($tax_rule['behavior'] == 0 ? $this->l('This tax only') : $this->l('Compute with others'));
foreach ($countries AS $country)
{
$id_tax = 0;
// render fields
$html .= '<tr>
<td>'.Tools::htmlentitiesUTF8($tax_rule['country_name']).'</td>
<td>'.Tools::htmlentitiesUTF8($state_name).'</td>
<td>'.Tools::htmlentitiesUTF8($zipcodes).'</td>
<td>'.Tools::htmlentitiesUTF8($behavior).'</td>
<td>'.Tools::htmlentitiesUTF8($tax).'</td>
<td>'.Tools::htmlentitiesUTF8($tax_rule['description']).'</td>
<td>
<a href="#" onclick="loadTaxRule(\''.$tax_rule['id_tax_rule'].'\'); return false;">
<img src="../img/admin/edit.gif" border="0" alt="'.$this->l('Edit').'" title="'.$this->l('Edit').'" />
</a>
<a href="'.$currentIndex.'&id_tax_rule='.$tax_rule['id_tax_rule'].'&action=delete_rule&token='.$this->token.'" onclick="return confirm(\''.addslashes($this->l('Delete item ?')).'\');">
<img src="../img/admin/delete.gif" border="0" alt="'.$this->l('Delete').'" title="'.$this->l('Delete').'" />
</a>
if (array_key_exists($country['id_country'], $tax_rules) AND array_key_exists(0, $tax_rules[$country['id_country']]))
$id_tax = (int)$tax_rules[$country['id_country']][0][0]['id_tax'];
$html .= '
<tr>
<td>'.($country['contains_states'] ? '<a class="open_state" id="state_'.(int)$country['id_country'].'"><img id="state_'.(int)$country['id_country'].'_button" src="../img/admin/more.png" alt="" style="vertical-align:middle;padding:0;" /></a>' : '').'</td>
<td>
<img src="../img/admin/lv2_'.($i == $countCountries ? 'f' : 'b').'.png" alt="" style="vertical-align:middle;" /> <label class="t">'.Tools::htmlentitiesUTF8($country['name']).'</label>
</td>
<td>'.$this->renderTaxesSelect($id_lang, $id_tax, array('class' => 'tax_'.$id_zone, 'id' => 'tax_'.$country['id_country'].'_0', 'name' => 'tax_'.$country['id_country'].'_0' )).'</td>
</tr>
';
if ($country['contains_states']) {
$html .= $this->renderStates($tax_rules, (int)$id_zone, (int)$country['id_country'], (int)$id_lang);
</td>
</tr>';
}
$i++;
}
$html .= '
</tbody>
</table>
';
}
return $html;
}
}
public function renderStates($tax_rules, $id_zone, $id_country, $id_lang)
{
$states = State::getStatesByIdCountry((int)$id_country);
$countStates = sizeof($states);
$i = 1;
$html = '';
foreach ($states AS $state)
/**
* @param boolean $firstCall
*/
public function displayForm($firstCall = true)
{
if (!($obj = $this->loadObject(true)))
return;
parent::displayForm();
$this->displayRuleGroupForm();
$this->displayJS();
// display tax rules only if the group has already been created
if ($obj->id)
{
$id_tax = 0;
$selected = PS_PRODUCT_TAX;
if (array_key_exists($id_country, $tax_rules)
AND array_key_exists($state['id_state'], $tax_rules[$id_country])
AND array_key_exists(0, $tax_rules[$id_country][$state['id_state']]))
{
$id_tax = (int)$tax_rules[$id_country][$state['id_state']][0]['id_tax'];
$selected = (int)$tax_rules[$id_country][$state['id_state']][0]['state_behavior'];
}
$disable = (PS_PRODUCT_TAX == $selected ? 'disabled' : '');
$html .= '
<tr class="states state_'.(int)$id_country.' alt_row">
<td>'.(State::hasCounties($state['id_state']) ? '<a class="open_county" id="county_'.(int)$state['id_state'].'"><img id="county_'.(int)$state['id_state'].'_button" class="county_state_'.(int)$id_country.'_button" src="../img/admin/more.png" alt="" /></a>' : '').'</td>
<td><img src="../img/admin/lv3_'.($i == $countStates ? 'f' : 'b').'.png" alt="" style="vertical-align:middle;" /> <label class="t">'.Tools::htmlentitiesUTF8($state['name']).'</label></td>
<td>
'.$this->renderTaxesSelect($id_lang, $id_tax, array('class' => 'tax_'.$id_zone,
'id' => 'tax_'.$id_country.'_'.$state['id_state'],
'name' => 'tax_'.$id_country.'_'.$state['id_state'],
'disabled' => $disable )).'&nbsp;-&nbsp;
<select id="behavior_state_'.$state['id_state'].'" name="behavior_state_'.$state['id_state'].'" onchange="disableStateTaxRate(\''.$id_country.'\',\''.$state['id_state'].'\')">
<option value="'.(int)PS_PRODUCT_TAX.'" '.($selected == PS_PRODUCT_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply country tax only').'</option>
<option value="'.(int)PS_STATE_TAX.'" '.($selected == PS_STATE_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply state tax only').'</option>
<option value="'.(int)PS_BOTH_TAX.'" '.($selected == PS_BOTH_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply both taxes').'</option>
</select>
</td>
</tr>
';
if (State::hasCounties($state['id_state']))
$html .= $this->renderCounties($tax_rules, $id_zone, $id_country, $state['id_state'], $id_lang);
$i++;
echo '<hr />';
$this->displayTaxRulesErrors();
$this->displayRuleForm($obj->id);
$this->displayRulesList($obj->id);
}
return $html;
}
public function renderCounties($tax_rules, $id_zone, $id_country, $id_state, $id_lang)
{
$counties = County::getCounties((int)$id_state);
$countCounties = sizeof($counties);
$i = 1;
$html = '';
foreach ($counties AS $county)
{
$id_tax = 0;
$selected = County::USE_STATE_TAX;
if (array_key_exists($id_country, $tax_rules)
AND array_key_exists($id_state, $tax_rules[$id_country])
AND array_key_exists($county['id_county'], $tax_rules[$id_country][$id_state]))
{
$id_tax = (int)$tax_rules[$id_country][$id_state][$county['id_county']]['id_tax'];
$selected = (int)$tax_rules[$id_country][$id_state][$county['id_county']]['county_behavior'];
}
$disable = (County::USE_STATE_TAX == $selected ? 'disabled' : '');
$html .= '
<tr class="counties county_state_'.(int)$id_country.' county_'.(int)$id_state.'">
<td></td>
<td><img src="../img/admin/lv4_'.($i == $countCounties ? 'f' : 'b').'.png" alt="" style="vertical-align:middle;" /> <label class="t">'.Tools::htmlentitiesUTF8($county['name']).'</label></td>
<td>
'.$this->renderTaxesSelect($id_lang, $id_tax, array('class' => 'tax_'.$id_zone,
'id' => 'tax_'.$id_country.'_'.$id_state.'_'.$county['id_county'],
'name' => 'tax_'.$id_country.'_'.$id_state.'_'.$county['id_county'],
'disabled' => $disable )).'&nbsp;-&nbsp;
<select id="behavior_county_'.$county['id_county'].'" name="behavior_county_'.$county['id_county'].'" onchange="disableCountyTaxRate(\''.$id_country.'\',\''.$id_state.'\',\''.$county['id_county'].'\')">
<option value="'.(int)County::USE_STATE_TAX.'" '.($selected == County::USE_STATE_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply state tax only').'</option>
<option value="'.(int)County::USE_COUNTY_TAX.'" '.($selected == County::USE_COUNTY_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply county tax only').'</option>
<option value="'.(int)County::USE_BOTH_TAX.'" '.($selected == County::USE_BOTH_TAX ? 'selected="selected"' : '').'>'.$this->l('Apply both taxes').'</option>
</select>
</td>
</tr>
';
}
return $html;
}
public function renderTaxesSelect($id_lang, $default_value, $html_options)
{
$opt = '';
foreach( array('id', 'class', 'name', 'disabled') AS $prop)
if (array_key_exists($prop, $html_options) && !empty($html_options[$prop]))
$opt .= $prop.'="'.$html_options[$prop].'"';
$html = '<select '.$opt.'>
<option value="0">'.$this->l('No Tax').'</option>';
$taxes = Tax::getTaxes((int)$id_lang, true);
foreach ($taxes AS $tax)
{
$selected = ($default_value == $tax['id_tax']) ? 'selected="selected"' : '';
$html .= '<option value="'.(int)$tax['id_tax'].'" '.$selected.'>'.Tools::htmlentitiesUTF8($tax['name']).'</option>';
}
$html .= '</select>';
return $html;
}
protected function afterAdd($object)
{
$this->afterUpdate($object);
}
protected function afterUpdate($object)
{
TaxRule::deleteByGroupId($object->id);
foreach(Country::getCountries($this->context->language->id, true) AS $country)
{
$id_tax = (int)Tools::getValue('tax_'.$country['id_country'].'_0');
// default country rule
if (!empty($id_tax))
{
$tr = new TaxRule();
$tr->id_tax_rules_group = $object->id;
$tr->id_country = (int)$country['id_country'];
$tr->id_state = 0;
$tr->id_county = 0;
$tr->id_tax = $id_tax;
$tr->state_behavior = 0;
$tr->county_behavior = 0;
$tr->save();
}
// state specific rule
if (!empty($country['contains_states']))
{
foreach ($country['states'] AS $state)
{
$state_behavior = (int)Tools::getValue('behavior_state_'.$state['id_state']);
if ($state_behavior != PS_PRODUCT_TAX)
{
$tr = new TaxRule();
$tr->id_tax_rules_group = $object->id;
$tr->id_country = (int)$country['id_country'];
$tr->id_state = (int)$state['id_state'];
$tr->id_county = 0;
$tr->id_tax = (int)Tools::getValue('tax_'.$country['id_country'].'_'.$state['id_state']);
$tr->state_behavior = $state_behavior;
$tr->county_behavior = 0;
$tr->save();
}
// county specific rule
if (State::hasCounties($state['id_state']))
{
$counties = County::getCounties($state['id_state']);
foreach ($counties AS $county)
{
$county_behavior = (int)Tools::getValue('behavior_county_'.$county['id_county']);
if ($county_behavior != County::USE_STATE_TAX)
{
$tr = new TaxRule();
$tr->id_tax_rules_group = $object->id;
$tr->id_country = (int)$country['id_country'];
$tr->id_state = (int)$state['id_state'];
$tr->id_county = (int)$county['id_county'];
$tr->id_tax = (int)Tools::getValue('tax_'.$country['id_country'].'_'.$state['id_state'].'_'.$county['id_county']);
$tr->state_behavior = 0;
$tr->county_behavior = $county_behavior;
$tr->save();
}
}
}
}
}
}
}
public function postProcess()
{
if (!isset($this->table))
return false;
// set token
$token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
if (Tools::getValue('submitAdd'.$this->table))
{
$id_product = Tools::getValue('id_product');
/* Checking fields validity */
$this->validateRules();
if (!sizeof($this->_errors))
{
$id = (int)(Tools::getValue($this->identifier));
/* Object update */
if (isset($id) AND !empty($id))
{
if ($this->tabAccess['edit'] === '1')
{
$object = new $this->className($id);
if (Validate::isLoadedObject($object))
{
/* Specific to objects which must not be deleted */
if ($this->deleted AND $this->beforeDelete($object))
{
// Create new one with old objet values
$objectNew = new $this->className($object->id);
$objectNew->id = NULL;
$objectNew->date_add = '';
$objectNew->date_upd = '';
// Update old object to deleted
$object->deleted = 1;
$object->update();
// Update new object with post values
$this->copyFromPost($objectNew, $this->table);
$result = $objectNew->add();
if (Validate::isLoadedObject($objectNew))
$this->afterDelete($objectNew, $object->id);
}
else
{
$this->copyFromPost($object, $this->table);
$result = $object->update();
$this->afterUpdate($object);
}
if (!$result)
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> ('.Db::getInstance()->getMsgError().')';
elseif ($this->postImage($object->id) AND !sizeof($this->_errors))
{
$parent_id = (int)(Tools::getValue('id_parent', 1));
// Save and stay on same form
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=4&update'.$this->table.'&token='.$token);
// Default behavior (save and back)
$id_product = (int)Tools::getValue('id_product');
if ($id_product)
Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id));
Tools::redirectAdmin(self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token);
}
}
else
$this->_errors[] = Tools::displayError('An error occurred while updating object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
}
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
/* Object creation */
else
{
if ($this->tabAccess['add'] === '1')
{
$object = new $this->className();
$this->copyFromPost($object, $this->table);
if (!$object->add())
$this->_errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.' ('.Db::getInstance()->getMsgError().')</b>';
elseif (($_POST[$this->identifier] = $object->id /* voluntary */) AND $this->postImage($object->id) AND !sizeof($this->_errors) AND $this->_redirect)
{
$parent_id = (int)(Tools::getValue('id_parent', 1));
$this->afterAdd($object);
// Save and stay on same form
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
Tools::redirectAdmin(self::$currentIndex.'&'.$this->identifier.'='.$object->id.'&conf=3&update'.$this->table.'&token='.$token);
$id_product = (int)Tools::getValue('id_product');
if ($id_product)
Tools::redirectAdmin('?tab=AdminCatalog&id_product='.$id_product.'&updateproduct&token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id));
Tools::redirectAdmin(self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token);
// Default behavior (save and back)
Tools::redirectAdmin(self::$currentIndex.($parent_id ? '&'.$this->identifier.'='.$object->id : '').'&conf=3&token='.$token);
}
}
else
$this->_errors[] = Tools::displayError('You do not have permission to add here.');
}
}
$this->_errors = array_unique($this->_errors);
}
parent::postProcess();
}
}
}
+5 -3
View File
@@ -156,9 +156,9 @@ class AdminTracking extends AdminTab
</tr>';
foreach ($this->_list['obj'] AS $k => $prod)
{
$product = new Product((int)($prod['id_product']));
$product = new Product((int)$prod['id_product'], false);
$product->name = $product->name[(int)$this->context->language->id];
$taxrate = Tax::getProductTaxRate($product->id);
$taxrate = $product->getTaxesRate();
echo '
<tr>
@@ -222,13 +222,15 @@ class AdminTracking extends AdminTab
else
$prod['combination_name'] = $prod['group_name'].' : '.$prod['attribute_name'];
$attributes[$prod['id_product_attribute']] = $prod;
$prevAttributeId = $prod['id_product_attribute'];
}
foreach ($attributes AS $prod)
{
$taxrate = Tax::getProductTaxRate($prod['id_product']);
$product = new Product((int)$prod['id_product'], false);
$tax_rate = $product->getTaxesRate();
echo '
<tr>