84 lines
3.3 KiB
Smarty
84 lines
3.3 KiB
Smarty
<div class="delivery-class" data-delivery-class="{$deliveryPrefix}[intime-point]">
|
|
{if $object.cart_description}
|
|
{$object.cart_description nofilter}
|
|
{else}
|
|
<p>{t escape=false}Zásilky běžně doručujeme do druhého dne.{/t}</p>
|
|
{/if}
|
|
{$info = $object->getInfo($object.intime_id)}
|
|
<div class="pos-rel">
|
|
<input type="hidden" name="{$deliveryPrefix}[intime_id]" value="{$info.id}">
|
|
<input name="{$deliveryPrefix}[delivery_intime_zip]" value="{$info.address}" class="form-control" placeholder="PSČ, město"
|
|
autocomplete="off">
|
|
<button type="button" class="delete-zip" title="{t}Smazat hledané PSČ, město{/t}"><span class="fc lightbox_close"></span>
|
|
</button>
|
|
</div>
|
|
<div data-reload="intime-point_{$object.id}" class="delivery-class-info">
|
|
{if $info.zip}
|
|
{if $info.id}
|
|
<input type="hidden" name="delivery_intime_valid" value="1">
|
|
<p><strong>{t}Zboží doručíme na pobočku:{/t}</strong></p>
|
|
<p><strong>{$info.name}</strong><br>
|
|
{$info.street}<br>{$info.zip} {$info.city}<br>
|
|
</p>
|
|
{else}
|
|
<p><strong>{t}Pobočka nenalezena{/t}</strong></p>
|
|
<p>{t}Na hledaném místě neexistuje žádná pobočka Uloženky.{/t}</p>
|
|
{/if}
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
|
|
<script id="{$deliveryPrefix}[intimePointSearch]" type="text/x-dot-template">
|
|
{literal}
|
|
<div class="ac-psc">
|
|
<ul>
|
|
{{? it.items.length > 0}}
|
|
{{~it.items :item :index}}
|
|
<li data-autocomplete-item="product" data-autocomplete-value="{{=item.value}}"
|
|
data-autocomplete-name="{{=item.zip}} {{=item.name}}">
|
|
<span>{{=item.zip}} {{=item.name}}</span>
|
|
</li>
|
|
{{~}}
|
|
{{??}}
|
|
<li>Pobočka InTime nenalezena</li>
|
|
{{?}}
|
|
</ul>
|
|
</div>
|
|
{/literal}
|
|
</script>
|
|
|
|
<script>
|
|
wpj.onReady.push(function () {
|
|
var errNotFound = "{t}Pobočka InTime nebyla nalezena. Vyberte prosím jinou pobočku, nebo změňte způsob dopravy.{/t}";
|
|
|
|
var $deliveryWrapper = $('[data-delivery-class="{$deliveryPrefix}[intime-point]"]');
|
|
var $input = $deliveryWrapper.find('input[name="{$deliveryPrefix}[delivery_intime_zip]"]');
|
|
var $inputId = $deliveryWrapper.find(`input[name="{{$deliveryPrefix}}[intime_id]"]`);
|
|
|
|
{literal}
|
|
|
|
$input.deliveryAutocomplete({
|
|
source: '{/literal}{path('kupshop_catalog_autocomplete_autocomplete', ['type' => 'delivery_intime'])}{literal}&term={{=it.value}}',
|
|
template: '#{/literal}{$deliveryPrefix|replace:'[':'\\\['|replace:']':'\\\]'}{literal}\\[intimePointSearch\\]',
|
|
inputId: $inputId
|
|
});
|
|
|
|
$input.closest('form').on('success.form.bv', function (w, hasError) {
|
|
if ($input.is(':visible') && $input.parents(':hidden').length === 0) {
|
|
if (!$('[name="delivery_intime_valid"]').val()) {
|
|
window.alert(errNotFound);
|
|
if (typeof hasError !== "undefined") {
|
|
hasError.error = true;
|
|
}
|
|
setTimeout(function () {
|
|
$input.get(0).focus();
|
|
}, 100);
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
|
|
{/literal}
|
|
});
|
|
</script>
|