From ea5405a917ee8f64f433ec2c72545c5ac419c3b3 Mon Sep 17 00:00:00 2001 From: gRoussac Date: Mon, 27 May 2013 19:06:59 +0200 Subject: [PATCH] [-] CORE : Report of https://github.com/PrestaShop/PrestaShop-1.4/commit/ec8deb289185daa03cd11d239797bbe5bdbaecd0 --- .../countries/helpers/form/form.tpl | 21 ++++++++++++- .../admin/AdminCountriesController.php | 31 +++++++++++++++++-- controllers/front/AddressController.php | 2 +- controllers/front/AuthController.php | 4 +++ js/admin.js | 8 +++++ 5 files changed, 62 insertions(+), 4 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/countries/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/countries/helpers/form/form.tpl index 14ecde6ad..88f0278cf 100644 --- a/admin-dev/themes/default/template/controllers/countries/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/countries/helpers/form/form.tpl @@ -48,6 +48,21 @@ {else} {$smarty.block.parent} + {/if} +{/block} +{block name="label"} + {if $input.name == 'standardization'} + + {else} + {$smarty.block.parent} {/if} {/block} @@ -85,7 +100,11 @@ $('#need_zip_code_on, #need_zip_code_off').change(function() { disableZipFormat(); }); - + + $('#iso_code').change(function() { + disableTAASC(); + }); + disableTAASC(); }); function switchExplanationText(text) { diff --git a/controllers/admin/AdminCountriesController.php b/controllers/admin/AdminCountriesController.php index 5a80556cd..2eb4e31a2 100644 --- a/controllers/admin/AdminCountriesController.php +++ b/controllers/admin/AdminCountriesController.php @@ -251,6 +251,26 @@ class AdminCountriesControllerCore extends AdminController 'encoding_default_layout' => urlencode($default_layout), 'display_valid_fields' => $this->displayValidFields() ), + array( + 'type' => 'radio', + 'label' => $this->l('Address Standardization:'), + 'name' => 'standardization', + 'required' => false, + 'class' => 't', + 'is_bool' => true, + 'values' => array( + array( + 'id' => 'standardization_on', + 'value' => 1, + 'label' => $this->l('Enabled') + ), + array( + 'id' => 'standardization_off', + 'value' => 0, + 'label' => $this->l('Disabled') + ) + ), + ), array( 'type' => 'radio', 'label' => $this->l('Active:'), @@ -271,7 +291,7 @@ class AdminCountriesControllerCore extends AdminController ) ), 'desc' => $this->l('Display this country to your customers (the selected country will always be displayed in the Back Office)') - ), + ), array( 'type' => 'radio', 'label' => $this->l('Contains following states:'), @@ -330,6 +350,7 @@ class AdminCountriesControllerCore extends AdminController ) ) ) + ); if (Shop::isFeatureActive()) @@ -345,7 +366,10 @@ class AdminCountriesControllerCore extends AdminController 'title' => $this->l('Save '), 'class' => 'button' ); - + + if ($this->object->iso_code == 'US') + $this->object->standardization = Configuration::get('PS_TAASC'); + return parent::renderForm(); } @@ -362,6 +386,9 @@ class AdminCountriesControllerCore extends AdminController if (!is_null($id_country) && $id_country != Tools::getValue('id_'.$this->table)) $this->errors[] = Tools::displayError('This ISO code already exists.You cannot create two countries with the same ISO code.'); } + + if (Tools::isSubmit('standardization')) + Configuration::updateValue('PS_TAASC', (bool)Tools::getValue('standardization', false)); if (!count($this->errors)) $res = parent::postProcess(); diff --git a/controllers/front/AddressController.php b/controllers/front/AddressController.php index 0d5a399c3..699a37287 100644 --- a/controllers/front/AddressController.php +++ b/controllers/front/AddressController.php @@ -138,7 +138,7 @@ class AddressControllerCore extends FrontController $this->errors[] = Tools::displayError('This country requires you to chose a State.'); // US customer: normalize the address - if ($address->id_country == Country::getByIso('US')) + if ($address->id_country == Country::getByIso('US') && Configuration::get('PS_TAASC')) { include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php'); $normalize = new AddressStandardizationSolution; diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 935fe05e3..3c2a2b4e4 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -489,7 +489,11 @@ class AuthControllerCore extends FrontController $this->errors = array_unique(array_merge($this->errors, $address->validateController())); // US customer: normalize the address +<<<<<<< HEAD + if ($address->id_country == Country::getByIso('US') && Configuration::get('PS_TAASC')) +======= if ($address->id_country == Country::getByIso('US')) +>>>>>>> a04e6b1a67fc34bd1049e546283cb5a938fd2279 { include_once(_PS_TAASC_PATH_.'AddressStandardizationSolution.php'); $normalize = new AddressStandardizationSolution; diff --git a/js/admin.js b/js/admin.js index 3172cadda..bf67a53f9 100644 --- a/js/admin.js +++ b/js/admin.js @@ -577,6 +577,14 @@ function disableZipFormat() $('.zip_code_format').show(); } +function disableTAASC() +{ + if ($('#iso_code').val() == 'US') + $('#TAASC').show(); + else + $('#TAASC').hide(); +} + function spreadFees(id_range) { newVal = $('#fees_all_'+id_range).val().replace(/,/g, '.');