{% extends 'dcim/device.html' %}
{% load helpers %}

{% block title %}{{ device }} - Inventory{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-md-12">
            <form method="post">
                {% csrf_token %}
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <strong>Inventory Items</strong>
                    </div>
                    <table class="table table-hover table-condensed panel-body" id="hardware">
                        <thead>
                            <tr>
                                {% if perms.dcim.change_inventoryitem or perms.dcim.delete_inventoryitem %}
                                    <th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
                                {% endif %}
                                <th>Name</th>
                                <th>Manufacturer</th>
                                <th>Part ID</th>
                                <th>Serial Number</th>
                                <th>Asset Tag</th>
                                <th>Discovered</th>
                                <th>Description</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for item in inventory_items %}
                                {% with template_name='dcim/inc/inventoryitem.html' indent=0 %}
                                    {% include template_name %}
                                {% endwith %}
                            {% endfor %}
                        </tbody>
                    </table>
                    <div class="panel-footer noprint">
                        {% if inventory_items and perms.dcim.change_inventoryitem %}
                            <button type="submit" name="_rename" formaction="{% url 'dcim:inventoryitem_bulk_rename' %}?return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-warning btn-xs">
                                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
                            </button>
                            <button type="submit" name="_edit" formaction="{% url 'dcim:inventoryitem_bulk_edit' %}?device={{ device.pk }}&return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-warning btn-xs">
                                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Edit
                            </button>
                        {% endif %}
                        {% if inventory_items and perms.dcim.delete_inventoryitem %}
                            <button type="submit" name="_delete" formaction="{% url 'dcim:inventoryitem_bulk_delete' %}?return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-danger btn-xs">
                                <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
                            </button>
                        {% endif %}
                        {% if perms.dcim.add_inventoryitem %}
                            <div class="pull-right">
                                <a href="{% url 'dcim:inventoryitem_add' %}?device={{ device.pk }}&return_url={% url 'dcim:device_inventory' pk=device.pk %}" class="btn btn-primary btn-xs">
                                    <span class="fa fa-plus" aria-hidden="true"></span> Add Inventory Item
                                </a>
                            </div>
                        {% endif %}
                    </div>
                </div>
            </form>
        </div>
    </div>
{% endblock %}
