<commit_before>{% extends 'layout/admin/base.html' %}
{% from 'macros/datetime.html' import render_date, render_datetime %}
{% from 'macros/icons.html' import render_icon %}
{% from 'macros/shop_admin.html' import render_main_tabs with context %}
{% from 'macros/shop_article_admin.html' import render_article_link %}
{% from 'macros/shop_order_admin.html' import render_order_payment_method, render_order_payment_state %}
{% from 'macros/user_admin.html' import render_user_avatar_20_and_link %}
{% set current_page = 'shop_admin.orders' %}
{% set current_page_party = order.party %}
{% set title = 'Bestellung ' ~ order.order_number %}

{% block before_body %}
{{ render_main_tabs(current_page, order.party) }}
{%- endblock %}

{% block body %}

  <nav class="breadcrumbs">
    <ol>
      <li>Bestellungen</li>
      <li><a href="{{ url_for('.index_for_party', party_id=order.party.id) }}">{{ order.party.title }}</a></li>
    </ol>
  </nav>
  <h1>{{ title }}</h1>

  <table class="index">
    <tr>
      <th>Zeitpunkt</th>
      <td>{{ render_datetime(order.created_at) }}</td>
    </tr>
    <tr>
      <th>Zahlungsart</th>
      <td>{{ render_order_payment_method(order.payment_method) }}</td>
    </tr>
    <tr>
      <th>Bezahlstatus</th>
      <td>
        {{ render_order_payment_state(order.payment_state) }}
        {%- if order.payment_state != PaymentState.canceled %}
        <div class="dropdown">
          <button class="dropdown-toggle">{{ render_icon('caret-down') }}</button>
          <ol>
            {%- if order.payment_state == PaymentState.open %}
            <li><a href="{{ url_for('.mark_as_paid_form', order_id=order.id) }}">{{ render_icon('success') }} als bezahlt markieren</a></li>
            {%- endif %}
            <li><a href="{{ url_for('.cancel_form', order_id=order.id) }}">{{ render_icon('disabled') }} stornieren</a></li>
          </ol>
        </div>
        {%- endif %}
      </td>
    </tr>
    {%- if order.payment_state == PaymentState.canceled %}
    <tr>
      <th>Begründung für<br>Stornierung</th>
      <td>{{ order.cancelation_reason|fallback }}</td>
    </tr>
    {%- endif %}
  </table>

  <h2>Aktivität</h2>
  <ol class="activity-stream">
    {%- for update in updates %}
    <li>
      <table class="activity-stream-item">
        <tr>
          <td><span class="icon-container">{{ render_icon('payment') }}</span></td>
          <td>
            <span class="user-link">{{ render_user_avatar_20_and_link(update.created_by) }}</span> hat den Bezahlstatus geändert:
            {{ render_order_payment_state(update.payment_state_from) }} → {{ render_order_payment_state(update.payment_state_to) }}
          </td>
          <td class="timestamp">{{ render_datetime(update.created_at) }}</td>
        </tr>
      </table>
    </li>
    {%- endfor %}
    <li>
      <table class="activity-stream-item">
        <tr>
          <td><span class="icon-container">{{ render_icon('add') }}</span></td>
          <td><span class="user-link">{{ render_user_avatar_20_and_link(order.placed_by) }}</span> hat die Bestellung <strong>{{ order.order_number }}</strong> aufgegeben.</td>
          <td class="timestamp">{{ render_datetime(order.created_at) }}</td>
        </tr>
      </table>
    </li>
  </ol>

  <h2>Auftraggeber/in</h2>
  <table class="index">
    <tr>
      <th>Benutzer</th>
      <td>{{ render_user_avatar_20_and_link(order.placed_by) }}</td>
    </tr>
    <tr>
      <th>Name</th>
      <td>{{ order.first_names }} {{ order.last_name }}</td>
    </tr>
    <tr>
      <th>Anschrift</th>
      <td>{{ order.street }}, {{ order.zip_code }} {{ order.city }}, {{ order.country }}</td>
    </tr>
    <tr>
      <th>E-Mail-Adresse</th>
      <td>{{ order.placed_by.email_address }}</td>
    </tr>
    <tr>
      <th>Geburtsdatum</th>
      <td>{{ render_date(order.date_of_birth, smart=False) }}</td>
    </tr>
  </table>

  <h2>Artikel</h2>
  <table class="index" style="margin: 0 auto;">
    <thead>
      <tr>
        <th>Anzahl</th>
        <th>Artikelnr.</th>
        <th>Beschreibung</th>
        <th>Stückpreis</th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <th colspan="3">Gesamtbetrag</th>
        <td class="number"><strong>{{ order.calculate_total_price()|format_euro_amount }}</strong></td>
      </tr>
    </tfoot>
    <tbody>
      {%- for item in order.items|sort(attribute='article_number') %}
      <tr>
        <td class="number">{{ item.quantity }}</td>
        <td class="nowrap">{{ render_article_link(item.article) }}</td>
        <td><strong>{{ item.description }}</strong></td>
        <td class="number">{{ item.price|format_euro_amount }}</td>
      </tr>
      {%- endfor %}
    </tbody>
  </table>

  <ol class="actions">
    <li><a href="{{ url_for('.export', order_id=order.id) }}" download="{{ order.order_number }}.xml">{{ render_icon('download') }} für Lexware exportieren<br><small>(Shopschnittstelle; als XML)</small></a></li><commit_msg>Modernize order export button<commit_after>{% extends 'layout/admin/base.html' %}
{% from 'macros/datetime.html' import render_date, render_datetime %}
{% from 'macros/icons.html' import render_icon %}
{% from 'macros/shop_admin.html' import render_main_tabs with context %}
{% from 'macros/shop_article_admin.html' import render_article_link %}
{% from 'macros/shop_order_admin.html' import render_order_payment_method, render_order_payment_state %}
{% from 'macros/user_admin.html' import render_user_avatar_20_and_link %}
{% set current_page = 'shop_admin.orders' %}
{% set current_page_party = order.party %}
{% set title = 'Bestellung ' ~ order.order_number %}

