{**
 * Copyright 2024-2025 Simply.IN Sp. z o.o.
 *
 * NOTICE OF LICENSE
 *
 * Licensed under the EUPL-1.2 or later.
 * You may not use this work except in compliance with the Licence.
 *
 * Copy of the Licence is available at:
 * https://joinup.ec.europa.eu/software/page/eupl
 * It is bundled with this package in the file LICENSE.txt
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Licence is distributed on an as is basis,
 * without warranties or conditions of any kind, either express or implied.
 * Check the Licence for the specific language governing permissions
 * and limitations under the License.
 *
 * @author    Simply.IN Sp. z o.o.
 * @copyright 2024-2025 Simply.IN Sp. z o.o.
 * @license   https://joinup.ec.europa.eu/software/page/eupl
 *}
<div class="simplyin-popup-overlay"></div>
<div class="simplyin-popup">
    <div class="simplyin-popup-header">
        <img width="39" height="40" src="{$module_path|escape:'html':'UTF-8'}views/img/logo_smalln.svg"/>
        <span class="popup-add-address-label-header">
            {if $address_type == 'shippingAddresses'}
                {l s='Delivery details' mod='simplyin'}
            {else}
                {l s='Billing details' mod='simplyin'}
            {/if}
        </span>
        <div class="simplyin-popup-close-button">
            <img width="24" height="24" src="{$module_path|escape:'html':'UTF-8'}views/img/close_icon.svg"/>
        </div>
    </div>
    <div class="simplyin-popup-container">
        <form class="simplyin-popup-addres-form">
        <div class="simplyin-popup-content">
                <input type="hidden" name="_id" value="{$address['_id']|escape:'htmlall':'UTF-8'}" />
                <input type="hidden" name="address_type" value="{$address_type|escape:'htmlall':'UTF-8'}" />
                <div class="form-row">
                    <div class="form-group">
                        <input required type="text" id="first-name" name="name" placeholder="{l s='Firstname' mod='simplyin'}" value="{$address['name']|escape:'htmlall':'UTF-8'}" placeholder="{l s='First name' mod='simplyin'}">
                        <div class="error-message">{l s='First name is required' mod='simplyin'}</div>
                    </div>
                    <div class="form-group">
                        <input required type="text" id="last-name" name="surname" placeholder="{l s='Surname' mod='simplyin'}" value="{$address['surname']|escape:'htmlall':'UTF-8'}" placeholder="{l s='Last name' mod='simplyin'}">
                        <div class="error-message">{l s='Last name is required' mod='simplyin'}</div>
                    </div>
                </div>
                <div class="form-group">
                    <input required type="text" id="street" name="street" placeholder="{l s='Street' mod='simplyin'}" value="{$address['street']|escape:'htmlall':'UTF-8'}" placeholder="{l s='Street and house number' mod='simplyin'}">
                    <div class="error-message">{l s='Street is required' mod='simplyin'}</div>
                </div>
                <div class="form-group">
                    <input type="text" id="apartment" name="appartmentNumber" placeholder="{l s='Apartment number' mod='simplyin'}" value="{$address['appartmentNumber']|escape:'htmlall':'UTF-8'}" placeholder="{l s='Apartment number (optional)' mod='simplyin'}">
                </div>
                <div class="form-row">
                    <div class="form-group">
                        <input required type="text" id="zip" name="postalCode" placeholder="{l s='Post code' mod='simplyin'}" value="{$address['postalCode']|escape:'htmlall':'UTF-8'}" placeholder="{l s='Postal code' mod='simplyin'}">
                        <div class="error-message">{l s='Postal code is required' mod='simplyin'}</div>
                    </div>
                    <div class="form-group">
                        <input required type="text" id="city" name="city" placeholder="{l s='City' mod='simplyin'}" value="{$address['city']|escape:'htmlall':'UTF-8'}" placeholder="{l s='City' mod='simplyin'}">
                        <div class="error-message">{l s='City is required' mod='simplyin'}</div>
                    </div>
                </div>
                <div class="form-group">
                    <select id="country" name="country">
                        {foreach from=$countries item='country'}
                            <option{if $address['country'] == $country['iso_code'] || $address['country'] == '' AND $country['iso_code'] == $default_country_iso} selected{/if} value="{$country['iso_code']|escape:'htmlall':'UTF-8'}">{$country['name']|escape:'htmlall':'UTF-8'}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="pickup-details-header">{l s='Company details (optional)' mod='simplyin'}</div>
                <div class="form-group">
                    <input type="text" id="company" name="companyName" placeholder="{l s='Company' mod='simplyin'}" value="{$address['companyName']|escape:'htmlall':'UTF-8'}" placeholder="{l s='Company name (optional)' mod='simplyin'}">
                </div>
                {if $address_type == 'billingAddresses'}
                <div class="form-group">
                    <input type="text" id="nip" name="taxId" placeholder="{l s='Vat number' mod='simplyin'}" value="{if isset($address['taxId'])}{$address['taxId']|escape:'htmlall':'UTF-8'}{/if}" placeholder="{l s='Tax ID (optional)' mod='simplyin'}">
                    <div class="error-message"></div>
                </div>
                {else}
                    <input type="hidden" id="nip" name="taxId" placeholder="{l s='Vat number' mod='simplyin'}" value="" disabled>
                {/if}
                <div class="pickup-details-header">{l s='Name the address' mod='simplyin'}</div>
                <div class="pickup-details-description">{l s='A personalized name will allow you to find or associate an address on your list more quickly.' mod='simplyin'}</div>
                <div class="form-group">
                    <input type="text" id="address" name="addressName" placeholder="{l s='Address name' mod='simplyin'}" value="{$address['addressName']|escape:'htmlall':'UTF-8'}" placeholder="{l s='Address name' mod='simplyin'}">
                    <div class="error-message"></div>
                </div>
        </div>
        <div class="popup-buttons-footer popup-buttons-footer-add-addres">
            <button type="button" class="popup-button simplyin-cancel">{l s='CANCEL' mod='simplyin'}</button>
            {if $address['_id'] == ''}
                <button type="submit" class="popup-button simplyin-submit">{l s='ADD' mod='simplyin'}</button>
            {else}
                <button type="submit" class="popup-button simplyin-submit">{l s='SAVE' mod='simplyin'}</button>
            {/if}
        </div>
    </form>
    </div>
</div>
