public function renderForm()
    {
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $address_layout = AddressFormat::getAddressCountryFormat($obj->id);
        if ($value = Tools::getValue('address_layout')) {
            $address_layout = $value;
        }
        $default_layout = '';
        $default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
        foreach ($default_layout_tab as $line) {
            $default_layout .= implode(' ', $line) . "\r\n";
        }
        $this->fields_form = array('legend' => array('title' => $this->l('Countries'), 'image' => '../img/admin/world.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Country:'), 'name' => 'name', 'lang' => true, 'size' => 30, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('Country name')), array('type' => 'text', 'label' => $this->l('ISO code:'), 'name' => 'iso_code', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Two -- or three -- letter ISO code (e.g. U.S. for United States)') . '.
							<a href="http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm" target="_blank">' . $this->l('Official list here') . '
							</a>.'), array('type' => 'text', 'label' => $this->l('Call prefix:'), 'name' => 'call_prefix', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('International call prefix, (e.g. 1 for United States)')), array('type' => 'select', 'label' => $this->l('Default currency:'), 'name' => 'id_currency', 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name', 'default' => array('label' => $this->l('Default store currency'), 'value' => 0))), array('type' => 'select', 'label' => $this->l('Zone:'), 'name' => 'id_zone', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name'), 'desc' => $this->l('Geographical region')), array('type' => 'radio', 'label' => $this->l('Need zip/postal code:'), 'name' => 'need_zip_code', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'need_zip_code_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'need_zip_code_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Zip/post code format:'), 'name' => 'zip_code_format', 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Zip Code format (L for a letter, N for a number and C for the ISO code). For example, NNNNN for the United States. No verification if undefined.')), array('type' => 'address_layout', 'label' => $this->l('Address format:'), 'name' => 'address_layout', 'address_layout' => $address_layout, 'encoding_address_layout' => urlencode($address_layout), '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:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), '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:'), 'name' => 'contains_states', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'contains_states_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'contains_states_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Do you need a tax identification number?'), 'name' => 'need_identification_number', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'need_identification_number_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'need_identification_number_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Display tax label (e.g. "Tax incl."):'), 'name' => 'display_tax_label', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'display_tax_label_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'display_tax_label_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No'))))));
        if (Shop::isFeatureActive()) {
            $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
        }
        $this->fields_form['submit'] = array('title' => $this->l('Save   '), 'class' => 'button');
        if ($this->object->iso_code == 'US') {
            $this->object->standardization = Configuration::get('PS_TAASC');
        }
        return parent::renderForm();
    }
 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $address_layout = AddressFormat::getAddressCountryFormat($obj->id);
     if ($value = Tools::getValue('address_layout')) {
         $address_layout = $value;
     }
     $default_layout = '';
     $default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
     foreach ($default_layout_tab as $line) {
         $default_layout .= implode(' ', $line) . "\r\n";
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Countries'), 'icon' => 'icon-globe'), 'input' => array(array('type' => 'text', 'label' => $this->l('Country'), 'name' => 'name', 'lang' => true, 'required' => true, 'hint' => $this->l('Country name') . ' - ' . $this->l('Invalid characters:') . ' &lt;&gt;;=#{} '), array('type' => 'text', 'label' => $this->l('ISO code'), 'name' => 'iso_code', 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'hint' => $this->l('Two -- or three -- letter ISO code (e.g. "us for United States).')), array('type' => 'text', 'label' => $this->l('Call prefix'), 'name' => 'call_prefix', 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'hint' => $this->l('International call prefix, (e.g. 1 for United States).')), array('type' => 'select', 'label' => $this->l('Default currency'), 'name' => 'id_currency', 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name', 'default' => array('label' => $this->l('Default store currency'), 'value' => 0))), array('type' => 'select', 'label' => $this->l('Zone'), 'name' => 'id_zone', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name'), 'hint' => $this->l('Geographical region.')), array('type' => 'switch', 'label' => $this->l('Does it need Zip/postal code?'), 'name' => 'need_zip_code', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'need_zip_code_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'need_zip_code_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Zip/postal code format'), 'name' => 'zip_code_format', 'required' => true, 'desc' => $this->l('Indicate the format of the postal code: use L for a letter, N for a number, and C for the country\'s ISO 3166-1 alpha-2 code. For example, NNNNN for the United States, France, Poland and many other; LNNNNLLL for Argentina, etc. If you do not want PrestaShop to verify the postal code for this country, leave it blank.')), array('type' => 'address_layout', 'label' => $this->l('Address format'), 'name' => 'address_layout', 'address_layout' => $address_layout, 'encoding_address_layout' => urlencode($address_layout), 'encoding_default_layout' => urlencode($default_layout), 'display_valid_fields' => $this->displayValidFields()), array('type' => 'switch', 'label' => $this->l('Active'), 'name' => 'active', 'required' => false, 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'hint' => $this->l('Display this country to your customers (the selected country will always be displayed in the Back Office).')), array('type' => 'switch', 'label' => $this->l('Contains states'), 'name' => 'contains_states', 'required' => false, 'values' => array(array('id' => 'contains_states_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'contains_states_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'switch', 'label' => $this->l('Do you need a tax identification number?'), 'name' => 'need_identification_number', 'required' => false, 'values' => array(array('id' => 'need_identification_number_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'need_identification_number_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'switch', 'label' => $this->l('Display tax label (e.g. "Tax incl.")'), 'name' => 'display_tax_label', 'required' => false, 'values' => array(array('id' => 'display_tax_label_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'display_tax_label_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No'))))));
     if (Shop::isFeatureActive()) {
         $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso');
     }
     $this->fields_form['submit'] = array('title' => $this->l('Save'));
     return parent::renderForm();
 }
