{#**
 * 2007-2019 PrestaShop and Contributors
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 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:
 * https://opensource.org/licenses/OSL-3.0
 * 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 https://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <contact@prestashop.com>
 * @copyright 2007-2019 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 *#}

<div class="card">
  <h3 class="card-header">
    <i class="material-icons">location_on</i>
    {{ 'Addresses'|trans({}, 'Admin.Global') }}

    <a href="{{ getAdminLink('AdminAddresses', true, {'id_customer': customerInformation.customerId.value, 'addaddress': 1}) }}"
       class="tooltip-link float-right"
       data-toggle="pstooltip"
       title=""
       data-placement="top"
       data-original-title="{{ 'Add'|trans({}, 'Admin.Actions') }}"
    >
      <i class="material-icons">add_circle</i>
    </a>
  </h3>

  <div class="card-body">
    {% if customerInformation.addressesInformation is not empty %}
      <table class="table">
        <thead>
          <tr>
            <th>{{ 'Company'|trans({}, 'Admin.Global') }}</th>
            <th>{{ 'Name'|trans({}, 'Admin.Global') }}</th>
            <th>{{ 'Address'|trans({}, 'Admin.Global') }}</th>
            <th>{{ 'Country'|trans({}, 'Admin.Global') }}</th>
            <th>{{ 'Phone number(s)'|trans({}, 'Admin.Orderscustomers.Feature') }}</th>
            <th class="text-right">{{ 'Actions'|trans({}, 'Admin.Global') }}</th>
          </tr>
        </thead>
        <tbody>
          {% for address in customerInformation.addressesInformation %}
            {% set addressEditUrl = getAdminLink('AdminAddresses', true, {'id_address': address.addressId, 'addaddress': 1, 'back': app.request.uri}) %}

            <tr>
              <td class="js-linkable-item cursor-pointer" data-linkable-href="{{ addressEditUrl }}">{{ address.company }}</td>
              <td class="js-linkable-item cursor-pointer" data-linkable-href="{{ addressEditUrl }}">{{ address.fullName }}</td>
              <td class="js-linkable-item cursor-pointer" data-linkable-href="{{ addressEditUrl }}">{{ address.fullAddress }}</td>
              <td class="js-linkable-item cursor-pointer" data-linkable-href="{{ addressEditUrl }}">{{ address.countryName }}</td>
              <td class="js-linkable-item cursor-pointer" data-linkable-href="{{ addressEditUrl }}">
                {% if address.phone %}
                  {{ address.phone }}
                  {% if address.phoneMobile is not empty %}
                    <br> {{ address.phoneMobile }}
                  {% endif %}
                {% elseif address.phoneMobile is not empty %}
                  {{ address.phoneMobile }}
                {% else %}
                  --
                {% endif %}
              </td>
              <td class="text-right">
                <div class="btn-group-action">
                  <div class="btn-group">
                    <a href="{{ addressEditUrl }}"
                       class="btn tooltip-link dropdown-item"
                       data-toggle="pstooltip"
                       data-placement="top"
                       data-original-title="{{ 'Edit'|trans({}, 'Admin.Actions') }}"
                    >
                      <i class="material-icons">edit</i>
                    </a>

                    <a class="btn btn-link dropdown-toggle dropdown-toggle-dots dropdown-toggle-split"
                       data-toggle="dropdown"
                       aria-haspopup="true"
                       aria-expanded="false"
                    ></a>

                    <div class="dropdown-menu dropdown-menu-right">
                      <a class="btn tooltip-link dropdown-item"
                         href="{{ getAdminLink('AdminAddresses', true, {'id_address': address.addressId, 'deleteaddress': 1, 'back': app.request.uri}) }}"
                      >
                        <i class="material-icons">delete</i>
                        {{ 'Delete'|trans({}, 'Admin.Actions') }}
                      </a>

                      {{ renderhook('displayAdminCustomersAddressesItemAction', {'id_address': address.addressId}) }}
                    </div>
                  </div>
                </div>
              </td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    {% else %}
      <p class="text-muted text-center mb-0">
        {{ '%firstname% %lastname% has not registered any addresses yet'|trans({'%firstname%': customerInformation.personalInformation.firstName, '%lastname%': customerInformation.personalInformation.lastName}, 'Admin.Orderscustomers.Feature') }}
      </p>
    {% endif %}
  </div>
</div>
