{% extends 'base.html' %}
{% block content %}
<div class="toolbar">
  <div>
    <h1>{{ t('software.all_installations') }}</h1>
    <p class="muted">{{ t('software.all_installations_help') }}</p>
  </div>
  <a class="button button-secondary" href="/software">{{ t('common.back') }}</a>
</div>

<section class="panel" data-software-selection>
  <div class="software-section-heading">
    <div>
      <h2>{{ t('software.detailed_list') }}</h2>
      <p class="muted">{{ t('software.table_filter_help') }}</p>
    </div>
    <span class="software-inventory-count">{{ software_entries|length }}</span>
  </div>
  <form method="post" action="/software/inventory/delete" data-software-delete-form data-confirm-template="{{ t('software.delete.confirm')|e }}" data-inventory-only-warning="{{ t('software.delete.inventory_only')|e }}" class="software-delete-toolbar">
    <input type="hidden" name="redirect_to" value="/software/installations">
    <span>{{ t('software.selected_count') }}: <strong data-software-selection-count>0</strong></span>
    <button type="submit" class="button button-danger" data-software-delete-button disabled>🗑 {{ t('software.delete.selected') }}</button>
  </form>
  <div class="table-scroll management-table-scroll software-dedicated-table">
    <table class="data-table" id="software-all-installations" data-storage-key="software-all-installations">
      <thead><tr>
        <th data-no-sort="1"><input type="checkbox" data-software-select-all aria-label="{{ t('software.select_all_visible')|e }}"></th>
        <th>{{ t('common.assets') }}</th>
        <th>{{ t('common.name') }}</th>
        <th>{{ t('about.version') }}</th>
        <th>{{ t('software.publisher') }}</th>
        <th>{{ t('software.architecture') }}</th>
        <th>{{ t('software.platform') }}</th>
        <th>{{ t('software.install_date') }}</th>
        <th>{{ t('software.last_seen') }}</th>
      </tr></thead>
      <tbody>
      {% for entry in software_entries %}
        <tr>
          <td><input type="checkbox" value="{{ entry.id }}" data-software-entry-checkbox aria-label="{{ t('software.select_entry', name=entry.name)|e }}"></td>
          <td><a href="/assets/{{ entry.asset_id }}?inventory_tab=software">{{ entry.asset_name }}</a></td>
          <td>{{ entry.name }}</td>
          <td>{{ entry.version or '' }}</td>
          <td>{{ entry.publisher or '' }}</td>
          <td>{{ entry.architecture or '' }}</td>
          <td>{{ t('software.platform.' ~ (entry.platform or 'unknown'), entry.platform or 'unknown') }}</td>
          <td data-sort-value="{{ entry.install_date or '' }}">{{ entry.install_date or '' }}</td>
          <td data-sort-value="{{ entry.last_seen_at.isoformat() if entry.last_seen_at else '' }}">{% if entry.last_seen_at %}<time class="local-time" datetime="{{ utc_iso(entry.last_seen_at) }}" data-utc="{{ utc_iso(entry.last_seen_at) }}">{{ entry.last_seen_at }}</time>{% else %}{{ '' }}{% endif %}</td>
        </tr>
      {% else %}
        <tr><td colspan="9">{{ t('software.no_global_inventory') }}</td></tr>
      {% endfor %}
      </tbody>
    </table>
  </div>
</section>
{% endblock %}