{% block before_body %}
{{ render_main_tabs(current_page, order.party) }}
{%- endblock %}

{% block body %}

  <nav class="breadcrumbs">
    <ol>
      <li>Bestellungen</li>
      <li><a href="{{ url_for('.index_for_party', party_id=order.party.id) }}">{{ order.party.title }}</a></li>
    </ol>
  </nav>
  <h1>{{ title }}</h1>

  <table class="index">
    <tr>
      <th>Zeitpunkt</th>
      <td>{{ render_datetime(order.created_at) }}</td>
    </tr>
    <tr>
      <th>Zahlungsart</th>
      <td>{{ render_order_payment_method(order.payment_method) }}</td>
    </tr>
    <tr>
      <th>Bezahlstatus</th>
      <td>
        {{ render_order_payment_state(order.payment_state) }}
        {%- if order.payment_state != PaymentState.canceled %}
        <div class="dropdown">
          <button class="dropdown-toggle">{{ render_icon('caret-down') }}</button>
          <ol>
            {%- if order.payment_state == PaymentState.open %}
            <li><a href="{{ url_for('.mark_as_paid_form', order_id=order.id) }}">{{ render_icon('success') }} als bezahlt markieren</a></li>
            {%- endif %}
            <li><a href="{{ url_for('.cancel_form', order_id=order.id) }}">{{ render_icon('disabled') }} stornieren</a></li>
          </ol>
        </div>
        {%- endif %}
      </td>
    </tr>
    {%- if order.payment_state == PaymentState.canceled %}
    <tr>
      <th>Begründung für<br>Stornierung</th>
      <td>{{ order.cancelation_reason|fallback }}</td>
    </tr>
    {%- endif %}
  </table>

  <h2>Aktivität</h2>
  <ol class="activity-stream">
    {%- for update in updates %}
    <li>
      <table class="activity-stream-item">
        <tr>
          <td><span class="icon-container">{{ render_icon('payment') }}</span></td>
          <td>
            <span class="user-link">{{ render_user_avatar_20_and_link(update.created_by) }}</span> hat den Bezahlstatus geändert:
            {{ render_order_payment_state(update.payment_state_from) }} → {{ render_order_payment_state(update.payment_state_to) }}
          </td>
          <td class="timestamp">{{ render_datetime(update.created_at) }}</td>
        </tr>
      </table>
    </li>
    {%- endfor %}
    <li>
      <table class="activity-stream-item">
        <tr>
          <td><span class="icon-container">{{ render_icon('add') }}</span></td>
          <td><span class="user-link">{{ render_user_avatar_20_and_link(order.placed_by) }}</span> hat die Bestellung <strong>{{ order.order_number }}</strong> aufgegeben.</td>
          <td class="timestamp">{{ render_datetime(order.created_at) }}</td>
        </tr>
      </table>
    </li>
  </ol>

  <h2>Auftraggeber/in</h2>
  <table class="index">
    <tr>
      <th>Benutzer</th>
      <td>{{ render_user_avatar_20_and_link(order.placed_by) }}</td>
    </tr>
    <tr>
      <th>Name</th>
      <td>{{ order.first_names }} {{ order.last_name }}</td>
    </tr>
    <tr>
      <th>Anschrift</th>
      <td>{{ order.street }}, {{ order.zip_code }} {{ order.city }}, {{ order.country }}</td>
    </tr>
    <tr>
      <th>E-Mail-Adresse</th>
      <td>{{ order.placed_by.email_address }}</td>
    </tr>
    <tr>
      <th>Geburtsdatum</th>
      <td>{{ render_date(order.date_of_birth, smart=False) }}</td>
    </tr>
  </table>

  <h2>Artikel</h2>
  <table class="index" style="margin: 0 auto;">
    <thead>
      <tr>
        <th>Anzahl</th>
        <th>Artikelnr.</th>
        <th>Beschreibung</th>
        <th>Stückpreis</th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <th colspan="3">Gesamtbetrag</th>
        <td class="number"><strong>{{ order.calculate_total_price()|format_euro_amount }}</strong></td>
      </tr>
    </tfoot>
    <tbody>
      {%- for item in order.items|sort(attribute='article_number') %}
      <tr>
        <td class="number">{{ item.quantity }}</td>
        <td class="nowrap">{{ render_article_link(item.article) }}</td>
        <td><strong>{{ item.description }}</strong></td>
        <td class="number">{{ item.price|format_euro_amount }}</td>
      </tr>
      {%- endfor %}
    </tbody>
  </table>

  <ol class="actions">
    <li><a href="{{ url_for('.export', order_id=order.id) }}" download="{{ order.order_number }}.xml">
      <div class="block-with-icon">
        <div class="icon">
          {{ render_icon('download') }}
        </div>
        <div class="body">
          für Lexware exportieren<br>
          <small>{{ 'Shopschnittstelle (als XML)'|dim }}</small>
        </div>
      </div>
    </a></li>
{'fraction_non_alphanumeric': 0.19787845742044216, 'fraction_numerical': 0.00356895013383563, 'mean_word_length': 2.896485129393588, 'pattern_counts': {'":': 0, '<': 355, '<?xml version=': 0, '>': 355, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5045411', 'n_tokens_mistral': 3684, 'n_tokens_neox': 3538, 'n_words': 599}