<ul class="nav nav-tabs">
    <li{% ifequal tab 'detail' %} class="active"{% endifequal %}>
        <a href="{% url 'part-detail' part.id %}">Details</a>
    </li>
    <li{% ifequal tab 'params' %} class='active'{% endifequal %}>
        <a href="{% url 'part-params' part.id %}">Parameters <span class='badge'>{{ part.parameters.count }}</span></a>
    </li>
    {% if part.is_template %}
    <li{% ifequal tab 'variants' %} class='active'{% endifequal %}>
        <a href="{% url 'part-variants' part.id %}">Variants <span class='badge'>{{ part.variants.count }}</span></span></a>
    </li>
    {% endif %}
    <li{% ifequal tab 'stock' %} class="active"{% endifequal %}>
        <a href="{% url 'part-stock' part.id %}">Stock <span class="badge">{{ part.total_stock }}</span></a>
    </li>
    {% if part.allocation_count > 0 %}
    <li{% ifequal tab 'allocation' %} class="active"{% endifequal %}>
        <a href="{% url 'part-allocation' part.id %}">Allocated <span class="badge">{{ part.allocation_count }}</span></a>
    </li>
    {% endif %}
    {% if part.assembly %}
    <li{% ifequal tab 'bom' %} class="active"{% endifequal %}>
        <a href="{% url 'part-bom' part.id %}">BOM<span class="badge{% if part.is_bom_valid == False %} badge-alert{% endif %}">{{ part.bom_count }}</span></a></li>
    <li{% ifequal tab 'build' %} class="active"{% endifequal %}>
        <a href="{% url 'part-build' part.id %}">Build<span class='badge'>{{ part.active_builds|length }}</span></a></li>
    {% endif %}
    {% if part.component or part.used_in_count > 0 %}
    <li{% ifequal tab 'used' %} class="active"{% endifequal %}>
        <a href="{% url 'part-used-in' part.id %}">Used In{% if part.used_in_count > 0 %}<span class="badge">{{ part.used_in_count }}</span>{% endif %}</a></li>
    {% endif %}
    {% if part.purchaseable %}
    {% if part.is_template == False %}
    <li{% ifequal tab 'suppliers' %} class="active"{% endifequal %}>
        <a href="{% url 'part-suppliers' part.id %}">Suppliers
            <span class="badge">{{ part.supplier_count }}</span>
        </a>
    </li>
    {% endif %}
    <li{% ifequal tab 'orders' %} class='active'{% endifequal %}>
        <a href="{% url 'part-orders' part.id %}">Purchase Orders <span class='badge'>{{ part.purchase_orders|length }}</span></a>
    </li>
    {% endif %}
    {% if part.trackable and 0 %}
    <li{% ifequal tab 'track' %} class="active"{% endifequal %}>
        <a href="{% url 'part-track' part.id %}">Tracking
        {% if parts.serials.all|length > 0 %}
        <span class="badge">{{ part.serials.all|length }}</span>
        {% endif %}
    </a></li>
    {% endif %}
    <li{% ifequal tab 'attachments' %} class="active"{% endifequal %}>
        <a href="{% url 'part-attachments' part.id %}">Attachments {% if part.attachment_count > 0 %}<span class="badge">{{ part.attachment_count }}</span>{% endif %}</a>
    </li>
</ul>