diff --git a/admin-dev/tabs/AdminTaxes.php b/admin-dev/tabs/AdminTaxes.php
deleted file mode 100644
index 5c0d5732e..000000000
--- a/admin-dev/tabs/AdminTaxes.php
+++ /dev/null
@@ -1,205 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision: 7060 $
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-class AdminTaxes extends AdminTab
-{
- public function __construct()
- {
- $this->table = 'tax';
- $this->className = 'Tax';
- $this->lang = true;
- $this->edit = true;
- $this->delete = true;
-
- $this->fieldsDisplay = array(
- 'id_tax' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
- 'name' => array('title' => $this->l('Name'), 'width' => 140),
- 'rate' => array('title' => $this->l('Rate'), 'align' => 'center', 'suffix' => '%', 'width' => 50),
- 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
-
- $ecotax_desc = '';
- if (Configuration::get('PS_USE_ECOTAX'))
- $ecotax_desc = $this->l('If you disable the ecotax, the ecotax for all your products will be set to 0');
-
- $this->optionsList = array(
- 'general' => array(
- 'title' => $this->l('Tax options'),
- 'fields' => array(
- 'PS_TAX' => array('title' => $this->l('Enable tax:'), 'desc' => $this->l('Select whether or not to include tax on purchases'), 'cast' => 'intval', 'type' => 'bool'),
- 'PS_TAX_DISPLAY' => array('title' => $this->l('Display tax in cart:'), 'desc' => $this->l('Select whether or not to display tax on a distinct line in the cart'), 'cast' => 'intval', 'type' => 'bool'),
- 'PS_TAX_ADDRESS_TYPE' => array('title' => $this->l('Base on:'), 'cast' => 'pSQL', 'type' => 'select', 'list' => array(array('name' => $this->l('Invoice Address'), 'id' => 'id_address_invoice'), array('name' => $this->l('Delivery Address'), 'id' => 'id_address_delivery')), 'identifier' => 'id'),
- 'PS_USE_ECOTAX' => array('title' => $this->l('Use ecotax'), 'desc' => $ecotax_desc, 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
- ),
- ),
- );
-
- if (Configuration::get('PS_USE_ECOTAX'))
- $this->optionsList['general']['fields']['PS_ECOTAX_TAX_RULES_GROUP_ID'] = array('title' => $this->l('Ecotax:'), 'desc' => $this->l('The tax to apply on the ecotax (e.g., French ecotax: 19.6%).'),
- 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_tax', 'identifier' => 'id_tax_rules_group', 'list' => TaxRulesGroup::getTaxRulesGroupsForOptions());
-
- parent::__construct();
- }
-
- public function displayForm($isMainTab = true)
- {
- parent::displayForm();
-
- if (!($obj = $this->loadObject(true)))
- return;
- $zones = Zone::getZones(true);
- $states = State::getStates($this->context->language->id);
-
- echo '
-
';
- }
-
- public function postProcess()
- {
- if (Tools::getValue('submitAdd'.$this->table))
- {
- /* Checking fields validity */
- $this->validateRules();
- if (!sizeof($this->_errors))
- {
- $id = (int)(Tools::getValue('id_'.$this->table));
-
- /* Object update */
- if (isset($id) AND !empty($id))
- {
- if ($this->tabAccess['edit'] === '1')
- {
- $object = new $this->className($id);
- if (Validate::isLoadedObject($object))
- {
- $this->copyFromPost($object, $this->table);
- $result = $object->update(false, false);
-
- if (!$result)
- $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.'';
- elseif ($this->postImage($object->id))
- {
- Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=4'.'&token='.$this->token);
- }
- }
- else
- $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.' '.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.').' '.$this->table.'';
- elseif (($_POST['id_'.$this->table] = $object->id /* voluntary */) AND $this->postImage($object->id) AND $this->_redirect)
- {
- Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=3'.'&token='.$this->token);
- }
- }
- else
- $this->_errors[] = Tools::displayError('You do not have permission to add here.');
- }
- }
- }
- else
- parent::postProcess();
- }
-
- protected function _displayDeleteLink($token = NULL, $id)
- {
- $_cacheLang['Delete'] = $this->l('Delete', __CLASS__, TRUE, FALSE);
-
- $_cacheLang['DeleteItem'] = $this->l('Delete item #', __CLASS__, TRUE, FALSE).$id.' ?)';
- if (TaxRule::isTaxInUse($id))
- $_cacheLang['DeleteItem'] = $this->l('This tax is currently in use in a tax rule. Are you sure?');
-
- echo '
-
-
';
- }
-
- protected function _displayEnableLink($token, $id, $value, $active, $id_category = NULL, $id_product = NULL)
- {
- $confirm = ($value AND TaxRule::isTaxInUse($id)) ? 'onclick="return confirm(\''. $this->l('This tax is currently in use in a tax rule. If you continue this tax will be removed from the tax rule, are you sure?').'\')"' : '';
-
- echo '
-
';
- }
-
- public function updateOptionPsUseEcotax($value)
- {
- $old_value = (int)Configuration::get('PS_USE_ECOTAX');
-
- if ($old_value != $value)
- {
- // Reset ecotax
- if ($value == 0)
- Product::resetEcoTax();
-
- Configuration::updateValue('PS_USE_ECOTAX', (int)$value);
- }
- }
-}
diff --git a/admin-dev/themes/template/geolocation/options.tpl b/admin-dev/themes/template/geolocation/options.tpl
index 09272d0fa..48a112257 100644
--- a/admin-dev/themes/template/geolocation/options.tpl
+++ b/admin-dev/themes/template/geolocation/options.tpl
@@ -24,7 +24,7 @@
* International Registered Trademark & Property of PrestaShop SA
*}
-{extends file="../options.tpl"}
+{extends file="helper/options/options.tpl"}
{block name="start_field_block"}
{if $field['type'] == 'checkbox_table'}
diff --git a/admin-dev/themes/template/helper/list/list_content.tpl b/admin-dev/themes/template/helper/list/list_content.tpl
index 76505d3e9..68c32d307 100644
--- a/admin-dev/themes/template/helper/list/list_content.tpl
+++ b/admin-dev/themes/template/helper/list/list_content.tpl
@@ -30,19 +30,11 @@
{if $index is odd}class="alt_row"{/if}
{if isset($tr.color) && $color_on_bg}style="background-color: {$tr.color}"{/if}
>
-
- {if $bulk_actions}
- {assign var=bulkActionPossible value=true}
- {foreach $list_skip_actions as $key => $value}
- {if in_array($tr.$identifier, $value) == true}
- {assign var=bulkActionPossible value=false}
- {/if}
- {/foreach}
- {if $bulkActionPossible == true}
-
- {/if}
- {/if}
- |
+ {if isset($tr.has_bulk_actions) && $tr.has_bulk_actions}
+
+
+ |
+ {/if}
{foreach $fields_display AS $key => $params}
|
|
- {if $delete}
+ {if $has_bulk_actions}
{/if}
|
diff --git a/classes/HelperList.php b/classes/HelperList.php
index 2e872ba97..c42d9e35a 100644
--- a/classes/HelperList.php
+++ b/classes/HelperList.php
@@ -159,18 +159,19 @@ class HelperListCore extends Helper
* @param string $token
* @param int $id
* @param int $value state enabled or not
- * @param unknown_type $active
- * @param unknown_type $id_category
- * @param unknown_type $id_product
+ * @param string $active status
+ * @param int $id_category
+ * @param int $id_product
*/
protected function displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null)
{
- $this->context->smarty->assign(array(
+ $tpl_enable = $this->context->smarty->createTemplate('helper/list/list_action_enable.tpl');
+ $tpl_enable->assign(array(
'enabled' => (bool)$value,
'url_enable' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&'.$active.$this->table.
((int)$id_category && (int)$id_product ? '&id_category='.$id_category : '').'&token='.($token != null ? $token : $this->token)
));
- return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/helper/list/list_action_enable.tpl');
+ return $tpl_enable->fetch();
}
public function displayListContent($token = null)
@@ -213,16 +214,26 @@ class HelperListCore extends Helper
$this->_list[$index][$action] = $this->context->controller->$method_name($token, $id);
else if (method_exists($this, $method_name))
$this->_list[$index][$action] = $this->$method_name($token, $id);
+
+ // At least one bulk action is possible for this row
+ $this->_list[$index]['has_bulk_actions'] = true;
}
}
+
foreach ($this->fieldsDisplay as $key => $params)
{
$tmp = explode('!', $key);
$key = isset($tmp[1]) ? $tmp[1] : $tmp[0];
if (isset($params['active']))
- $this->_list[$index][$key] = $this->displayEnableLink(
+ {
+ // If method is defined in calling controller, use it instead of the Helper method
+ if (method_exists($this->context->controller, 'displayEnableLink'))
+ $calling_obj = $this->context->controller;
+ else
+ $calling_obj = $this;
+ $this->_list[$index][$key] = $calling_obj->displayEnableLink(
$this->token,
$id,
$tr[$key],
@@ -230,6 +241,7 @@ class HelperListCore extends Helper
Tools::getValue('id_category'),
Tools::getValue('id_product')
);
+ }
else if (isset($params['activeVisu']))
$this->_list[$index][$key] = (bool)$tr[$key];
else if (isset($params['position']))
@@ -309,6 +321,7 @@ class HelperListCore extends Helper
'view' => in_array('view', $this->actions),
'edit' => in_array('edit', $this->actions),
'has_actions' => (bool)count($this->actions),
+ 'has_bulk_actions' => (bool)count($this->bulk_actions),
'list_skip_actions' => $this->list_skip_actions,
));
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/'.$this->content_tpl);
@@ -550,7 +563,8 @@ class HelperListCore extends Helper
'identifier' => $this->identifier,
'id_cat' => $id_cat,
'shop_link_type' => $this->shopLinkType,
- 'has_actions' => (boolean)count($this->actions),
+ 'has_actions' => (bool)count($this->actions),
+ 'has_bulk_actions' => (bool)count($this->bulk_actions),
'toolbar_btn' => $this->toolbar_btn,
'table_id' => isset($table_id) ? $table_id : null,
'table_dnd' => isset($table_dnd) ? $table_dnd : null,
diff --git a/controllers/admin/AdminTaxesController.php b/controllers/admin/AdminTaxesController.php
new file mode 100644
index 000000000..1b2141e2f
--- /dev/null
+++ b/controllers/admin/AdminTaxesController.php
@@ -0,0 +1,237 @@
+
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 7060 $
+* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*/
+
+class AdminTaxesControllerCore extends AdminController
+{
+ public function __construct()
+ {
+ $this->table = 'tax';
+ $this->className = 'Tax';
+ $this->lang = true;
+ $this->addRowAction('edit');
+ $this->addRowAction('delete');
+ $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
+
+ $this->fieldsDisplay = array(
+ 'id_tax' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
+ 'name' => array('title' => $this->l('Name'), 'width' => 140),
+ 'rate' => array('title' => $this->l('Rate'), 'align' => 'center', 'suffix' => '%', 'width' => 50),
+ 'active' => array('title' => $this->l('Enabled'), 'width' => 25, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
+
+ $ecotax_desc = '';
+ if (Configuration::get('PS_USE_ECOTAX'))
+ $ecotax_desc = $this->l('If you disable the ecotax, the ecotax for all your products will be set to 0');
+
+ $this->options = array(
+ 'general' => array(
+ 'title' => $this->l('Tax options'),
+ 'fields' => array(
+ 'PS_TAX' => array('title' => $this->l('Enable tax:'), 'desc' => $this->l('Select whether or not to include tax on purchases'), 'cast' => 'intval', 'type' => 'bool'),
+ 'PS_TAX_DISPLAY' => array('title' => $this->l('Display tax in cart:'), 'desc' => $this->l('Select whether or not to display tax on a distinct line in the cart'), 'cast' => 'intval', 'type' => 'bool'),
+ 'PS_TAX_ADDRESS_TYPE' => array('title' => $this->l('Base on:'), 'cast' => 'pSQL', 'type' => 'select', 'list' => array(array('name' => $this->l('Invoice Address'), 'id' => 'id_address_invoice'), array('name' => $this->l('Delivery Address'), 'id' => 'id_address_delivery')), 'identifier' => 'id'),
+ 'PS_USE_ECOTAX' => array('title' => $this->l('Use ecotax'), 'desc' => $ecotax_desc, 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'),
+ ),
+ 'submit' => array()
+ ),
+ );
+
+ if (Configuration::get('PS_USE_ECOTAX'))
+ $this->optionsList['general']['fields']['PS_ECOTAX_TAX_RULES_GROUP_ID'] = array('title' => $this->l('Ecotax:'), 'desc' => $this->l('The tax to apply on the ecotax (e.g., French ecotax: 19.6%).'),
+ 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_tax', 'identifier' => 'id_tax_rules_group', 'list' => TaxRulesGroup::getTaxRulesGroupsForOptions());
+
+ parent::__construct();
+ }
+
+ /**
+ * Display delete action link
+ */
+ public function displayDeleteLink($token = null, $id)
+ {
+ if (!array_key_exists('Delete', self::$cache_lang))
+ self::$cache_lang['Delete'] = $this->l('Delete');
+
+ if (!array_key_exists('DeleteItem', self::$cache_lang))
+ self::$cache_lang['DeleteItem'] = $this->l('Delete item #', __CLASS__, true, false);
+
+ if (TaxRule::isTaxInUse($id))
+ $confirm = $this->l('This tax is currently in use in a tax rule. Are you sure?');
+
+ $this->context->smarty->assign(array(
+ 'href' => self::$currentIndex.'&'.$this->identifier.'='.$id.'&delete'.$this->table.'&token='.($token != null ? $token : $this->token),
+ 'confirm' => (isset($confirm) ? '\r'.$confirm : self::$cache_lang['DeleteItem'].$id.' ? '),
+ 'action' => self::$cache_lang['Delete'],
+ ));
+
+ return $this->context->smarty->fetch('helper/list/list_action_delete.tpl');
+ }
+
+ /**
+ * Fetch the template for action enable
+ *
+ * @param string $token
+ * @param int $id
+ * @param int $value state enabled or not
+ * @param string $active status
+ * @param int $id_category
+ * @param int $id_product
+ */
+ public function displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null)
+ {
+ if ($value AND TaxRule::isTaxInUse($id))
+ $confirm = $this->l('This tax is currently in use in a tax rule. If you continue this tax will be removed from the tax rule, are you sure?');
+
+ $tpl_enable = $this->context->smarty->createTemplate('helper/list/list_action_enable.tpl');
+ $tpl_enable->assign(array(
+ 'enabled' => (bool)$value,
+ 'url_enable' => self::$currentIndex.'&'.$this->identifier.'='.$id.'&'.$active.$this->table.
+ ((int)$id_category && (int)$id_product ? '&id_category='.$id_category : '').'&token='.($token != null ? $token : $this->token),
+ 'confirm' => isset($confirm) ? $confirm : null,
+ ));
+
+ return $tpl_enable->fetch();
+ }
+
+ public function initForm()
+ {
+ $this->fields_form = array(
+ 'legend' => array(
+ 'title' => $this->l('Taxes'),
+ 'image' => '../img/admin/dollar.gif'
+ ),
+ 'input' => array(
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('Name:'),
+ 'name' => 'name',
+ 'size' => 33,
+ 'required' => true,
+ 'lang' => true,
+ 'hint' => $this->l('Invalid characters:').' <>;=#{}',
+ 'p' => $this->l('Tax name to display in cart and on invoice, e.g., VAT')
+ ),
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('Rate:'),
+ 'name' => 'rate',
+ 'size' => 4,
+ 'maxlength' => 6,
+ 'required' => true,
+ 'hint' => $this->l('Invalid characters:').' <>;=#{}',
+ 'p' => $this->l('Format: XX.XX or XX.XXX (e.g., 19.60 or 13.925)')
+ ),
+ array(
+ 'type' => 'radio',
+ 'label' => $this->l('Enable:'),
+ 'name' => 'active',
+ 'required' => false,
+ 'class' => 't',
+ 'is_bool' => true,
+ 'values' => array(
+ array(
+ 'id' => 'active_on',
+ 'value' => 1,
+ 'label' => $this->l('Enabled')
+ ),
+ array(
+ 'id' => 'active_off',
+ 'value' => 0,
+ 'label' => $this->l('Disabled')
+ )
+ )
+ )
+ ),
+ 'submit' => array(
+ 'title' => $this->l(' Save '),
+ 'class' => 'button'
+ )
+ );
+
+ return parent::initForm();
+ }
+
+ public function postProcess()
+ {
+ if ($this->action == 'save')
+ {
+ /* Checking fields validity */
+ $this->validateRules();
+ if (!sizeof($this->_errors))
+ {
+ $id = (int)(Tools::getValue('id_'.$this->table));
+
+ /* Object update */
+ if (isset($id) AND !empty($id))
+ {
+ $object = new $this->className($id);
+ if (Validate::isLoadedObject($object))
+ {
+ $this->copyFromPost($object, $this->table);
+ $result = $object->update(false, false);
+
+ if (!$result)
+ $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.'';
+ elseif ($this->postImage($object->id))
+ {
+ Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=4'.'&token='.$this->token);
+ }
+ }
+ else
+ $this->_errors[] = Tools::displayError('An error occurred while updating object.').' '.$this->table.' '.Tools::displayError('(cannot load object)');
+ }
+
+ /* Object creation */
+ else
+ {
+ $object = new $this->className();
+ $this->copyFromPost($object, $this->table);
+ if (!$object->add())
+ $this->_errors[] = Tools::displayError('An error occurred while creating object.').' '.$this->table.'';
+ elseif (($_POST['id_'.$this->table] = $object->id /* voluntary */) AND $this->postImage($object->id) AND $this->_redirect)
+ {
+ Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=3'.'&token='.$this->token);
+ }
+ }
+ }
+ }
+ else
+ parent::postProcess();
+ }
+
+ public function updateOptionPsUseEcotax($value)
+ {
+ $old_value = (int)Configuration::get('PS_USE_ECOTAX');
+
+ if ($old_value != $value)
+ {
+ // Reset ecotax
+ if ($value == 0)
+ Product::resetEcoTax();
+
+ Configuration::updateValue('PS_USE_ECOTAX', (int)$value);
+ }
+ }
+}