* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7111 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include_once(PS_ADMIN_DIR.'/../classes/AdminTab.php'); class AdminCountries extends AdminTab { public function __construct() { global $cookie; $this->table = 'country'; $this->className = 'Country'; $this->lang = true; $this->edit = true; $this->deleted = false; $this->_select = 'z.`name` AS zone'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = a.`id_zone`)'; $this->fieldsDisplay = array( 'id_country' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Country'), 'width' => 130, 'filter_key' => 'b!name'), 'iso_code' => array('title' => $this->l('ISO code'), 'width' => 70, 'align' => 'center'), 'call_prefix' => array('title' => $this->l('Call prefix'), 'width' => 40, 'align' => 'center', 'callback' => 'displayCallPrefix'), 'zone' => array('title' => $this->l('Zone'), 'width' => 100, 'filter_key' => 'z!name'), 'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active')); $this->optionTitle = $this->l('Countries options'); $this->_fieldsOptions = array('PS_COUNTRY_DEFAULT' => array('title' => $this->l('Default country:'), 'desc' => $this->l('The default country used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_country', 'list' => Country::getCountries((int)($cookie->id_lang)))); parent::__construct(); } public function postProcess() { if (isset($_GET['delete'.$this->table]) OR Tools::getValue('submitDel'.$this->table)) $this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.'); else { if (Tools::getValue('submitAdd'.$this->table)) { $id_country = Tools::getValue('id_country'); $tmp_addr_format = new AddressFormat($id_country); $save_status = false; $is_new = is_null($tmp_addr_format->id_country); if ($is_new) { $tmp_addr_format = new AddressFormat(); $tmp_addr_format->id_country = $id_country; } $tmp_addr_format->format = Tools::getValue('address_layout'); if (strlen($tmp_addr_format->format) > 0) { if ($tmp_addr_format->checkFormatFields()) $save_status = ($is_new) ? $tmp_addr_format->save(): $tmp_addr_format->update(); else { $errorList = $tmp_addr_format->getErrorList(); foreach($errorList as $numError => $error) $this->_errors[] = $error; } if (!$save_status) $this->_errors[] = Tools::displayError('Invalid address layout'.Db::getInstance()->getMsgError()); } unset($tmp_addr_format); } return parent::postProcess(); } } private function _displayValidFields() { $html = ''; } public function displayForm($isMainTab = true) { global $currentIndex, $cookie; parent::displayForm(); $defaultLayout = ''; $defaultLayoutTab = array( array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone')); if (!($obj = $this->loadObject(true))) return; foreach ($defaultLayoutTab as $line) $defaultLayout .= implode(' ', $line)."\r\n"; echo '
'.($obj->id ? '' : '').'
'.$this->l('Countries').'
'; foreach ($this->_languages as $language) echo '
* '.$this->l('Invalid characters:').' <>;=#{} 
'; $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name'); echo '

'.$this->l('Name of country').'

*

'.$this->l('2- or 3-letter ISO code, e.g., FR for France').'. '.$this->l('Official list here').'.

*

'.$this->l('International call prefix, e.g., 33 for France.').'.

'.$this->l('Geographical zone where country is located').'

id OR $this->getFieldValue($obj, 'need_zip_code')) ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'need_zip_code') AND $obj->id) ? 'checked="checked" ' : '').'/>
*

'.$this->l('National zip code (L for a letter, N for a number and C for the Iso code), e.g., NNNNN for France. No verification if undefined').'.

'.$this->l('Liable fields for the address information (click to have more details)').': '.$this->_displayValidFields().'
'. $this->l('Use the last registered layout').' '. $this->l('Use a default layout').' '. $this->l('Use my current modified layout').' '. $this->l('Clean layout').'
id OR $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'active') AND $obj->id) ? 'checked="checked" ' : '').'/>

'.$this->l('Enabled or disabled').'

id OR $this->getFieldValue($obj, 'contains_states')) ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'contains_states') AND $obj->id) ? 'checked="checked" ' : '').'/>
id OR $this->getFieldValue($obj, 'need_identification_number')) ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'need_identification_number') AND $obj->id) ? 'checked="checked" ' : '').'/>
id OR $this->getFieldValue($obj, 'display_tax_label')) ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'display_tax_label') AND $obj->id) ? 'checked="checked" ' : '').'/>
* '.$this->l('Required field').'
'; } }