{*
* 2007-2024 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-2024 PrestaShop SA
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
<div class="col-xs-12 text-xs-right mb-1">
    <a class="ag-cur-pointer btn btn-primary" href="{$link->getModuleLink(
            'agilemultisellerpro',
            'sellershipping',
            [
                'id_location_carrier'=>0,
                'id_carrier_reference'=>$idCarrierReference
            ],
            true
        )|escape:'htmlall':'UTF-8'}">
        {l s='Add location' d='Modules.Agilemultisellerpro.Location'}
    </a>
</div>

<div class="table-responsive">
    <table class="table agile-table">
        <thead>
            <tr>
                <th>{l s='Location' d='Modules.Agilemultisellerpro.Location'}</th>
                <th>{l s='Address' d='Modules.Agilemultisellerpro.Location'}</th>
                <th>{l s='Zip / Postal code' d='Modules.Agilemultisellerpro.Location'}</th>
                <th>{l s='City' d='Modules.Agilemultisellerpro.Location'}</th>
                <th>{l s='Country' d='Modules.Agilemultisellerpro.Location'}</th>
                <th>{l s='Active' d='Modules.Agilemultisellerpro.Location'}</th>
                <th></th>
            </tr>
        </thead>

        <tbody>
            {if count($locations) > 0}
                {foreach $locations as $location}
                    <tr>
                        <td>{$location->getLocation()|truncate:50|escape:'htmlall':'UTF-8'}</td>
                        <td>{$location->getAddress1()|escape:'htmlall':'UTF-8'}</td>
                        <td>{$location->getPostcode()|escape:'htmlall':'UTF-8'}</td>
                        <td>{$location->getCity()|escape:'htmlall':'UTF-8'}</td>
                        <td>
                            {if isset($countries[$location->getIdCountry()])}
                                {$countries[$location->getIdCountry()]|escape:'htmlall':'UTF-8'}
                            {else}
                                ---
                            {/if}
                        </td>
                        <td>
                            {if $location->isActive()}
                                <a class="ag-cur-pointer" href="{$link->getModuleLink(
                                    'agilemultisellerpro',
                                    'sellershipping',
                                    [
                                        'id_location_carrier'=>$location->getIdLocationCarrier(), 'action'=>'inactive'
                                    ],
                                    true
                                )|escape:'htmlall':'UTF-8'}">
                                    <i class="material-icons btn-outline-success" aria-hidden="true">done</i>
                                </a>
                            {else}
                                <a class="ag-cur-pointer" href="{$link->getModuleLink(
                                    'agilemultisellerpro',
                                    'sellershipping',
                                    [
                                        'id_location_carrier'=>$location->getIdLocationCarrier(), 'action'=>'active'
                                    ],
                                    true
                                )|escape:'htmlall':'UTF-8'}">
                                    <i class="material-icons btn-outline-danger" aria-hidden="true">close</i>
                                </a>
                            {/if}
                        </td>
                        <td class="text-xs-center align-middle">
                            <a class="ag-cur-pointer" href="{$link->getModuleLink(
                                    'agilemultisellerpro',
                                    'sellershipping',
                                    [
                                        'id_location_carrier'=>$location->getIdLocationCarrier()
                                    ],
                                    true
                                )|escape:'htmlall':'UTF-8'}">
                                <i class="material-icons btn-outline-primary" aria-hidden="true">edit</i>
                            </a>
                            <a class="ag-cur-pointer" onclick="deleteLocation('{$link->getModuleLink(
                                    'agilemultisellerpro',
                                    'sellershipping',
                                    [
                                        'id_location_carrier'=>$location->getIdLocationCarrier(), 'action'=>'delete'
                                    ],
                                    true
                                )|escape:'htmlall':'UTF-8'}')">
                                <i class="material-icons btn-outline-danger" aria-hidden="true">delete</i>
                            </a>
                        </td>
                    </tr>
                {/foreach}
            {else}
                <tr>
                    <td colspan="7">
                        <p class="alert alert-warning">
                        {l s='No locations available' d='Modules.Agilemultisellerpro.Shipping'}
                        </p>
                    </td>
                </tr>
            {/if}
        </tbody>
    </table>
</div>

<div class="row p-0 p-md-1 ">
    <div class="col-xs-12 col-md-6 text-xs-center text-md-left pt-1">
        <a class="btn btn-link"
        href="{$sellerCarrierListUrl|escape:'htmlall':'UTF-8'}">
            <i class="icon-th-list"></i>{l s=' Back to carriers list' d='Modules.Agilemultisellerpro.Product'}
        </a>
    </div>
</div>
