From 0088f5d2453740aef9f6cc84459dfcd94fc26ba8 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Thu, 16 Feb 2012 14:13:04 +0000 Subject: [PATCH] [-] BO : #PSTEST-769 - The default country must be pre-selected on address list --- .../default/template/helpers/form/form.tpl | 32 ++++++++++++++++--- classes/helper/HelperForm.php | 1 + .../admin/AdminAddressesController.php | 3 +- .../admin/AdminManufacturersController.php | 3 +- controllers/admin/AdminStatesController.php | 3 +- controllers/admin/AdminStoresController.php | 3 +- .../admin/AdminSuppliersController.php | 15 +++++---- .../admin/AdminWarehousesController.php | 11 ++----- 8 files changed, 48 insertions(+), 23 deletions(-) diff --git a/admin-dev/themes/default/template/helpers/form/form.tpl b/admin-dev/themes/default/template/helpers/form/form.tpl index 4941dd251..c6087b64f 100644 --- a/admin-dev/themes/default/template/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/helpers/form/form.tpl @@ -171,20 +171,44 @@ {else} diff --git a/classes/helper/HelperForm.php b/classes/helper/HelperForm.php index 95382c79f..fb9d670f7 100644 --- a/classes/helper/HelperForm.php +++ b/classes/helper/HelperForm.php @@ -160,6 +160,7 @@ class HelperFormCore extends Helper 'form_id' => $this->id, 'fields' => $this->fields_form, 'fields_value' => $this->fields_value, + 'default_country' => (int)(Configuration::get('PS_SHOP_COUNTRY_ID') ? Configuration::get('PS_SHOP_COUNTRY_ID') : Configuration::get('PS_COUNTRY_DEFAULT')), 'required_fields' => $this->getFieldsRequired(), 'vat_number' => file_exists(_PS_MODULE_DIR_.'vatnumber/ajax.php'), 'module_dir' => _MODULE_DIR_, diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php index 7e516fccf..ec0852520 100644 --- a/controllers/admin/AdminAddressesController.php +++ b/controllers/admin/AdminAddressesController.php @@ -257,7 +257,8 @@ class AdminAddressesControllerCore extends AdminController 'options' => array( 'query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', - 'name' => 'name' + 'name' => 'name', + 'preselect_country' => true, ) ); $temp_fields[] = array( diff --git a/controllers/admin/AdminManufacturersController.php b/controllers/admin/AdminManufacturersController.php index d80234d0a..565d52927 100644 --- a/controllers/admin/AdminManufacturersController.php +++ b/controllers/admin/AdminManufacturersController.php @@ -460,7 +460,8 @@ class AdminManufacturersControllerCore extends AdminController 'options' => array( 'query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', - 'name' => 'name' + 'name' => 'name', + 'preselect_country' => true, ) ); $form['input'][] = array( diff --git a/controllers/admin/AdminStatesController.php b/controllers/admin/AdminStatesController.php index a39501832..f6ec60d1c 100644 --- a/controllers/admin/AdminStatesController.php +++ b/controllers/admin/AdminStatesController.php @@ -127,7 +127,8 @@ class AdminStatesControllerCore extends AdminController 'options' => array( 'query' => Country::getCountries($this->context->language->id, false, true), 'id' => 'id_country', - 'name' => 'name' + 'name' => 'name', + 'preselect_country' => true, ), 'desc' => $this->l('Country where state, region or city is located') ), diff --git a/controllers/admin/AdminStoresController.php b/controllers/admin/AdminStoresController.php index 7aa441687..923b71bc0 100644 --- a/controllers/admin/AdminStoresController.php +++ b/controllers/admin/AdminStoresController.php @@ -183,7 +183,8 @@ class AdminStoresControllerCore extends AdminController 'options' => array( 'query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', - 'name' => 'name' + 'name' => 'name', + 'preselect_country' => true, ) ), array( diff --git a/controllers/admin/AdminSuppliersController.php b/controllers/admin/AdminSuppliersController.php index 0122902e8..05f67a7cf 100644 --- a/controllers/admin/AdminSuppliersController.php +++ b/controllers/admin/AdminSuppliersController.php @@ -29,19 +29,19 @@ class AdminSuppliersControllerCore extends AdminController { public function __construct() { - $this->table = 'supplier'; - $this->className = 'Supplier'; + $this->table = 'supplier'; + $this->className = 'Supplier'; $this->addRowAction('view'); $this->addRowAction('edit'); $this->addRowAction('delete'); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); $this->_select = 'COUNT(ps.`id_product`) AS products'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_supplier` ps ON (a.`id_supplier` = ps.`id_supplier`)'; $this->_group = 'GROUP BY a.`id_supplier`'; - $this->fieldImageSettings = array('name' => 'logo', 'dir' => 'su'); + $this->fieldImageSettings = array('name' => 'logo', 'dir' => 'su'); $this->fieldsDisplay = array( 'id_supplier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), @@ -141,7 +141,8 @@ class AdminSuppliersControllerCore extends AdminController 'options' => array( 'query' => Country::getCountries($this->context->language->id, false), 'id' => 'id_country', - 'name' => 'name' + 'name' => 'name', + 'preselect_country' => true, ), 'desc' => $this->l('Country where the state, region or city is located') ), @@ -292,8 +293,8 @@ class AdminSuppliersControllerCore extends AdminController else { $product_infos = Supplier::getProductInformationsBySupplier($this->object->id, - $products[$i]->id, - 0); + $products[$i]->id, + 0); $products[$i]->product_supplier_reference = $product_infos['product_supplier_reference']; $products[$i]->product_supplier_price_te = Tools::displayPrice($product_infos['product_supplier_price_te'], new Currency($product_infos['id_currency'])); } diff --git a/controllers/admin/AdminWarehousesController.php b/controllers/admin/AdminWarehousesController.php index 6d8e46544..0d2d077e3 100644 --- a/controllers/admin/AdminWarehousesController.php +++ b/controllers/admin/AdminWarehousesController.php @@ -137,12 +137,6 @@ class AdminWarehousesControllerCore extends AdminController $query->where('active = 1'); $employees_array = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); - // sets countries - $countries = Country::getCountries($this->context->language->id, false); - $id_default_country = Configuration::get('PS_SHOP_COUNTRY_ID'); - if (isset($countries[$id_default_country])) - $countries = array($id_default_country => $countries[$id_default_country]) + $countries; - // sets the title of the toolbar $this->toolbar_title = $this->l('Stock : Warehouse management'); @@ -222,9 +216,10 @@ class AdminWarehousesControllerCore extends AdminController 'name' => 'id_country', 'required' => true, 'options' => array( - 'query' => $countries, + 'query' => Country::getCountries($this->context->language->id, false), 'id' => 'id_country', - 'name' => 'name' + 'name' => 'name', + 'preselect_country' => true, ), 'desc' => $this->l('Country where the state, region or city is located') ),