{% extends 'detail.html.j2' %}

{% load json %}
{% load markdown %}


{% block tabs %}
<form action="" method="post">
  {% csrf_token %}

<div id="details" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.details %}

</div>


<div id="versions" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.versions %}

    <table>
        <thead>
            <th>Version</th>
            <th>Installations</th>
            <th>Vulnerable</th>
            <th>&nbsp;</th>
        </thead>
        {% for version in operating_system_versions %}
        <tr>
            <td><a href="{% url 'ITAM:_operating_system_version_view' operating_system_id=operating_system.id pk=version.id %}">{{ version.name }}</a></td>
            <td>{% if version.installs == 0%}-{% else %}{{ version.installs }}{% endif %}</td>
            <td>&nbsp;</td>
            <td><a href="{% url 'ITAM:_operating_system_version_delete' operating_system_id=operating_system.id pk=version.id %}">DELETE</a></td>
        </tr>
        {% endfor %}
    </table>

</div>


<div id="licences" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.licences %}

    {% include 'icons/issue_link.html.j2' with issue=4 %}

    <table>
        <thead>
            <th>Name</th>
            <th>Type</th>
            <th>Available</th>
            <th>&nbsp;</th>
        </thead>
        <tr>
            <td>GPL-3</td>
            <td>Open Source</td>
            <td>1 / 5</td>
            <th>&nbsp;</th>
        </tr>
        <tr>
            <td>MIT</td>
            <td>Open Source</td>
            <td>Unlimited</td>
            <th>&nbsp;</th>
        </tr>
        <tr>
            <td>Windows Device</td>
            <td>CAL</td>
            <td>11 / 15</td>
            <th>&nbsp;</th>
        </tr>
    </table>

</div>


<div id="installations" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.installations %}

    <table>
          <thead>
            <th>Device</th>
            <th>Organization</th>
            <th>Version</th>
            <th title="Date Software Installed">Installed</th>
            <th>&nbsp;</th>
        </thead>
        {% for install in installs %}
        <tr>
            <td><a href="{% url 'ITAM:_device_view' pk=install.device_id %}">{{ install.device }}</a></td>
            <td>{{ install.organization }}</td>
            <td>{{ install.version }}</td>
            <td>
            {% if install.installdate %}
              {{ install.installdate }}
            {% else %}
              -
            {% endif %}
            </td>
            <td>&nbsp;</td>
        </tr>
        {% endfor %}
    </table>

</div>

<div id="tickets" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.tickets %}

    <table>
        <thead>
          <th>Name</th>
          <th>Status</th>
          <th>&nbsp</th>
        </thead>
        {% if tickets %}
        {% for ticket in tickets %}
        <tr>
          <td>{% concat_strings "#" ticket.ticket.id as ticket_ref %}{{ ticket_ref | markdown | safe}}</td>
          <td>{% include 'core/ticket/badge_ticket_status.html.j2' with ticket_status_text=ticket.ticket.get_status_display ticket_status=ticket.ticket.get_status_display|ticket_status %}</td>
          <td>&nbsp;</td>
        </tr>
        {% endfor %}
        {% else %}
        <tr>
            <td colspan="3">No related tickets exist</td>
        </tr>
        {% endif %}
    </table>

</div>

<div id="notes" class="content-tab">

    {% include 'content/section.html.j2' with tab=form.tabs.notes %}

    {{ notes_form }}
    <input type="submit" name="{{notes_form.prefix}}" value="Submit" />
    <div class="comments">
      {% if notes %}
      {% for note in notes%}
      {% include 'note.html.j2' %}
      {% endfor %}
      {% endif %}
    </div>

</div>

</form>
{% endblock %}

