{#
/**
 * @file
 * Order template used on the admin order page.
 *
 * Available variables:
 * - attributes: HTML attributes for the wrapper.
 * - order: The rendered order fields.
 *   Use 'order' to print them all, or print a subset such as
 *   'order.order_number'. Use the following code to exclude the
 *   printing of a given field:
 *   @code
 *   {{ order|without('order_number') }}
 *   @endcode
 * - order_entity: The order entity.
 *
 * @ingroup themeable
 */
#}

{{ attach_library('commerce/admin-layout') }}
{% set order_state = order_entity.getState.getLabel %}

<div class="layout-order-admin layout-commerce-admin">
  <div class="layout-region layout-region--commerce-main">
    <div class="layout-region__content">
      {{ order.order_items }}
      {{ order.total_price }}

      {% if order.activity %}
        <h2>{% trans %}Order activity{% endtrans %}</h2>
        {{ order.activity }}
      {% endif %}
    </div>
  </div>
  <div class="layout-region layout-region--commerce-secondary">
    <div class="entity-meta">
      <div class="entity-meta__header">
        <h3 class="entity-meta__title">
          {{ order_state }}
        </h3>
        {% for key in ['completed', 'placed', 'changed'] %}
          {% if order[key] %}
            <div class="form-item">
              {{ order[key] }}
            </div>
          {% endif %}
        {% endfor %}
        {% if stores_count > 1 and order.store_id %}
          <div class="form-item">
            {{ order.store_id }}
          </div>
        {% endif %}
        {% if order.balance %}
          <div class="form-item">
            {{ order.balance }}
          </div>
        {% endif %}
        {# If the order has possible transitions, render the field for transition buttons. #}
        {% if order_entity.getState.getTransitions is not empty %}
          {{ order.state }}
        {% endif %}
      </div>
      <details open class="claro-details">
        <summary role="button" class="claro-details__summary">
          {{ 'Customer Information'|t }}
        </summary>
        <div class="details-wrapper claro-details__wrapper">
          {% for key in ['uid', 'mail', 'ip_address'] %}
            {% if order[key] %}
              <div class="form-item">
                {{ order[key] }}
              </div>
            {% endif %}
          {% endfor %}
        </div>
      </details>
      {% if order.billing_information %}
        <details open class="claro-details">
          <summary role="button" class="claro-details__summary">
            {{ 'Billing information'|t }}
          </summary>
          <div class="details-wrapper claro-details__wrapper">
            {{ order.billing_information }}
          </div>
        </details>
      {% endif %}
      {% if order.shipping_information %}
        <details open class="claro-details">
          <summary role="button" class="claro-details__summary">
            {{ 'Shipping information'|t }}
          </summary>
          <div class="details-wrapper claro-details__wrapper">
            {{ order.shipping_information }}
          </div>
        </details>
      {% endif %}
      {% if additional_order_fields %}
        <details open class="claro-details">
          <summary role="button" class="claro-details__summary">
            {{ 'Other'|t }}
          </summary>
          {# Show fields that are not shown elsewhere. #}
          <div class="details-wrapper claro-details__wrapper">
            {{ additional_order_fields }}
          </div>
        </details>
      {% endif %}
    </div>
  </div>
</div>
