{% extends "base.html" %}
{% load i18n %}
{% load translations %}
{% load static %}

{% block extra_script %}
{% if support.name != 'community' %}
<script id="zammad_form_script" defer data-cfasync="false" src="https://care.weblate.org/assets/form/form.js"></script>
<script defer data-cfasync="false" src="{% static 'zammad.js' %}{{ cache_param }}"></script>
{% endif %}
{% endblock %}

{% block breadcrumbs %}
<li><a href="{% url 'manage' %}">{% trans "Manage" %}</a></li>
{% endblock %}

{% block content %}

<div class="panel panel-default">
<div class="panel-heading">
  <h4 class="panel-title">
    {% documentation_icon 'admin/support' right=True %}
    {% trans "Weblate support status" %}
  </h4>
</div>
  <table class="table table-striped table-supportstatus">
  <tr>
  <th>{% trans "Weblate version" %}</th>
  <td colspan="3">
    {% if git_revision %}
      {{ version }} — <a href="{{ git_revision_link }}">{{ git_revision }}</a>
    {% elif git_revision_link %}
      <a href="{{ git_revision_link }}">{{ version }}</a>
    {% else %}
      {{ version }}
    {% endif %}
  </td>
  </tr>
  <tr>
  <th>{% trans "Support status" %}</th>
  <td colspan="3">
    <a href="" class="pull-right flip btn btn-link link-post" data-href="{% url 'manage-activate' %}" data-params='{"refresh":1}'>{% trans "Refresh support status" %}</a>
    {{ support.get_verbose }}
    {% if not support.in_limits %}
    <div class="alert alert-danger" role="alert">
      {% trans "Your Weblate is exceeding service limits. Please upgrade the subscription." %}
    </div>
    {% endif %}
  </td>
  </tr>
  {% if support.expiry %}
    {% with support.get_limits_details as limit_details %}
      {% if limit_details %}
        <tr>
        <th rowspan="{{ limit_details|length }}">{% trans "Support package limits" %}</th>
        {% for limit in limit_details %}
          {% if not forloop.first %}
            <tr>
          {% endif %}
          <td>{{ limit.name }}</td>
          {% include "billing/used.html" with max=limit.limit total=limit.limit used=limit.current %}
          </tr>
        {% endfor %}
      {% endif %}
    {% endwith %}
  <tr>
  <th>{% trans "Support expiry" %}</th>
  <td colspan="3">{{ support.expiry|naturaltime }}</td>
  </tr>
  {% endif %}
  {% if support.secret %}
  <tr>
  <th>{% trans "Discover Weblate" %}</th>
  <td colspan="3">
    <a href="https://weblate.org/discover/" class="btn btn-link pull-right flip">{% trans "Browse discovery" %}</a>
    {% if support.discoverable %}
      {% trans "Your Weblate is listed on weblate.org" %}
      <br />
      <a href="" class="btn btn-primary link-post" data-href="{% url 'manage-discovery' %}">{% trans "Disable discovery" %}</a>
      <a href="https://weblate.org/user/" class="btn btn-primary">{% trans "Manage your listing" %}</a>
    {% else %}
      {% trans "Your Weblate is not listed on weblate.org" %}
      <br />
      <a href="" class="btn btn-primary link-post" data-href="{% url 'manage-discovery' %}">{% trans "Enable discovery" %}</a>
    {% endif %}
  </td>
  </tr>
  {% endif %}
  </table>
  <div class="panel-footer">
  {% if support.secret %}
  <a href="https://weblate.org/user/" class="btn btn-primary">{% trans "Manage support package" %}</a>
  {% endif %}
  {% if support.name == 'community' %}
  <a href="https://weblate.org/support/" class="btn btn-primary">{% trans "Purchase support package" %}</a>
  <a href="https://weblate.org/donate/" class="btn btn-primary">{% trans "Donate to Weblate" %}</a>
  {% else %}
  <a href="mailto:support@weblate.org" id="support-form" data-fullname="{{ user.full_name }}" data-email="{{ user.email }}" class="btn btn-primary">{% trans "Get help" %}</a>
  {% endif %}
  </div>
</div>

{% include "manage/snippets/activation-form.html" %}

{% endblock %}
