diff --git a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl index 21f0a162e..afedb3edd 100644 --- a/admin/themes/default/template/controllers/customers/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/customers/helpers/view/view.tpl @@ -75,7 +75,7 @@
-

{if $nationality}{$nationality}{else}{l s='Unknown'}{/if}

+

{if $nationality}{$nationality}{else}--{/if}

diff --git a/classes/Customer.php b/classes/Customer.php index d397b5972..f67ad0c57 100644 --- a/classes/Customer.php +++ b/classes/Customer.php @@ -173,7 +173,7 @@ class CustomerCore extends ObjectModel 'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 60), 'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false), 'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), - 'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false), + 'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'copy_post' => false), 'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'), 'newsletter' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'newsletter_date_add' => array('type' => self::TYPE_DATE,'copy_post' => false), @@ -838,6 +838,16 @@ class CustomerCore extends ObjectModel return (int) Configuration::get('PS_COUNTRY_DEFAULT'); } + public static function getNationalities($id_lang) + { + $nationalities = Country::getCountries((int) $id_lang); + $nationalities[-1] = array( + 'id_country' => -1, + 'name' => Translate::getAdminTranslation('Other', 'AdminCustomersController'), + ); + + return $nationalities; + } public function toggleStatus() { diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php index 66f695ed1..b2589f681 100644 --- a/controllers/admin/AdminCustomersController.php +++ b/controllers/admin/AdminCustomersController.php @@ -88,6 +88,7 @@ class AdminCustomersControllerCore extends AdminController foreach ($nationalities_result as $row) { $selected_nationalities[$row['id_country']] = $row['name']; } + $selected_nationalities[-1] = $this->l('Other'); $selected_countries = array(); $countries_result = Db::getInstance()->executeS(' @@ -337,7 +338,8 @@ class AdminCustomersControllerCore extends AdminController ad.company as address_company, ad.vat_number, ad.address1, ad.address2, ad.city, adstate.name as state, ad.postcode, adcountry.name as country, ad.phone as address_phone, - ad.phone_mobile, ad.dni, natcountry.name as nationality'; + ad.phone_mobile, ad.dni, + (CASE WHEN a.id_country = -1 THEN \''.pSQL($this->l('Other')).'\' ELSE natcountry.name END) as nationality'; // Check if we can add a customer if (Shop::isFeatureActive() && (Shop::getContext() == Shop::CONTEXT_ALL || Shop::getContext() == Shop::CONTEXT_GROUP)) { @@ -630,7 +632,7 @@ class AdminCustomersControllerCore extends AdminController 'required' => (bool)(Configuration::get('PS_CUSTOMER_NATIONALITY') && Configuration::get('PS_CUSTOMER_NATIONALITY_MANDATORY')), 'col' => '4', 'options' => array( - 'query' => Country::getCountries($this->context->language->id), + 'query' => Customer::getNationalities($this->context->language->id), 'id' => 'id_country', 'name' => 'name', 'default' => array( @@ -997,7 +999,9 @@ class AdminCustomersControllerCore extends AdminController $gender_image = $gender->getImage(); $nationality = ''; - if ($customer->id_country) { + if ($customer->id_country == -1) { + $nationality = Translate::getAdminTranslation('Other', 'AdminCustomersController'); + } elseif ($customer->id_country) { $nationalityCountry = new Country($customer->id_country, $this->context->language->id); if (Validate::isLoadedObject($nationalityCountry)) { $nationality = $nationalityCountry->name; diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index c92a6d12f..41258d478 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -108,7 +108,7 @@ class AuthControllerCore extends FrontController $this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE')); $this->context->smarty->assign('nationality', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY')); $this->context->smarty->assign('nationality_mandatory', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY_MANDATORY')); - $this->context->smarty->assign('nationality_countries', Country::getCountries($this->context->language->id)); + $this->context->smarty->assign('nationality_countries', Customer::getNationalities($this->context->language->id)); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); diff --git a/controllers/front/IdentityController.php b/controllers/front/IdentityController.php index 90de6f31d..0e29de05a 100644 --- a/controllers/front/IdentityController.php +++ b/controllers/front/IdentityController.php @@ -175,7 +175,7 @@ class IdentityControllerCore extends FrontController $this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE')); $this->context->smarty->assign('nationality', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY')); $this->context->smarty->assign('nationality_mandatory', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY_MANDATORY')); - $this->context->smarty->assign('nationality_countries', Country::getCountries($this->context->language->id)); + $this->context->smarty->assign('nationality_countries', Customer::getNationalities($this->context->language->id)); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index 26132c846..782253ab5 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -562,7 +562,7 @@ class OrderOpcControllerCore extends ParentOrderController $this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE')); $this->context->smarty->assign('nationality', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY')); $this->context->smarty->assign('nationality_mandatory', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY_MANDATORY')); - $this->context->smarty->assign('nationality_countries', Country::getCountries($this->context->language->id)); + $this->context->smarty->assign('nationality_countries', Customer::getNationalities($this->context->language->id)); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); $this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase()); diff --git a/install/data/db_structure.sql b/install/data/db_structure.sql index ce4b9b2e8..c9d8c7bb8 100644 --- a/install/data/db_structure.sql +++ b/install/data/db_structure.sql @@ -587,7 +587,7 @@ CREATE TABLE `PREFIX_customer` ( `id_gender` int(10) unsigned NOT NULL, `id_default_group` int(10) unsigned NOT NULL DEFAULT '1', `id_lang` int(10) unsigned NULL, - `id_country` int(10) unsigned NOT NULL DEFAULT '0', + `id_country` int(10) NOT NULL DEFAULT '0', `id_risk` int(10) unsigned NOT NULL DEFAULT '1', `company` varchar(64), `siret` varchar(14), diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index da4f48339..e6fb3f0c0 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -912,7 +912,7 @@ 1 - 1 + 0 0