Example #3
0
 /**
  * Returns address format fields in array by country
  *
  * @param Integer PS_COUNTRY.id if null using default country
  * @return Array String field address format
  */
 public static function getOrderedAddressFields($id_country = 0, $split_all = false, $cleaned = false)
 {
     $out = array();
     $field_set = explode("\n", AddressFormat::getAddressCountryFormat($id_country));
     foreach ($field_set as $field_item) {
         if ($split_all) {
             if ($cleaned) {
                 $keyList = $cleaned ? preg_split(self::_CLEANING_REGEX_, $field_item, -1, PREG_SPLIT_NO_EMPTY) : explode(' ', $field_item);
             }
             foreach ($keyList as $word_item) {
                 $out[] = trim($word_item);
             }
         } else {
             $out[] = $cleaned ? implode(' ', preg_split(self::_CLEANING_REGEX_, trim($field_item), -1, PREG_SPLIT_NO_EMPTY)) : trim($field_item);
         }
     }
     return $out;
 }
Example #4
0
    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 '
		<script type="text/javascript" language="javascript" src="' . _PS_JS_DIR_ . 'jquery/jquery-fieldselection.js"></script>
		<script type="text/javascript" language="javascript">
			
			lastLayoutModified = "";
			
			$(document).ready(function()
			{
				$(".availableFieldsList").css("display", "none");
				$(".addPattern").click(function()
				{
					addFieldsToCursorPosition($(this).attr("id"))
					lastLayoutModified = $("#ordered_fields").val();
				});
				$("#ordered_fields").keyup(function()
				{
					lastLayoutModified = $(this).val();
				});
				$("#useLastDefaultLayout").mouseover(function()
				{
					switchExplanationText("' . $this->l('Will display back your last registered layout') . '");
				});
				$("#useDefaultLayoutSystem").mouseover(function()
				{
					switchExplanationText("' . $this->l('Will display a default layout for this country') . '");
				});
				$("#useCurrentLastModifiedLayout").mouseover(function()
				{
					switchExplanationText("' . $this->l('Will display back you\'re current editing layout') . '");
				});
				$("#eraseCurrentLayout").mouseover(function()
				{
					switchExplanationText("' . $this->l('Will delete the current layout') . '");
				});
				
			});
			
			function  switchExplanationText(text)
			{
				$("#explanationText").fadeOut("fast", function()
				{
					$(this).html(text);
					$(this).fadeIn("fast");
				});
			}
			
			function addFieldsToCursorPosition(pattern)
			{
				$("#ordered_fields").replaceSelection(pattern + " ");
			}
			
			function displayAvailableFields(containerName)
			{
				$(".availableFieldsList").each( function (){
					if ($(this).attr(\'id\') != \'availableListFieldsFor_\'+containerName)
						$(this).slideUp();
				});
				$("#availableListFieldsFor_" + containerName).slideToggle();
			}
			
			function resetLayout(defaultLayout, type)
			{
				if (confirm("' . $this->l('Are you sure to apply this selection ?') . '"))
				{
					$("#ordered_fields").val(unescape(defaultLayout.replace(/\\+/g, " ")));
				}
			}
			
		</script>
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/world.gif" />' . $this->l('Countries') . '</legend>
				<label>' . $this->l('Country:') . ' </label>
				<div class="margin-form">';
        foreach ($this->_languages as $language) {
            echo '
					<div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input size="30" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
						<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
					</div>';
        }
        $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
        echo '		<p style="clear: both">' . $this->l('Name of country') . '</p>
				</div>
				<label>' . $this->l('ISO code:') . ' </label>
				<div class="margin-form">
					<input type="text" size="4" maxlength="3" name="iso_code" value="' . htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup>
					<p>' . $this->l('2- or 3-letter ISO code, e.g., FR for France') . '. <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html" target="_blank">' . $this->l('Official list here') . '</a>.</p>
				</div>
				<label>' . $this->l('Call prefix:') . ' </label>
				<div class="margin-form">
					<input type="text" size="4" maxlength="3" name="call_prefix" value="' . (int) $this->getFieldValue($obj, 'call_prefix') . '" style="text-transform: uppercase;" /> <sup>*</sup>
					<p>' . $this->l('International call prefix, e.g., 33 for France.') . '.</p>
				</div>
				<label>' . $this->l('Default currency:') . ' </label>
				<div class="margin-form">
					<select name="id_currency">
						<option value="0" ' . (Tools::getValue('id_currency', $obj->id_currency) == 0 ? 'selected' : '') . '>' . $this->l('Default store currency') . '</option>
		';
        $currencies = Currency::getCurrencies();
        foreach ($currencies as $currency) {
            echo '<option value="' . intval($currency['id_currency']) . '" ' . (Tools::getValue('id_currency', $obj->id_currency) == $currency['id_currency'] ? 'selected' : '') . '>' . Tools::htmlentitiesUTF8($currency['name']) . '</option>';
        }
        echo '
					</select>
				</div>
				<label>' . $this->l('Zone:') . ' </label>
				<div class="margin-form">
					<select name="id_zone">';
        $zones = Zone::getZones();
        foreach ($zones as $zone) {
            echo '		<option value="' . (int) $zone['id_zone'] . '"' . ($this->getFieldValue($obj, 'id_zone') == $zone['id_zone'] ? ' selected="selected"' : '') . '>' . $zone['name'] . '</option>';
        }
        $address_layout = AddressFormat::getAddressCountryFormat($obj->id);
        if ($value = Tools::getValue('address_layout')) {
            $address_layout = $value;
        }
        echo '		</select>
					<p>' . $this->l('Geographical zone where country is located') . '</p>
				</div>
				<label>' . $this->l('Need zip code:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="need_zip_code" id="need_zip_code_on" value="1" onchange="disableZipFormat();" ' . ((!$obj->id or $this->getFieldValue($obj, 'need_zip_code')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="need_zip_code_on"> <img src="../img/admin/enabled.gif" alt="" title="' . $this->l('Yes') . '" /></label>
					<input type="radio" name="need_zip_code" id="need_zip_code_off" value="0" onchange="disableZipFormat();" ' . ((!$this->getFieldValue($obj, 'need_zip_code') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="need_zip_code_off"> <img src="../img/admin/disabled.gif" alt="" title="' . $this->l('No') . '" /></label>
				</div>
				<label class="zip_code_format">' . $this->l('Zip code format:') . ' </label>
				<div class="margin-form zip_code_format">
					<input type="text" name="zip_code_format" id="zip_code_format" value="' . $this->getFieldValue($obj, 'zip_code_format') . '" onkeyup="$(\'#zip_code_format\').val($(\'#zip_code_format\').val().toUpperCase());" /> <sup>*</sup>
					<p>' . $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') . '.</p>
				</div>
				<label class="address_layout">' . $this->l('Address layout:') . ' </label>
				<div class="margin-form" style="vertical-align: top;">
					<div style="float:left">
						<textarea id="ordered_fields" name="address_layout" style="width: 300px;height: 140px;">' . $address_layout . '</textarea>
					</div>
					<div style="float:left; margin-left:20px; width:340px;">
						' . $this->l('Liable fields for the address information (click to have more details)') . ': ' . $this->_displayValidFields() . '
					</div>
					<div class="clear"></div>
					<div style="margin:10px 0 10px 0;">
						<a id="useLastDefaultLayout" style="margin-left:5px;" href="javascript:void(0)" onClick="resetLayout(\'' . urlencode($address_layout) . '\', \'lastDefault\');" class="button">' . $this->l('Use the last registered layout') . '</a>
						<a id="useDefaultLayoutSystem" style="margin-left:5px;" href="javascript:void(0)" onClick="resetLayout(\'' . urlencode($defaultLayout) . '\', \'defaultSystem\');" class="button">' . $this->l('Use a default layout') . '</a>
						<a id="useCurrentLastModifiedLayout" style="margin-left:5px;" href="javascript:void(0)" onClick="resetLayout(lastLayoutModified, \'currentModified\')" class="button">' . $this->l('Use my current modified layout') . '</a>
						<a id="eraseCurrentLayout" style="margin-left:5px;" href="javascript:void(0)" onClick="resetLayout(\'\', \'erase\');" class="button">' . $this->l('Clean layout') . '</a>
						<div style="margin-top:10px; padding-top:5px; height:10px;" id="explanationText"></div>
					</div>
				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . ((!$this->getFieldValue($obj, 'active') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Enabled or disabled') . '</p>
				</div>
				<label>' . $this->l('Contains states:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="contains_states" id="contains_states_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'contains_states')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="contains_states_on"> <img src="../img/admin/enabled.gif" alt="" title="" />' . $this->l('Yes') . '</label>
					<input type="radio" name="contains_states" id="contains_states_off" value="0" ' . ((!$this->getFieldValue($obj, 'contains_states') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="contains_states_off"> <img src="../img/admin/disabled.gif" alt="" title="" />' . $this->l('No') . '</label>
				</div>
				<label>' . $this->l('Need tax identification number?') . ' </label>
				<div class="margin-form">
					<input type="radio" name="need_identification_number" id="need_identification_number_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'need_identification_number')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="need_identification_number_on"> <img src="../img/admin/enabled.gif" alt="" title="" />' . $this->l('Yes') . '</label>
					<input type="radio" name="need_identification_number" id="need_identification_number_off" value="0" ' . ((!$this->getFieldValue($obj, 'need_identification_number') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="need_identification_number_off"> <img src="../img/admin/disabled.gif" alt="" title="" />' . $this->l('No') . '</label>
				</div>
				<div class="clear"></div>
				<label>' . $this->l('Display tax label:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="display_tax_label" id="display_tax_label_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'display_tax_label')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="display_tax_label_on"> <img src="../img/admin/enabled.gif" alt="" title="" />' . $this->l('Yes') . '</label>
					<input type="radio" name="display_tax_label" id="display_tax_label_off" value="0" ' . ((!$this->getFieldValue($obj, 'display_tax_label') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="display_tax_label_off"> <img src="../img/admin/disabled.gif" alt="" title="" />' . $this->l('No') . '</label>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>
		<script type="text/javascript">disableZipFormat();</script>';
    }
    public function displayForm($isMainTab = true)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/world.gif" />' . $this->l('Countries') . '</legend>
				<label>' . $this->l('Country:') . ' </label>
				<div class="margin-form">';
        foreach ($this->_languages as $language) {
            echo '
					<div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input size="30" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
						<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
					</div>';
        }
        $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'name', 'name');
        echo '		<p style="clear: both">' . $this->l('Name of country') . '</p>
				</div>
				<label>' . $this->l('ISO code:') . ' </label>
				<div class="margin-form">
					<input type="text" size="4" maxlength="3" name="iso_code" value="' . htmlentities($this->getFieldValue($obj, 'iso_code'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup>
					<p>' . $this->l('2- or 3-letter ISO code, e.g., FR for France') . '. <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html" target="_blank">' . $this->l('Official list here') . '</a>.</p>
				</div>
				<label>' . $this->l('Call prefix:') . ' </label>
				<div class="margin-form">
					<input type="text" size="4" maxlength="3" name="call_prefix" value="' . (int) $this->getFieldValue($obj, 'call_prefix') . '" style="text-transform: uppercase;" /> <sup>*</sup>
					<p>' . $this->l('International call prefix, e.g., 33 for France.') . '.</p>
				</div>
				<label>' . $this->l('Default currency:') . ' </label>
				<div class="margin-form">
					<select name="id_currency">
						<option value="0" ' . (Tools::getValue('id_currency', $obj->id_currency) == 0 ? 'selected' : '') . '>' . $this->l('Default store currency') . '</option>
		';
        $currencies = Currency::getCurrencies();
        foreach ($currencies as $currency) {
            echo '<option value="' . intval($currency['id_currency']) . '" ' . (Tools::getValue('id_currency', $obj->id_currency) == $currency['id_currency'] ? 'selected' : '') . '>' . Tools::htmlentitiesUTF8($currency['name']) . '</option>';
        }
        echo '
					</select>
				</div>
				<label>' . $this->l('Zone:') . ' </label>
				<div class="margin-form">
					<select name="id_zone">';
        $zones = Zone::getZones();
        foreach ($zones as $zone) {
            echo '		<option value="' . (int) $zone['id_zone'] . '"' . ($this->getFieldValue($obj, 'id_zone') == $zone['id_zone'] ? ' selected="selected"' : '') . '>' . $zone['name'] . '</option>';
        }
        $address_layout = AddressFormat::getAddressCountryFormat($obj->id);
        echo '		</select>
					<p>' . $this->l('Geographical zone where country is located') . '</p>
				</div>
				<label>' . $this->l('Need zip code:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="need_zip_code" id="need_zip_code_on" value="1" onchange="disableZipFormat();" ' . ((!$obj->id or $this->getFieldValue($obj, 'need_zip_code')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="need_zip_code_on"> <img src="../img/admin/enabled.gif" alt="" title="' . $this->l('Yes') . '" /></label>
					<input type="radio" name="need_zip_code" id="need_zip_code_off" value="0" onchange="disableZipFormat();" ' . ((!$this->getFieldValue($obj, 'need_zip_code') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="need_zip_code_off"> <img src="../img/admin/disabled.gif" alt="" title="' . $this->l('No') . '" /></label>
				</div>
				<label class="zip_code_format">' . $this->l('Zip code format:') . ' </label>
				<div class="margin-form zip_code_format">
					<input type="text" name="zip_code_format" id="zip_code_format" value="' . $this->getFieldValue($obj, 'zip_code_format') . '" onkeyup="$(\'#zip_code_format\').val($(\'#zip_code_format\').val().toUpperCase());" /> <sup>*</sup>
					<p>' . $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') . '.</p>
				</div>
				<label class="address_layout">' . $this->l('Address layout:') . ' </label>
				<div class="margin-form" style="vertical-align: top;">
					<p style="float: left;"><textarea id="ordered_fields" name="address_layout" style="width: 300px;height: 120px;">' . $address_layout . '</textarea></p>
					<p style="float: left;margin-left: 10px;"><a href="#" onClick="$(\'textarea#ordered_fields\').val(unescape(\'' . urlencode($address_layout) . '\'.replace(/\\+/g, \' \')));return false;" class="button">' . $this->l('Reset address layout') . '</a></p>					
					<p class="clear">' . $this->l('Possible fields :') . ' ' . implode(', ', Address::getDispFieldsValidate()) . '</p>
				</div>
				<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'active')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . ((!$this->getFieldValue($obj, 'active') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Enabled or disabled') . '</p>
				</div>
				<label>' . $this->l('Contains states:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="contains_states" id="contains_states_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'contains_states')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="contains_states_on"> <img src="../img/admin/enabled.gif" alt="" title="" />' . $this->l('Yes') . '</label>
					<input type="radio" name="contains_states" id="contains_states_off" value="0" ' . ((!$this->getFieldValue($obj, 'contains_states') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="contains_states_off"> <img src="../img/admin/disabled.gif" alt="" title="" />' . $this->l('No') . '</label>
				</div>
				<label>' . $this->l('Need tax identification number?') . ' </label>
				<div class="margin-form">
					<input type="radio" name="need_identification_number" id="need_identification_number_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'need_identification_number')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="need_identification_number_on"> <img src="../img/admin/enabled.gif" alt="" title="" />' . $this->l('Yes') . '</label>
					<input type="radio" name="need_identification_number" id="need_identification_number_off" value="0" ' . ((!$this->getFieldValue($obj, 'need_identification_number') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="need_identification_number_off"> <img src="../img/admin/disabled.gif" alt="" title="" />' . $this->l('No') . '</label>
				</div>
				<div class="clear"></div>
				<label>' . $this->l('Display tax label:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="display_tax_label" id="display_tax_label_on" value="1" ' . ((!$obj->id or $this->getFieldValue($obj, 'display_tax_label')) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="display_tax_label_on"> <img src="../img/admin/enabled.gif" alt="" title="" />' . $this->l('Yes') . '</label>
					<input type="radio" name="display_tax_label" id="display_tax_label_off" value="0" ' . ((!$this->getFieldValue($obj, 'display_tax_label') and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="display_tax_label_off"> <img src="../img/admin/disabled.gif" alt="" title="" />' . $this->l('No') . '</label>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>
		<script type="text/javascript">disableZipFormat();</script>';
    }
 public function displayAddressDetail($address)
 {
     $optional_fields = array('company' => 1, 'phone' => 1, 'phone_mobile' => 1, 'address2' => 1);
     $out = '';
     $address_datas = AddressFormat::getAddressCountryFormat($address->id_country);
     $field_other = $address->other;
     $lines_out = $address->getOrderedValues(array('spacer' => ' ', 'optional' => $optional_fields), $address_datas);
     $out = implode("<br />", $lines_out) . (!(is_null($field_other) || $field_other == '') ? '<hr />' . $field_other : '');
     return $out;
 }