diff --git a/admin-dev/tabs/AdminCountries.php b/admin-dev/tabs/AdminCountries.php
deleted file mode 100644
index b8cb72fb0..000000000
--- a/admin-dev/tabs/AdminCountries.php
+++ /dev/null
@@ -1,353 +0,0 @@
-
-* @copyright 2007-2011 PrestaShop SA
-* @version Release: $Revision: 7310 $
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-include_once(_PS_ADMIN_DIR_.'/../classes/AdminTab.php');
-
-class AdminCountries extends AdminTab
-{
- public function __construct()
- {
- $this->table = 'country';
- $this->className = 'Country';
- $this->lang = true;
- $this->edit = true;
- $this->deleted = false;
- $this->_select = 'z.`name` AS zone';
- $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)';
-
- $this->fieldsDisplay = array(
- 'id_country' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
- 'name' => array('title' => $this->l('Country'), 'width' => 130, 'filter_key' => 'b!name'),
- 'iso_code' => array('title' => $this->l('ISO code'), 'width' => 70, 'align' => 'center'),
- 'call_prefix' => array('title' => $this->l('Call prefix'), 'width' => 40, 'align' => 'center', 'callback' => 'displayCallPrefix'),
- 'zone' => array('title' => $this->l('Zone'), 'width' => 100, 'filter_key' => 'z!name'),
- 'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'),
- );
-
- $this->optionsList = array(
- 'general' => array(
- 'title' => $this->l('Countries options'),
- 'fields' => array(
- 'PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries(Context::getContext()->language->id)),
- 'PS_RESTRICT_DELIVERED_COUNTRIES' => array('title' => $this->l('Restrict countries in FO by those delivered by active carriers'), 'cast' => 'intval', 'type' => 'bool', 'default' => '0')
- ),
- ),
- );
-
- parent::__construct();
- }
-
- public function postProcess()
- {
- if (isset($_GET['delete'.$this->table]) OR Tools::getValue('submitDel'.$this->table))
- $this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.');
- else
- {
- if (Tools::getValue('submitAdd'.$this->table))
- {
- $id_country = Tools::getValue('id_country');
- $tmp_addr_format = new AddressFormat($id_country);
-
- $save_status = false;
-
- $is_new = is_null($tmp_addr_format->id_country);
- if ($is_new)
- {
- $tmp_addr_format = new AddressFormat();
- $tmp_addr_format->id_country = $id_country;
- }
-
- $tmp_addr_format->format = Tools::getValue('address_layout');
-
- if (strlen($tmp_addr_format->format) > 0)
- {
- if ($tmp_addr_format->checkFormatFields())
- $save_status = ($is_new) ? $tmp_addr_format->save(): $tmp_addr_format->update();
- else
- {
- $errorList = $tmp_addr_format->getErrorList();
- foreach($errorList as $numError => $error)
- $this->_errors[] = $error;
- }
-
-
- if (!$save_status)
- $this->_errors[] = Tools::displayError('Invalid address layout'.Db::getInstance()->getMsgError());
- }
- unset($tmp_addr_format);
- }
-
- return parent::postProcess();
- }
- }
-
- private function _displayValidFields()
- {
- $html = '
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 8971 $
+* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*}
+
+{if $firstCall}
+
+
+
+{/if}
+
+
+
+
+
+{if $firstCall}
+ {if $back}
+ {l s='Back'}
+ {else}
+ {l s='Back to list'}
+ {/if}
+
+{/if}
diff --git a/admin-dev/themes/template/list_header.tpl b/admin-dev/themes/template/list_header.tpl
index 8786db544..ddb47c74a 100644
--- a/admin-dev/themes/template/list_header.tpl
+++ b/admin-dev/themes/template/list_header.tpl
@@ -69,13 +69,13 @@
{if $page > 1}
-
-
+
+
{/if}
{l s='Page '}{$page} / {$total_pages}
{if $page < $total_pages}
-
-
+
+
{/if}
| {l s='Display'}
diff --git a/classes/AdminController.php b/classes/AdminController.php
index 0a37d2dd2..87b5c6dd6 100644
--- a/classes/AdminController.php
+++ b/classes/AdminController.php
@@ -538,6 +538,10 @@ class AdminControllerCore extends Controller
/* Table alias could be specified using a ! eg. alias!field */
$tmp_tab = explode('!', $key);
$key = (count($tmp_tab) > 1 ? $tmp_tab[1] : $tmp_tab[0]);
+
+ // init list declaration
+ $this->initList();
+
if (array_key_exists($key, $this->fieldsDisplay))
unset($this->context->cookie->$cookie_key);
}
@@ -746,6 +750,9 @@ class AdminControllerCore extends Controller
protected function filterToField($key, $filter)
{
+ // init list declaration
+ $this->initList();
+
foreach ($this->fieldsDisplay as $field)
if (array_key_exists('filter_key', $field) && $field['filter_key'] == $key)
return $field;
diff --git a/classes/Country.php b/classes/Country.php
index 673d44156..6e0a5beb8 100644
--- a/classes/Country.php
+++ b/classes/Country.php
@@ -27,53 +27,65 @@
class CountryCore extends ObjectModel
{
- public $id;
+ public $id;
/** @var integer Zone id which country belongs */
- public $id_zone;
+ public $id_zone;
/** @var integer Currency id which country belongs */
- public $id_currency;
+ public $id_currency;
/** @var string 2 letters iso code */
- public $iso_code;
+ public $iso_code;
/** @var integer international call prefix */
- public $call_prefix;
+ public $call_prefix;
/** @var string Name */
- public $name;
+ public $name;
/** @var boolean Contain states */
- public $contains_states;
+ public $contains_states;
/** @var boolean Need identification number dni/nif/nie */
- public $need_identification_number;
+ public $need_identification_number;
/** @var boolean Need Zip Code */
- public $need_zip_code;
+ public $need_zip_code;
/** @var string Zip Code Format */
- public $zip_code_format;
+ public $zip_code_format;
/** @var boolean Display or not the tax incl./tax excl. mention in the front office */
public $display_tax_label = true;
/** @var boolean Status for delivery */
- public $active = true;
+ public $active = true;
protected static $_idZones = array();
- protected $tables = array ('country', 'country_lang');
+ protected $tables = array ('country', 'country_lang');
- protected $fieldsRequired = array('id_zone', 'id_currency', 'iso_code', 'contains_states', 'need_identification_number', 'display_tax_label');
- protected $fieldsSize = array('iso_code' => 3);
- protected $fieldsValidate = array('id_zone' => 'isUnsignedId', 'id_currency' => 'isUnsignedId', 'call_prefix' => 'isInt', 'iso_code' => 'isLanguageIsoCode', 'active' => 'isBool', 'contains_states' => 'isBool', 'need_identification_number' => 'isBool', 'need_zip_code' => 'isBool', 'zip_code_format' => 'isZipCodeFormat', 'display_tax_label' => 'isBool');
- protected $fieldsRequiredLang = array('name');
- protected $fieldsSizeLang = array('name' => 64);
- protected $fieldsValidateLang = array('name' => 'isGenericName');
+ protected $fieldsRequired = array('id_zone', 'id_currency', 'iso_code', 'contains_states', 'need_identification_number', 'display_tax_label');
+ protected $fieldsSize = array('iso_code' => 3);
+ protected $fieldsValidate = array(
+ 'id_zone' => 'isUnsignedId',
+ 'id_currency' => 'isUnsignedId',
+ 'call_prefix' => 'isInt',
+ 'iso_code' => 'isLanguageIsoCode',
+ 'active' => 'isBool',
+ 'contains_states' => 'isBool',
+ 'need_identification_number' => 'isBool',
+ 'need_zip_code' => 'isBool',
+ 'zip_code_format' => 'isZipCodeFormat',
+ 'display_tax_label' => 'isBool'
+ );
- protected $webserviceParameters = array(
+ protected $fieldsRequiredLang = array('name');
+ protected $fieldsSizeLang = array('name' => 64);
+ protected $fieldsValidateLang = array('name' => 'isGenericName');
+
+ protected $webserviceParameters = array(
'objectsNodeName' => 'countries',
'fields' => array(
'id_zone' => array('sqlId' => 'id_zone', 'xlink_resource'=> 'zones'),
@@ -81,20 +93,20 @@ class CountryCore extends ObjectModel
),
);
- protected $table = 'country';
- protected $identifier = 'id_country';
+ protected $table = 'country';
+ protected $identifier = 'id_country';
public function getFields()
{
$this->validateFields();
- $fields['id_zone'] = (int)($this->id_zone);
- $fields['id_currency'] = (int)($this->id_currency);
+ $fields['id_zone'] = (int)$this->id_zone;
+ $fields['id_currency'] = (int)$this->id_currency;
$fields['iso_code'] = pSQL(strtoupper($this->iso_code));
- $fields['call_prefix'] = (int)($this->call_prefix);
- $fields['active'] = (int)($this->active);
- $fields['contains_states'] = (int)($this->contains_states);
- $fields['need_identification_number'] = (int)($this->need_identification_number);
- $fields['need_zip_code'] = (int)($this->need_zip_code);
+ $fields['call_prefix'] = (int)$this->call_prefix;
+ $fields['active'] = (int)$this->active;
+ $fields['contains_states'] = (int)$this->contains_states;
+ $fields['need_identification_number'] = (int)$this->need_identification_number;
+ $fields['need_zip_code'] = (int)$this->need_zip_code;
$fields['zip_code_format'] = $this->zip_code_format;
$fields['display_tax_label'] = $this->display_tax_label;
return $fields;
@@ -118,14 +130,14 @@ class CountryCore extends ObjectModel
* @param boolean $active return only active coutries
* @return array Countries and corresponding zones
*/
- static public function getCountries($id_lang, $active = false, $containStates = NULL, Shop $shop = null)
+ public static function getCountries($id_lang, $active = false, $contain_states = null, Shop $shop = null)
{
if (!Validate::isBool($active))
die(Tools::displayError());
if (!$shop)
$shop = Context::getContext()->shop;
-
+
$states = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT s.*
FROM `'._DB_PREFIX_.'state` s
@@ -138,13 +150,13 @@ class CountryCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'zone` z ON z.`id_zone` = c.`id_zone`
WHERE 1'
.($active ? ' AND c.active = 1' : '')
- .(!is_null($containStates) ? ' AND c.`contains_states` = '.(int)($containStates) : '').'
+ .(!is_null($contain_states) ? ' AND c.`contains_states` = '.(int)$contain_states : '').'
ORDER BY cl.name ASC';
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
$countries = array();
- foreach ($result AS &$country)
+ foreach ($result as &$country)
$countries[$country['id_country']] = $country;
- foreach ($states AS &$state)
+ foreach ($states as &$state)
if (isset($countries[$state['id_country']])) /* Does not keep the state if its country has been disabled and not selected */
$countries[$state['id_country']]['states'][] = $state;
@@ -180,7 +192,7 @@ class CountryCore extends ObjectModel
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT `id_zone`
FROM `'._DB_PREFIX_.'country`
- WHERE `id_country` = '.(int)($id_country));
+ WHERE `id_country` = '.(int)$id_country);
self::$_idZones[$id_country] = $result['id_zone'];
return $result['id_zone'];
@@ -196,10 +208,11 @@ class CountryCore extends ObjectModel
public static function getNameById($id_lang, $id_country)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT `name`
- FROM `'._DB_PREFIX_.'country_lang`
- WHERE `id_lang` = '.(int)($id_lang).'
- AND `id_country` = '.(int)($id_country));
+ SELECT `name`
+ FROM `'._DB_PREFIX_.'country_lang`
+ WHERE `id_lang` = '.(int)$id_lang.'
+ AND `id_country` = '.(int)$id_country
+ );
return $result['name'];
}
@@ -213,9 +226,10 @@ class CountryCore extends ObjectModel
public static function getIsoById($id_country)
{
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
- SELECT `iso_code`
- FROM `'._DB_PREFIX_.'country`
- WHERE `id_country` = '.(int)($id_country));
+ SELECT `iso_code`
+ FROM `'._DB_PREFIX_.'country`
+ WHERE `id_country` = '.(int)$id_country
+ );
return $result['iso_code'];
}
@@ -227,45 +241,40 @@ class CountryCore extends ObjectModel
* @param string $country Country Name
* @return intval Country id
*/
- public static function getIdByName($id_lang = NULL, $country)
+ public static function getIdByName($id_lang = null, $country)
{
$sql = '
SELECT `id_country`
FROM `'._DB_PREFIX_.'country_lang`
WHERE `name` LIKE \''.pSQL($country).'\'';
if ($id_lang)
- $sql .= ' AND `id_lang` = '.(int)($id_lang);
+ $sql .= ' AND `id_lang` = '.(int)$id_lang;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
- return ((int)($result['id_country']));
+ return (int)$result['id_country'];
}
public static function getNeedZipCode($id_country)
{
- if (!(int)($id_country))
+ if (!(int)$id_country)
return false;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `need_zip_code`
FROM `'._DB_PREFIX_.'country`
- WHERE `id_country` = '.(int)($id_country));
+ WHERE `id_country` = '.(int)$id_country);
}
public static function getZipCodeFormat($id_country)
{
- if (!(int)($id_country))
+ if (!(int)$id_country)
return false;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `zip_code_format`
FROM `'._DB_PREFIX_.'country`
- WHERE `id_country` = '.(int)($id_country));
- }
-
- public static function displayCallPrefix($prefix)
- {
- return ((int)($prefix) ? '+'.$prefix : '-');
+ WHERE `id_country` = '.(int)$id_country);
}
/**
@@ -282,12 +291,12 @@ class CountryCore extends ObjectModel
public static function getCountriesByZoneId($id_zone, $id_lang, Shop $shop = null)
{
- if (empty($id_zone) OR empty($id_lang))
+ if (empty($id_zone) || empty($id_lang))
die(Tools::displayError());
-
+
if (!$shop)
$shop = Context::getContext()->shop;
-
+
$sql = ' SELECT DISTINCT c.*, cl.*
FROM `'._DB_PREFIX_.'country` c
'.$shop->addSqlAssociation('country', 'c', false).'
diff --git a/controllers/admin/AdminCountriesController.php b/controllers/admin/AdminCountriesController.php
new file mode 100644
index 000000000..9b5405aed
--- /dev/null
+++ b/controllers/admin/AdminCountriesController.php
@@ -0,0 +1,443 @@
+
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 8971 $
+* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*/
+
+class AdminCountriesControllerCore extends AdminController
+{
+ public function __construct()
+ {
+ $this->table = 'country';
+ $this->className = 'Country';
+ $this->lang = true;
+ $this->deleted = false;
+
+ $this->addRowAction('edit');
+ $this->addRowAction('delete');
+
+ $this->requiredDatabase = true;
+
+ $this->context = Context::getContext();
+
+ $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
+
+ $this->fieldImageSettings = array(
+ 'name' => 'logo',
+ 'dir' => 'st'
+ );
+
+ parent::__construct();
+ }
+
+ public function initList()
+ {
+ $this->_select = 'z.`name` AS zone';
+ $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)';
+
+ $this->fieldsDisplay = array(
+ 'id_country' => array(
+ 'title' => $this->l('ID'),
+ 'align' => 'center',
+ 'width' => 25
+ ),
+ 'name' => array(
+ 'title' => $this->l('Country'),
+ 'width' => 130,
+ 'filter_key' => 'b!name'
+ ),
+ 'iso_code' => array(
+ 'title' => $this->l('ISO code'),
+ 'width' => 70,
+ 'align' => 'center'
+ ),
+ 'call_prefix' => array(
+ 'title' => $this->l('Call prefix'),
+ 'width' => 40,
+ 'align' => 'center',
+ 'callback' => 'displayCallPrefix'
+ ),
+ 'zone' => array(
+ 'title' => $this->l('Zone'),
+ 'width' => 100,
+ 'filter_key' => 'z!name'
+ ),
+ 'active' => array(
+ 'title' => $this->l('Enabled'),
+ 'align' => 'center',
+ 'active' => 'status',
+ 'type' => 'bool',
+ 'orderby' => false,
+ 'filter_key' => 'a!active'
+ )
+ );
+ }
+
+ public function initOptions()
+ {
+ $this->options = array(
+ 'general' => array(
+ 'title' => $this->l('Countries options'),
+ 'fields' => array(
+ 'PS_COUNTRY_DEFAULT' => array(
+ 'title' => $this->l('Default country:'),
+ 'desc' => $this->l('The default country used in shop'),
+ 'cast' => 'intval',
+ 'type' => 'select',
+ 'identifier' => 'id_country',
+ 'list' => Country::getCountries(Context::getContext()->language->id)
+ ),
+ 'PS_RESTRICT_DELIVERED_COUNTRIES' => array(
+ 'title' => $this->l('Restrict countries in FO by those delivered by active carriers'),
+ 'cast' => 'intval',
+ 'type' => 'bool',
+ 'default' => '0'
+ )
+ ),
+ 'submit' => array()
+ )
+ );
+ }
+
+ public function initForm()
+ {
+ if (!($obj = $this->loadObject(true)))
+ return;
+
+ $address_layout = AddressFormat::getAddressCountryFormat($obj->id);
+ if ($value = Tools::getValue('address_layout'))
+ $address_layout = $value;
+
+ $default_layout = '';
+
+ $default_layout_tab = array(
+ array('firstname', 'lastname'),
+ array('company'),
+ array('vat_number'),
+ array('address1'),
+ array('address2'),
+ array('postcode', 'city'),
+ array('Country:name'),
+ array('phone'));
+
+ foreach ($default_layout_tab as $line)
+ $default_layout .= implode(' ', $line)."\r\n";
+
+ $this->fields_form = array(
+ 'legend' => array(
+ 'title' => $this->l('Countries'),
+ 'image' => '../img/admin/world.gif'
+ ),
+ 'input' => array(
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('Country:'),
+ 'name' => 'name',
+ 'lang' => true,
+ 'attributeLang' => 'name',
+ 'size' => 30,
+ 'required' => true,
+ 'hint' => $this->l('Invalid characters:').' <>;=#{}',
+ 'p' => $this->l('Name of country')
+ ),
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('ISO code:'),
+ 'name' => 'iso_code',
+ 'size' => 4,
+ 'maxlength' => 3,
+ 'class' => 'uppercase',
+ 'required' => true,
+ 'p' => $this->l('2- or 3-letter ISO code, e.g., FR for France').'.
+ '.
+ $this->l('Official list here').'
+ .'
+ ),
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('Call prefix:'),
+ 'name' => 'call_prefix',
+ 'size' => 4,
+ 'maxlength' => 3,
+ 'class' => 'uppercase',
+ 'required' => true,
+ 'p' => $this->l('International call prefix, e.g., 33 for France.')
+ ),
+ array(
+ 'type' => 'select',
+ 'label' => $this->l('Default currency:'),
+ 'name' => 'id_currency',
+ 'options' => array(
+ 'query' => Currency::getCurrencies(),
+ 'id' => 'id_currency',
+ 'name' => 'name',
+ 'default' => array(
+ 'label' => $this->l('Default store currency'),
+ 'value' => 0
+ )
+ )
+ ),
+ array(
+ 'type' => 'select',
+ 'label' => $this->l('Zone:'),
+ 'name' => 'id_zone',
+ 'options' => array(
+ 'query' => Zone::getZones(),
+ 'id' => 'id_zone',
+ 'name' => 'name'
+ ),
+ 'p' => $this->l('Geographical zone where country is located')
+ ),
+ array(
+ 'type' => 'radio',
+ 'label' => $this->l('Need zip code:'),
+ 'name' => 'need_zip_code',
+ 'required' => false,
+ 'class' => 't',
+ 'is_bool' => true,
+ 'values' => array(
+ array(
+ 'id' => 'need_zip_code_on',
+ 'value' => 1,
+ 'label' => $this->l('Yes')
+ ),
+ array(
+ 'id' => 'need_zip_code_off',
+ 'value' => 0,
+ 'label' => $this->l('No')
+ )
+ )
+ ),
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('Zip code format:'),
+ 'name' => 'zip_code_format',
+ 'class' => 'uppercase',
+ 'required' => true,
+ 'p' => $this->l('National zip code (L for a letter, N for a number and C for the Iso code), e.g., NNNNN for France.
+ No verification if undefined')
+ ),
+ array(
+ 'type' => 'address_layout',
+ 'label' => $this->l('Address layout:'),
+ 'name' => 'address_layout',
+ 'address_layout' => $address_layout,
+ 'encoding_address_layout' => urlencode($address_layout),
+ 'encoding_default_layout' => urlencode($default_layout),
+ 'display_valid_fields' => $this->displayValidFields()
+ ),
+ array(
+ 'type' => 'radio',
+ 'label' => $this->l('Status:'),
+ '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')
+ )
+ ),
+ 'p' => $this->l('Display or not this store')
+ ),
+ array(
+ 'type' => 'radio',
+ 'label' => $this->l('Contains states:'),
+ 'name' => 'contains_states',
+ 'required' => false,
+ 'class' => 't',
+ 'values' => array(
+ array(
+ 'id' => 'contains_states_on',
+ 'value' => 1,
+ 'label' => ' '.$this->l('Yes')
+ ),
+ array(
+ 'id' => 'contains_states_off',
+ 'value' => 0,
+ 'label' => ' '.$this->l('No')
+ )
+ )
+ ),
+ array(
+ 'type' => 'radio',
+ 'label' => $this->l('Need tax identification number?'),
+ 'name' => 'need_identification_number',
+ 'required' => false,
+ 'class' => 't',
+ 'values' => array(
+ array(
+ 'id' => 'need_identification_number_on',
+ 'value' => 1,
+ 'label' => ' '.$this->l('Yes')
+ ),
+ array(
+ 'id' => 'need_identification_number_off',
+ 'value' => 0,
+ 'label' => ' '.$this->l('No')
+ )
+ )
+ ),
+ array(
+ 'type' => 'radio',
+ 'label' => $this->l('Display tax label:'),
+ 'name' => 'display_tax_label',
+ 'required' => false,
+ 'class' => 't',
+ 'values' => array(
+ array(
+ 'id' => 'display_tax_label_on',
+ 'value' => 1,
+ 'label' => ' '.$this->l('Yes')
+ ),
+ array(
+ 'id' => 'display_tax_label_off',
+ 'value' => 0,
+ 'label' => ' '.$this->l('No')
+ )
+ )
+ )
+ )
+ );
+
+ if (Shop::isFeatureActive())
+ {
+ $this->fields_form['input'][] = array(
+ 'type' => 'shop',
+ 'label' => $this->l('Shop association:'),
+ 'name' => 'checkBoxShopAsso',
+ 'values' => Shop::getTree()
+ );
+
+ //Added values of object Shop
+ if ($obj->id)
+ {
+ $assos = array();
+ $sql = 'SELECT `id_shop`, `'.pSQL($this->identifier).'`
+ FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`
+ WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
+ foreach (Db::getInstance()->executeS($sql) as $row)
+ $this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
+ }
+ }
+
+ $this->fields_form['submit'] = array(
+ 'title' => $this->l(' Save '),
+ 'class' => 'button'
+ );
+ }
+
+ public function postProcess()
+ {
+ if (isset($_GET['delete'.$this->table]) || Tools::getValue('submitDel'.$this->table))
+ $this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.');
+ else
+ {
+ if (Tools::getValue('submitAdd'.$this->table))
+ {
+ $id_country = Tools::getValue('id_country');
+ $tmp_addr_format = new AddressFormat($id_country);
+
+ $save_status = false;
+
+ $is_new = is_null($tmp_addr_format->id_country);
+ if ($is_new)
+ {
+ $tmp_addr_format = new AddressFormat();
+ $tmp_addr_format->id_country = $id_country;
+ }
+
+ $object = new $this->className();
+ $this->updateAssoShop($object->id);
+
+ $tmp_addr_format->format = Tools::getValue('address_layout');
+
+ if (strlen($tmp_addr_format->format) > 0)
+ {
+ if ($tmp_addr_format->checkFormatFields())
+ $save_status = ($is_new) ? $tmp_addr_format->save(): $tmp_addr_format->update();
+ else
+ {
+ $error_list = $tmp_addr_format->getErrorList();
+ foreach ($error_list as $num_error => $error)
+ $this->_errors[] = $error;
+ }
+
+ if (!$save_status)
+ $this->_errors[] = Tools::displayError('Invalid address layout'.Db::getInstance()->getMsgError());
+ }
+ unset($tmp_addr_format);
+ }
+
+ return parent::postProcess();
+ }
+ }
+
+ public function initContent()
+ {
+ if ($this->display != 'edit' && $this->display != 'add')
+ $this->display = 'list';
+
+ parent::initContent();
+ }
+
+ private function displayValidFields()
+ {
+ $html = '';
+ }
+
+ public static function displayCallPrefix($prefix)
+ {
+ return ((int)$prefix ? '+'.$prefix : '-');
+ }
+}
+
+