[*] BO : reorganization of admin tabs
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13820 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -112,6 +112,8 @@ class AdminStoresControllerCore extends AdminController
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->_buildOrderedFieldsShop($this->_getDefaultFieldsContent());
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
@@ -386,6 +388,168 @@ class AdminStoresControllerCore extends AdminController
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
protected function _getDefaultFieldsContent()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
$countryList = array();
|
||||
$countryList[] = array('id' => '0', 'name' => $this->l('Choose your country'));
|
||||
foreach (Country::getCountries($this->context->language->id) as $country)
|
||||
$countryList[] = array('id' => $country['id_country'], 'name' => $country['name']);
|
||||
$stateList = array();
|
||||
$stateList[] = array('id' => '0', 'name' => $this->l('Choose your state (if applicable)'));
|
||||
foreach (State::getStates($this->context->language->id) as $state)
|
||||
$stateList[] = array('id' => $state['id_state'], 'name' => $state['name']);
|
||||
|
||||
$formFields = array(
|
||||
'PS_SHOP_NAME' => array(
|
||||
'title' => $this->l('Shop name:'),
|
||||
'desc' => $this->l('Displayed in e-mails and page titles'),
|
||||
'validation' => 'isGenericName',
|
||||
'required' => true,
|
||||
'size' => 30,
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_SHOP_EMAIL' => array('title' => $this->l('Shop e-mail:'),
|
||||
'desc' => $this->l('Displayed in e-mails sent to customers'),
|
||||
'validation' => 'isEmail',
|
||||
'required' => true,
|
||||
'size' => 30,
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_SHOP_DETAILS' => array(
|
||||
'title' => $this->l('Registration:'),
|
||||
'desc' => $this->l('Shop registration information (e.g., SIRET or RCS)'),
|
||||
'validation' => 'isGenericName',
|
||||
'size' => 30,
|
||||
'type' => 'textarea',
|
||||
'cols' => 30,
|
||||
'rows' => 5
|
||||
),
|
||||
'PS_SHOP_ADDR1' => array(
|
||||
'title' => $this->l('Shop address line 1:'),
|
||||
'validation' => 'isAddress',
|
||||
'size' => 30,
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_SHOP_ADDR2' => array(
|
||||
'title' => 'Address line 2',
|
||||
'validation' => 'isAddress',
|
||||
'size' => 30,
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_SHOP_CODE' => array(
|
||||
'title' => $this->l('Post/Zip code:'),
|
||||
'validation' => 'isGenericName',
|
||||
'size' => 6,
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_SHOP_CITY' => array(
|
||||
'title' => $this->l('City:'),
|
||||
'validation' => 'isGenericName',
|
||||
'size' => 30,
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_SHOP_COUNTRY_ID' => array(
|
||||
'title' => $this->l('Country:'),
|
||||
'validation' => 'isInt',
|
||||
'type' => 'select',
|
||||
'list' => $countryList,
|
||||
'identifier' => 'id',
|
||||
'cast' => 'intval',
|
||||
'defaultValue' => (int)$this->context->country->id
|
||||
),
|
||||
'PS_SHOP_STATE_ID' => array(
|
||||
'title' => $this->l('State:'),
|
||||
'validation' => 'isInt',
|
||||
'type' => 'select',
|
||||
'list' => $stateList,
|
||||
'identifier' => 'id',
|
||||
'cast' => 'intval'
|
||||
),
|
||||
'PS_SHOP_PHONE' => array(
|
||||
'title' => $this->l('Phone:'),
|
||||
'validation' => 'isGenericName',
|
||||
'size' => 30,
|
||||
'type' => 'text'
|
||||
),
|
||||
'PS_SHOP_FAX' => array(
|
||||
'title' => $this->l('Fax:'),
|
||||
'validation' => 'isGenericName',
|
||||
'size' => 30,
|
||||
'type' => 'text'
|
||||
),
|
||||
);
|
||||
return $formFields;
|
||||
}
|
||||
|
||||
protected function _buildOrderedFieldsShop($formFields)
|
||||
{
|
||||
$associatedOrderKey = array(
|
||||
'PS_SHOP_NAME' => 'company',
|
||||
'PS_SHOP_ADDR1' => 'address1',
|
||||
'PS_SHOP_ADDR2' => 'address2',
|
||||
'PS_SHOP_CITY' => 'city',
|
||||
'PS_SHOP_STATE_ID' => 'State:name',
|
||||
'PS_SHOP_CODE' => 'postcode',
|
||||
'PS_SHOP_COUNTRY_ID' => 'Country:name',
|
||||
'PS_SHOP_PHONE' => 'phone');
|
||||
|
||||
$fields = array();
|
||||
$orderedFields = AddressFormat::getOrderedAddressFields(Configuration::get('PS_SHOP_COUNTRY_ID'), false, true);
|
||||
|
||||
foreach ($orderedFields as $lineFields)
|
||||
if (($patterns = explode(' ', $lineFields)))
|
||||
foreach ($patterns as $pattern)
|
||||
if (($key = array_search($pattern, $associatedOrderKey)))
|
||||
$fields[$key] = $formFields[$key];
|
||||
foreach ($formFields as $key => $value)
|
||||
if (!isset($fields[$key]))
|
||||
$fields[$key] = $formFields[$key];
|
||||
|
||||
$this->options['contact'] = array(
|
||||
'title' => $this->l('Contact details'),
|
||||
'icon' => 'tab-contact',
|
||||
'fields' => $fields,
|
||||
'submit' => array('title' => $this->l(' Save '), 'class' => 'button')
|
||||
);
|
||||
}
|
||||
|
||||
public function beforeUpdateOptions()
|
||||
{
|
||||
if (isset($_POST['PS_SHOP_STATE_ID']) && $_POST['PS_SHOP_STATE_ID'] != '0')
|
||||
{
|
||||
$sql = 'SELECT `active` FROM `'._DB_PREFIX_.'state`
|
||||
WHERE `id_country` = '.(int)Tools::getValue('PS_SHOP_COUNTRY_ID').'
|
||||
AND `id_state` = '.(int)Tools::getValue('PS_SHOP_STATE_ID');
|
||||
$isStateOk = Db::getInstance()->getValue($sql);
|
||||
if ($isStateOk != 1)
|
||||
$this->errors[] = Tools::displayError('This state is not in this country.');
|
||||
}
|
||||
}
|
||||
|
||||
public function updateOptionPsShopCountryId($value)
|
||||
{
|
||||
if (!$this->errors && $value)
|
||||
{
|
||||
$country = new Country($value, $this->context->language->id);
|
||||
if ($country->id)
|
||||
{
|
||||
Configuration::updateValue('PS_SHOP_COUNTRY_ID', $value);
|
||||
Configuration::updateValue('PS_SHOP_COUNTRY', pSQL($country->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateOptionPsShopStateId($value)
|
||||
{
|
||||
if (!$this->errors && $value)
|
||||
{
|
||||
$state = new State($value);
|
||||
if ($state->id)
|
||||
{
|
||||
Configuration::updateValue('PS_SHOP_STATE_ID', $value);
|
||||
Configuration::updateValue('PS_SHOP_STATE', pSQL($state->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user