Exemplo n.º 1
0
    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() . '<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ($obj->id ? '<input type="hidden" id="id_county" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/world.gif" />' . $this->l('Counties') . '</legend>';
        if (!isset($obj->id)) {
            echo '<div class="hint clear" style="display:block;">&nbsp;' . $this->l('Save this county then you will be able to associate zipcodes') . '</div><br />';
        }
        $countries = Country::getCountries($cookie->id_lang, true, true);
        echo '<label>' . $this->l('Country:') . ' </label>
				<div class="margin-form"><select id="id_country" onchange="populateStates($(this).val(), ' . (int) $this->getFieldValue($obj, 'id_state') . ');">';
        foreach ($countries as $country) {
            echo '<option value="' . (int) $country['id_country'] . '" ' . ($cur_id_country == $country['id_country'] ? 'selected' : '') . '>' . Tools::htmlentitiesUTF8($country['name']) . '</option>';
        }
        echo '</select></div>';
        echo '<label>' . $this->l('State:') . ' </label>
				<div class="margin-form">
				<select name="id_state" id="id_state">
				</select>
				</div>
				<script type="text/javascript">
					id_country = $("#id_country").val();
					populateStates(id_country,' . (int) $cur_id_state . ');
				</script>';
        echo '<label>' . $this->l('Name:') . ' </label>
				<div class="margin-form">
					<input type="text" size="30" maxlength="64" name="name" value="' . htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
				</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="' . $this->l('Enabled') . '" 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="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p>' . $this->l('Enabled or disabled') . '</p>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />&nbsp;
					<input type="submit" value="' . $this->l('Save and stay') . '" name="submitAdd' . $this->table . 'AndStay" class="button" />
				</div>';
        echo '<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>';
        if (isset($obj->id)) {
            echo '
					<div class="margin-form">
					' . $this->_renderZipCodeForm() . '<br />
					<div id="zipcodes-list">
					' . AdminCounty::renderZipCodeList($obj->getZipCodes()) . '
					</div></div>';
        }
        echo '
			</fieldset>
		</form>';
    }
Exemplo n.º 2
0
    $zipcodes = Tools::getValue('zipcodes');
    $id_county = (int) Tools::getValue('id_county');
    $county = new County($id_county);
    if (!Validate::isLoadedObject($county)) {
        die('error');
    }
    if (Tools::isSubmit('ajaxAddZipCode')) {
        if ($county->isZipCodeRangePresent($zipcodes)) {
            die('error:' . Tools::displayError('This Zip Code is already in use.'));
        }
        if ($county->addZipCodes($zipcodes)) {
            die(AdminCounty::renderZipCodeList($county->getZipCodes()));
        }
    } else {
        if (Tools::isSubmit('ajaxRemoveZipCode') and $county->removeZipCodes($zipcodes)) {
            die(AdminCounty::renderZipCodeList($county->getZipCodes()));
        }
    }
    die('error');
}
if (Tools::isSubmit('helpAccess')) {
    $item = Tools::getValue('item');
    $isoUser = Tools::getValue('isoUser');
    $country = Tools::getValue('country');
    $version = Tools::getValue('version');
    if (isset($item) and isset($isoUser) and isset($country)) {
        die(HelpAccess::displayHelp($item, $isoUser, $country, $version));
    }
    die;
}
if (Tools::isSubmit('getHookableList')) {