* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class AdminCounty extends AdminTab { public function __construct() { global $cookie; $this->table = 'county'; $this->className = 'County'; $this->edit = true; $this->delete = true; $this->_select = 's.`name` AS state'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'state` s ON (s.`id_state` = a.`id_state`)'; $this->fieldsDisplay = array( 'id_county' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('County'), 'width' => 130, 'filter_key' => 'b!name'), 'state' => array('title' => $this->l('State'), 'width' => 70, 'filter_key' => 's!name'), 'a!active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active')); parent::__construct(); } public function renderJS() { return ''; } public function displayForm($isMainTab = true) { global $currentIndex, $cookie; parent::displayForm(); if (!($obj = $this->loadObject(true))) return; $cur_id_country = 0; $cur_id_state = 0; if (isset($obj->id_state)) { $cur_state = new State($obj->id_state); if (Validate::isLoadedObject($cur_state)) { $cur_id_country = $cur_state->id_country; $cur_id_state = $cur_state->id; } } echo $this->renderJS(). '
'.($obj->id ? '' : '').'
'.$this->l('Counties').''; if (!isset($obj->id)) echo '
'.$this->l('Save this county then you will be able to associate zipcodes').'

'; $countries = Country::getCountries($cookie->id_lang, true, true); echo '
'; echo '
'; echo '
*
id OR $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '').'/> getFieldValue($obj, 'active') AND $obj->id) ? 'checked="checked" ' : '').'/>

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

 
'; echo '
* '.$this->l('Required field').'
'; if (isset($obj->id)) { echo '
'.$this->_renderZipCodeForm().'
'.AdminCounty::renderZipCodeList($obj->getZipCodes()).'
'; } echo '
'; } protected function _renderZipCodeForm() { return '
Add Zip Codes:
Add
'; } public static function renderZipCodeList($zip_codes) { $html = ''; foreach ($zip_codes AS $zip_code) { $full_zip_code = $zip_code['from_zip_code']; if ($zip_code['to_zip_code'] != 0) $full_zip_code .= '-'.$zip_code['to_zip_code']; $html .= '
'.Tools::htmlentitiesUTF8($full_zip_code).'
'; } return $html; } }