[-] BO : you cannot create 2 states with the same iso code in the same country anymore #PSCFV-53

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15054 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dMetzger
2012-05-03 15:11:43 +00:00
parent b44fad77ce
commit 2c81894949
2 changed files with 17 additions and 5 deletions
@@ -181,6 +181,18 @@ class AdminStatesControllerCore extends AdminController
{
if (!isset($this->table))
return false;
if (!Tools::getValue('id_'.$this->table))
{
if (Validate::isStateIsoCode(Tools::getValue('iso_code')) && State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country')))
$this->errors[] = Tools::displayError('This ISO code already exists, you cannot create two states with the same ISO code in the same country');
}
else if (Validate::isStateIsoCode(Tools::getValue('iso_code')))
{
$id_state = State::getIdByIso(Tools::getValue('iso_code'), Tools::getValue('id_country'));
if ($id_state && $id_state != Tools::getValue('id_'.$this->table))
$this->errors[] = Tools::displayError('This ISO code already exists, you cannot create two states with the same ISO code in the same country');
}
/* Delete object */
if (isset($_GET['delete'.$this->table]))