2016-01-04 12:48:08 +01:00
|
|
|
{*
|
|
|
|
* 2007-2011 PrestaShop
|
|
|
|
*
|
|
|
|
* NOTICE OF LICENSE
|
|
|
|
*
|
|
|
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
|
|
* that is bundled with this package in the file LICENSE.txt.
|
|
|
|
* It is also available through the world-wide-web at this URL:
|
|
|
|
* http://opensource.org/licenses/afl-3.0.php
|
|
|
|
* If you did not receive a copy of the license and are unable to
|
|
|
|
* obtain it through the world-wide-web, please send an email
|
|
|
|
* to license@prestashop.com so we can send you a copy immediately.
|
|
|
|
*
|
|
|
|
* DISCLAIMER
|
|
|
|
*
|
|
|
|
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
|
|
|
* versions in the future. If you wish to customize PrestaShop for your
|
|
|
|
* needs please refer to http://www.prestashop.com for more information.
|
|
|
|
*
|
|
|
|
* @author PrestaShop SA <contact@prestashop.com>
|
|
|
|
* @copyright 2007-2011 PrestaShop SA
|
|
|
|
* @version Release: $Revision: 8673 $
|
|
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
|
|
* International Registered Trademark & Property of PrestaShop SA
|
|
|
|
*}
|
|
|
|
|
|
|
|
{*
|
|
|
|
** Compatibility code for Prestashop older than 1.4.2 using a recent theme
|
|
|
|
** Ignore list isn't require here
|
|
|
|
** $address exist in every PrestaShop version
|
|
|
|
*}
|
|
|
|
|
|
|
|
{* Will be deleted for 1.5 version and more *}
|
|
|
|
{* If ordered_adr_fields doesn't exist, it's a PrestaShop older than 1.4.2 *}
|
|
|
|
{if !isset($ordered_adr_fields)}
|
|
|
|
{if isset($address)}
|
|
|
|
{counter start=0 skip=1 assign=address_key_number}
|
|
|
|
{foreach from=$address key=address_key item=address_value}
|
|
|
|
{$ordered_adr_fields.$address_key_number = $address_key}
|
|
|
|
{counter}
|
|
|
|
{/foreach}
|
|
|
|
{else}
|
|
|
|
{$ordered_adr_fields.0 = 'company'}
|
|
|
|
{$ordered_adr_fields.1 = 'firstname'}
|
|
|
|
{$ordered_adr_fields.2 = 'lastname'}
|
|
|
|
{$ordered_adr_fields.3 = 'address1'}
|
|
|
|
{$ordered_adr_fields.4 = 'address2'}
|
|
|
|
{$ordered_adr_fields.5 = 'postcode'}
|
|
|
|
{$ordered_adr_fields.6 = 'city'}
|
|
|
|
{$ordered_adr_fields.7 = 'country'}
|
|
|
|
{$ordered_adr_fields.8 = 'state'}
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
// <![CDATA[
|
|
|
|
idSelectedCountry = {if isset($smarty.post.id_state)}{$smarty.post.id_state|intval}{else}{if isset($address->id_state)}{$address->id_state|intval}{else}false{/if}{/if};
|
|
|
|
countries = new Array();
|
|
|
|
countriesNeedIDNumber = new Array();
|
|
|
|
countriesNeedZipCode = new Array();
|
|
|
|
{foreach from=$countries item='country'}
|
|
|
|
{if isset($country.states) && $country.contains_states}
|
|
|
|
countries[{$country.id_country|intval}] = new Array();
|
|
|
|
{foreach from=$country.states item='state' name='states'}
|
|
|
|
countries[{$country.id_country|intval}].push({ldelim}'id' : '{$state.id_state}', 'name' : '{$state.name|escape:'htmlall':'UTF-8'}'{rdelim});
|
|
|
|
{/foreach}
|
|
|
|
{/if}
|
|
|
|
{if $country.need_identification_number}
|
|
|
|
countriesNeedIDNumber.push({$country.id_country|intval});
|
|
|
|
{/if}
|
|
|
|
{if isset($country.need_zip_code)}
|
|
|
|
countriesNeedZipCode[{$country.id_country|intval}] = {$country.need_zip_code};
|
|
|
|
{/if}
|
|
|
|
{/foreach}
|
|
|
|
$(function(){ldelim}
|
|
|
|
$('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state}{else}{if isset($address->id_state)}{$address->id_state|escape:'htmlall':'UTF-8'}{/if}{/if}]').attr('selected', 'selected');
|
|
|
|
{rdelim});
|
|
|
|
{if $vat_management}
|
|
|
|
{literal}
|
|
|
|
$(document).ready(function() {
|
|
|
|
$('#company').blur(function(){
|
|
|
|
vat_number();
|
|
|
|
});
|
|
|
|
vat_number();
|
|
|
|
function vat_number()
|
|
|
|
{
|
|
|
|
if ($('#company').val() != '')
|
|
|
|
$('#vat_number').show();
|
|
|
|
else
|
|
|
|
$('#vat_number').hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
{/literal}
|
|
|
|
{/if}
|
|
|
|
//]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{if $back == 'order.php?step=1'}
|
|
|
|
{assign var='current_step' value='address'}
|
|
|
|
{include file="$tpl_dir./order-steps.tpl"}
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
{capture name=path}{l s='Your addresses'}{/capture}
|
|
|
|
{include file="$tpl_dir./breadcrumb.tpl"}
|
|
|
|
|
|
|
|
<div id="title_block"><h1>{l s='Your addresses'}</h1></div>
|
|
|
|
<h3>
|
|
|
|
{if isset($id_address) && (isset($smarty.post.alias) || isset($address->alias))}
|
|
|
|
{l s='Modify address'}
|
|
|
|
{if isset($smarty.post.alias)}
|
|
|
|
"{$smarty.post.alias}"
|
|
|
|
{else}
|
|
|
|
{if isset($address->alias)}"{$address->alias|escape:'htmlall':'UTF-8'}"{/if}
|
|
|
|
{/if}
|
|
|
|
{else}
|
|
|
|
{l s='To add a new address, please fill out the form below.'}
|
|
|
|
{/if}
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
{include file="$tpl_dir./errors.tpl"}
|
|
|
|
|
|
|
|
<form action="{$link->getPageLink('address.php', true)}" method="post" class="std">
|
|
|
|
<fieldset>
|
|
|
|
<div class="content">
|
|
|
|
<p class="required info"><sup>*</sup>{l s='Required field'}</p>
|
|
|
|
<p class="required text dni">
|
|
|
|
<label for="dni">{l s='Identification number'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<input type="text" class="text" name="dni" id="dni" value="{if isset($smarty.post.dni)}{$smarty.post.dni}{else}{if isset($address->dni)}{$address->dni|escape:'htmlall':'UTF-8'}{/if}{/if}" />
|
|
|
|
<span class="form_info">{l s='DNI / NIF / NIE'}</span>
|
|
|
|
</p>
|
|
|
|
{if $vat_display == 2}
|
|
|
|
<div id="vat_area">
|
|
|
|
{elseif $vat_display == 1}
|
|
|
|
<div id="vat_area" style="display: none;">
|
|
|
|
{else}
|
|
|
|
<div style="display: none;">
|
|
|
|
{/if}
|
|
|
|
<div id="vat_number">
|
|
|
|
<p class="text">
|
|
|
|
<label for="vat_number">{l s='VAT number'}</label>
|
|
|
|
<input type="text" class="text" name="vat_number" value="{if isset($smarty.post.vat_number)}{$smarty.post.vat_number}{else}{if isset($address->vat_number)}{$address->vat_number|escape:'htmlall':'UTF-8'}{/if}{/if}" />
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{assign var="stateExist" value="false"}
|
|
|
|
{foreach from=$ordered_adr_fields item=field_name}
|
|
|
|
{if $field_name eq 'company'}
|
|
|
|
<p class="text">
|
|
|
|
<label for="company">{l s='Company'}</label>
|
|
|
|
<input type="text" id="company" name="company" value="{if isset($smarty.post.company)}{$smarty.post.company}{else}{if isset($address->company)}{$address->company|escape:'htmlall':'UTF-8'}{/if}{/if}" />
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
{if $field_name eq 'firstname'}
|
|
|
|
<p class="required text">
|
|
|
|
<label for="firstname">{l s='First name'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<input type="text" name="firstname" id="firstname" value="{if isset($smarty.post.firstname)}{$smarty.post.firstname}{else}{if isset($address->firstname)}{$address->firstname|escape:'htmlall':'UTF-8'}{/if}{/if}" /
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
{if $field_name eq 'lastname'}
|
|
|
|
<p class="required text">
|
|
|
|
<label for="lastname">{l s='Last name'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<input type="text" id="lastname" name="lastname" value="{if isset($smarty.post.lastname)}{$smarty.post.lastname}{else}{if isset($address->lastname)}{$address->lastname|escape:'htmlall':'UTF-8'}{/if}{/if}" />
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
{if $field_name eq 'address1'}
|
|
|
|
<p class="required text">
|
|
|
|
<label for="address1">{l s='Address'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<input type="text" id="address1" name="address1" value="{if isset($smarty.post.address1)}{$smarty.post.address1}{else}{if isset($address->address1)}{$address->address1|escape:'htmlall':'UTF-8'}{/if}{/if}" />
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
{if $field_name eq 'address2'}
|
|
|
|
<p class="required text">
|
|
|
|
<label for="address2">{l s='Address (Line 2)'}</label>
|
|
|
|
<input type="text" id="address2" name="address2" value="{if isset($smarty.post.address2)}{$smarty.post.address2}{else}{if isset($address->address2)}{$address->address2|escape:'htmlall':'UTF-8'}{/if}{/if}" />
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
{if $field_name eq 'postcode'}
|
|
|
|
<p class="required postcode text">
|
|
|
|
<label for="postcode">{l s='Zip / Postal Code'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<input type="text" id="postcode" name="postcode" value="{if isset($smarty.post.postcode)}{$smarty.post.postcode}{else}{if isset($address->postcode)}{$address->postcode|escape:'htmlall':'UTF-8'}{/if}{/if}" onkeyup="$('#postcode').val($('#postcode').val().toUpperCase());" />
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
{if $field_name eq 'city'}
|
|
|
|
<p class="required text">
|
|
|
|
<label for="city">{l s='City'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<input type="text" name="city" id="city" value="{if isset($smarty.post.city)}{$smarty.post.city}{else}{if isset($address->city)}{$address->city|escape:'htmlall':'UTF-8'}{/if}{/if}" maxlength="64" />
|
|
|
|
</p>
|
|
|
|
<!-- If the merchant has not updated his layout address, country has to be verified - however it's deprecated -->
|
|
|
|
{/if}
|
|
|
|
{if $field_name eq 'Country:name' || $field_name eq 'country'}
|
|
|
|
<p class="required select">
|
|
|
|
<label for="id_country">{l s='Country'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<select id="id_country" name="id_country">{$countries_list}</select>
|
|
|
|
</p>
|
|
|
|
{if isset($vatnumber_ajax_call) && $vatnumber_ajax_call}
|
|
|
|
<script type="text/javascript">
|
|
|
|
var ajaxurl = '{$ajaxurl}';
|
|
|
|
{literal}
|
|
|
|
$(document).ready(function(){
|
|
|
|
$('#id_country').change(function() {
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: ajaxurl+"vatnumber/ajax.php?id_country="+$('#id_country').val(),
|
|
|
|
success: function(isApplicable){
|
|
|
|
if(isApplicable == "1")
|
|
|
|
{
|
|
|
|
$('#vat_area').show();
|
|
|
|
$('#vat_number').show();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#vat_area').hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
{/literal}
|
|
|
|
</script>
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
{if $field_name eq 'State:name' || $field_name eq 'state'}
|
|
|
|
{assign var="stateExist" value="true"}
|
|
|
|
<p class="required id_state select">
|
|
|
|
<label for="id_state">{l s='State'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<select name="id_state" id="id_state">
|
|
|
|
<option value="">-</option>
|
|
|
|
</select>
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
{/foreach}
|
|
|
|
<p><input type="hidden" name="token" value="{$token}" /></p>
|
|
|
|
{if $stateExist eq "false"}
|
|
|
|
<p class="required id_state select">
|
|
|
|
<label for="id_state">{l s='State'}</label>
|
|
|
|
<sup>*</sup>
|
|
|
|
<select name="id_state" id="id_state">
|
|
|
|
<option value="">-</option>
|
|
|
|
</select>
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
<p class="textarea">
|
|
|
|
<label for="other">{l s='Additional information'}</label>
|
|
|
|
<textarea id="other" name="other" cols="26" rows="3">{if isset($smarty.post.other)}{$smarty.post.other}{else}{if isset($address->other)}{$address->other|escape:'htmlall':'UTF-8'}{/if}{/if}</textarea>
|
|
|
|
</p>
|
|
|
|
<p class="notification">{l s='You must register at least one phone number'} <sup>*</sup></p>
|
|
|
|
<p class="text">
|
|
|
|
<label for="phone">{l s='Home phone'}</label>
|
|
|
|
<input type="text" id="phone" name="phone" value="{if isset($smarty.post.phone)}{$smarty.post.phone}{else}{if isset($address->phone)}{$address->phone|escape:'htmlall':'UTF-8'}{/if}{/if}" />
|
|
|
|
</p>
|
|
|
|
<p class="text">
|
|
|
|
<label for="phone_mobile">{l s='Mobile phone'}</label>
|
|
|
|
<input type="text" id="phone_mobile" name="phone_mobile" value="{if isset($smarty.post.phone_mobile)}{$smarty.post.phone_mobile}{else}{if isset($address->phone_mobile)}{$address->phone_mobile|escape:'htmlall':'UTF-8'}{/if}{/if}" />
|
|
|
|
</p>
|
|
|
|
{if isset($first_address) && $first_address == 1}
|
|
|
|
<p class="required text hidden" id="adress_alias">
|
|
|
|
<label for="alias">{l s='Assign an address title for future reference'}<sup>*</sup></label>
|
|
|
|
<input type="text" id="alias" name="alias" value="{l s='My address'}" />
|
|
|
|
</p>
|
|
|
|
{else}
|
|
|
|
<p class="required text" id="adress_alias">
|
|
|
|
<label for="alias">{l s='Assign an address title for future reference'}<sup>*</sup></label>
|
|
|
|
<input type="text" id="alias" name="alias" value="{if isset($smarty.post.alias)}{$smarty.post.alias}{elseif isset($address->alias)}{$address->alias|escape:'htmlall':'UTF-8'}{elseif isset($select_address)}{else}{l s='My address'}{/if}" />
|
|
|
|
</p>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
<p class="submit2 address_navigation footer_links">
|
|
|
|
{if isset($id_address)}<input type="hidden" name="id_address" value="{$id_address|intval}" />{/if}
|
|
|
|
{if isset($back)}<input type="hidden" name="back" value="{$back}" />{/if}
|
|
|
|
{if isset($mod)}<input type="hidden" name="mod" value="{$mod}" />{/if}
|
|
|
|
{if isset($select_address)}<input type="hidden" name="select_address" value="{$select_address|intval}" />{/if}
|
|
|
|
<a class="button_large" href="{if $back == 'order.php?step=1'}order.php?step=1{else}{$link->getPageLink('addresses.php', true)}{/if}" title="{l s='Previous'}">{l s='Previous'}</a>
|
|
|
|
<input type="submit" name="submitAddress" id="submitAddress" value="{l s='Save'}" class="exclusive" />
|
|
|
|
<br class="clear"/>
|
|
|
|
</p>
|
2016-05-20 10:48:35 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
<!--{literal}
|
|
|
|
var ctimeout = null;
|
|
|
|
var ctimeout_cleared = true;
|
|
|
|
var creq = null;
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
$("#postcode, #city").keydown(function(e) {
|
|
|
|
if($("#address_ac").length > 0 && (e.keyCode == 13 || e.keyCode == 38 || e.keyCode == 40)) {
|
|
|
|
e.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$("#postcode").keyup(function(e) {
|
|
|
|
if($("#id_country").val() == 8) {
|
|
|
|
switch($("#postcode").val().substring(0, 3)) {
|
|
|
|
case "971":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(98);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "972":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(141);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "973":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(241);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "974":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(176);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "975":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(183);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "976":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(144);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "987":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(242);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "988":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(158);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "980":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(148);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch($("#postcode").val().substring(0, 2)) {
|
|
|
|
case "AD":
|
|
|
|
case "ad":
|
|
|
|
case "Ad":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(40);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case "SP":
|
|
|
|
case "sp":
|
|
|
|
case "Sp":
|
|
|
|
case "00":
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#id_country").val(245);
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($("#address_ac").length > 0 && (e.keyCode == 27)) {
|
|
|
|
$("#address_ac").remove();
|
|
|
|
} else if(e.keyCode == 13) {
|
|
|
|
e.preventDefault();
|
|
|
|
if($("#address_ac .active").length > 0) {
|
|
|
|
$("#address_ac .active").trigger("click");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} else if($("#address_ac").length > 0 && (e.keyCode == 38 || e.keyCode == 40)) {
|
|
|
|
if(e.keyCode == 38) {
|
|
|
|
$("#address_ac .active:not(:first-child)").removeClass("active").prev().addClass("active");
|
|
|
|
} else {
|
|
|
|
if($("#address_ac .active").length > 0) {
|
|
|
|
$("#address_ac .active:not(:last-child)").removeClass("active").next().addClass("active");
|
|
|
|
} else {
|
|
|
|
$("#address_ac li:first-child").addClass("active");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ctimeout = setTimeout(function() {
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#city").val("");
|
|
|
|
clearTimeout(ctimeout);
|
|
|
|
ctimeout_cleared = true;
|
|
|
|
var inval = $("<div />").text($("#postcode").val()).html();
|
|
|
|
if(inval != "") {
|
|
|
|
creq = $.getJSON("{/literal}{$base_dir_ssl}{literal}check_address.php?token={/literal}{$address_ac_token}{literal}&id_country=" + parseInt($("#id_country").val()) + "&postcode=" + inval, function(result) {
|
|
|
|
if(result) {
|
|
|
|
if(result.length == 1) {
|
|
|
|
$("#postcode").val(result[0].postcode);
|
|
|
|
$("#city").val(result[0].city);
|
|
|
|
} else {
|
|
|
|
var ac = $("<ul />").attr("id", "address_ac").css({
|
|
|
|
position: "absolute",
|
|
|
|
top: $("#postcode").position().top + $("#postcode").outerHeight(),
|
|
|
|
left: $("#postcode").position().left
|
|
|
|
});
|
|
|
|
for(i in result) {
|
|
|
|
$(ac).append($("<li />")
|
|
|
|
.attr("data-city", result[i].city)
|
|
|
|
.attr("data-postcode", result[i].postcode)
|
|
|
|
.html((result[i].postcode + " - " + result[i].city).replace(inval, "<strong>" + inval + "</strong>"))
|
|
|
|
.click(function() {
|
|
|
|
$("#postcode").val($(this).attr("data-postcode"));
|
|
|
|
$("#city").val($(this).attr("data-city"));
|
|
|
|
$("#address_ac").remove();
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$("#postcode").parent().after($(ac));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 300);
|
|
|
|
ctimeout_cleared = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$("#city").keyup(function(e) {
|
|
|
|
if($("#id_country").val() == 8) {
|
|
|
|
if($("#address_ac").length > 0 && (e.keyCode == 27)) {
|
|
|
|
$("#address_ac").remove();
|
|
|
|
} else if(e.keyCode == 13) {
|
|
|
|
e.preventDefault();
|
|
|
|
if($("#address_ac .active").length > 0) {
|
|
|
|
$("#address_ac .active").trigger("click");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} else if($("#address_ac").length > 0 && (e.keyCode == 38 || e.keyCode == 40)) {
|
|
|
|
if(e.keyCode == 38) {
|
|
|
|
$("#address_ac .active:not(:first-child)").removeClass("active").prev().addClass("active");
|
|
|
|
} else {
|
|
|
|
if($("#address_ac .active").length > 0) {
|
|
|
|
$("#address_ac .active:not(:last-child)").removeClass("active").next().addClass("active");
|
|
|
|
} else {
|
|
|
|
$("#address_ac li:first-child").addClass("active");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ctimeout = setTimeout(function() {
|
|
|
|
try {
|
|
|
|
creq.abort();
|
|
|
|
} catch(e) {}
|
|
|
|
$("#address_ac").remove();
|
|
|
|
$("#postcode").val("");
|
|
|
|
clearTimeout(ctimeout);
|
|
|
|
ctimeout_cleared = true;
|
|
|
|
var inval = $("<div />").text($("#city").val()).html();
|
|
|
|
if(inval != "") {
|
|
|
|
creq = $.getJSON("{/literal}{$base_dir_ssl}{literal}check_address.php?token={/literal}{$address_ac_token}{literal}&id_country=" + parseInt($("#id_country").val()) + "&city=" + inval, function(result) {
|
|
|
|
if(result) {
|
|
|
|
if(result.length == 1) {
|
|
|
|
$("#postcode").val(result[0].postcode);
|
|
|
|
$("#city").val(result[0].city);
|
|
|
|
} else {
|
|
|
|
var ac = $("<ul />").attr("id", "address_ac").css({
|
|
|
|
position: "absolute",
|
|
|
|
top: $("#city").position().top + $("#city").outerHeight(),
|
|
|
|
left: $("#city").position().left
|
|
|
|
});
|
|
|
|
for(i in result) {
|
|
|
|
$(ac).append($("<li />")
|
|
|
|
.attr("data-city", result[i].city)
|
|
|
|
.attr("data-postcode", result[i].postcode)
|
|
|
|
.html((result[i].postcode + " - " + result[i].city).replace(inval, "<strong>" + inval + "</strong>"))
|
|
|
|
.click(function() {
|
|
|
|
$("#postcode").val($(this).attr("data-postcode"));
|
|
|
|
$("#city").val($(this).attr("data-city"));
|
|
|
|
$("#address_ac").remove();
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$("#city").parent().after($(ac));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, 300);
|
|
|
|
ctimeout_cleared = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var postcodeval = $("#postcode").val();
|
|
|
|
setInterval(function() {
|
|
|
|
if($("#postcode").is(":focus") && ctimeout_cleared && $("#postcode").val() != postcodeval) {
|
|
|
|
$("#postcode").trigger("keyup");
|
|
|
|
}
|
|
|
|
postcodeval = $("#postcode").val();
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
var cityval = $("#city").val();
|
|
|
|
setInterval(function() {
|
|
|
|
if($("#city").is(":focus") && ctimeout_cleared && $("#city").val() != cityval) {
|
|
|
|
$("#city").trigger("keyup");
|
|
|
|
}
|
|
|
|
cityval = $("#city").val();
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
$("#id_country").change(function() {
|
|
|
|
$("#postcode, #city").val("");
|
|
|
|
if($("#id_country").val() == 8) {
|
|
|
|
$("#postcode, #city").attr("autocomplete", "off");
|
|
|
|
} else {
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if($("#id_country").val() == 8) {
|
|
|
|
$("#postcode, #city").attr("autocomplete", "off");
|
|
|
|
} else {
|
|
|
|
$("#postcode, #city").attr("autocomplete", "on");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
{/literal}-->
|
|
|
|
</script>
|
2016-01-04 12:48:08 +01:00
|
|
|
</form>
|