{% extends "collapse.html" %}

{% load static %}
{% load inventree_extras %}

{% block collapse_panel_setup %}class='panel part-allocation' id='allocation-panel-{{ item.sub_part.id }}'{% endblock %}

{% block collapse_title %}
    {% include "hover_image.html" with image=item.sub_part.image hover=false %}
    <div>
        {{ item.sub_part.full_name }}
        <small><i>{{ item.sub_part.description }}</i></small>
    </div>
{% endblock %}

{% block collapse_heading %}
    <div class='col-sm-2'>
        <b>{{ item.sub_part.total_stock }}</b>
    </div>
    <div class='col-sm-2'>
        <b>{% multiply build.quantity item.quantity %}</b>
    </div>
    <div class='col-sm-2'>
        <b><span id='allocation-total-{{ item.sub_part.id }}'>{% part_allocation_count build item.sub_part %}</span></b>
        <div class='btn-group' style='float: right;'>
            <button class='btn btn-success btn-sm' title='Allocate stock for {{ item.sub_part}}' id='new-item-{{ item.sub_part.id }}' url="{% url 'build-item-create' %}?part={{ item.sub_part.id }}&build={{ build.id }}">Allocate</button>
        </div>
</div>
{% endblock %}

{% block collapse_content %}
<table class='table table-striped table-condensed' id='allocate-table-id-{{ item.sub_part.id }}'>
</table>
{% endblock %}