{% extends "ui/base-devices.html" %}
{% load url from future %}
{% load icons %}

{% block content %}
    {% if form %}
        <div class="well">
            <div class="row">
                <form class="form-inline choose-asset-form" method="POST">
                    {% csrf_token %}
                    <div class="span3"><p class="choose-asset-label">
                        Select {% if asset %}new {% endif %}asset (by sn, barcode or model)
                    </p></div>
                    <div class="span2 control-group {% if form.asset.errors %}error{% endif %}">
                        {{ form.asset }}
                        {% if form.asset.errors %}
                            <span class="help-inline">
                                {% for error in form.asset.errors %}
                                    {{ error }}&nbsp;
                                {% endfor %}
                            </span>
                        {% endif %}
                    </div>
                    <div class="span2">
                        <button type="submit" class="btn btn-primary">{% icon 'fugue-tick' %}&nbsp;Save</button>
                    </div>
                </form>
            </div>
        </div>
    {% endif %}
    {% if asset %}
        <div class="row-fluid">
            <div class="span6">
                <h3>Base info</h3>
                <table class="table table-striped table-bordered table-condensed">
                    {% include 'ui/device_asset_property.html' with name='SN' value=asset.sn %}
                    {% include 'ui/device_asset_property.html' with name='Barcode' value=asset.barcode %}
                    {% include 'ui/device_asset_property.html' with name='Status' value=asset.status %}
                    {% include 'ui/device_asset_property.html' with name='Production use date' value=asset.production_use_date %}
                    {% include 'ui/device_asset_property.html' with name='Category' value=asset.category %}
                    {% include 'ui/device_asset_property.html' with name='Remarks' value=asset.remarks %}
                </table>
                <h3>Hardware</h3>
                <table class="table table-striped table-bordered table-condensed">
                    {% include 'ui/device_asset_property.html' with name='Manufacturer' value=asset.manufacturer %}
                    {% include 'ui/device_asset_property.html' with name='Model' value=asset.model %}
                    {% include 'ui/device_asset_property.html' with name='Slots (for blade centers)' value=asset.slots %}
                    {% include 'ui/device_asset_property.html' with name='Size in units' value=asset.size %}
                </table>
                <h3>Location</h3>
                <table class="table table-striped table-bordered table-condensed">
                    {% include 'ui/device_asset_property.html' with name='Warehouse' value=asset.warehouse %}
                    {% include 'ui/device_asset_property.html' with name='U level' value=asset.u_level %}
                    {% include 'ui/device_asset_property.html' with name='U height' value=asset.u_height %}
                </table>
            </div>
            <div class="span6">
                <h3>Accounting data</h3>
                <table class="table table-striped table-bordered table-condensed">
                    {% include 'ui/device_asset_property.html' with name='Invoice no' value=asset.invoice_no %}
                    {% include 'ui/device_asset_property.html' with name='Order no' value=asset.order_no %}
                    {% include 'ui/device_asset_property.html' with name='Niw' value=asset.niw %}
                    {% include 'ui/device_asset_property.html' with name='Source' value=asset.source %}
                    {% include 'ui/device_asset_property.html' with name='Price' value=asset.price %}
                    {% include 'ui/device_asset_property.html' with name='Support price' value=asset.support_price %}
                    {% include 'ui/device_asset_property.html' with name='Support type' value=asset.support_type %}
                    {% include 'ui/device_asset_property.html' with name='Support period in months' value=asset.support_period %}
                    {% include 'ui/device_asset_property.html' with name='Support void reporting' value=asset.support_void_reporting bool_value=1 %}
                    {% include 'ui/device_asset_property.html' with name='Provider' value=asset.provider %}
                    {% include 'ui/device_asset_property.html' with name='Request date' value=asset.request_date %}
                    {% include 'ui/device_asset_property.html' with name='Provider order date' value=asset.provider_order_date %}
                    {% include 'ui/device_asset_property.html' with name='Delivery date' value=asset.delivery_date %}
                    {% include 'ui/device_asset_property.html' with name='Invoice date' value=asset.invoice_date %}
                    {% include 'ui/device_asset_property.html' with name='Deprecation rate' value=asset.deprecation_rate %}
                    {% include 'ui/device_asset_property.html' with name='Deprecated' value=asset.is_deprecated bool_value=1 %}
                </table>
            </div>
        </div>
        <div class="row-fluid">
            <a href="/assets/dc/edit/device/{{ asset.asset_id }}" class="btn btn-primary">{% icon 'fugue-briefcase--pencil' %}&nbsp;Edit this asset</a>
        </div>
    {% else %}
        <div class="alert alert-info">
            This device doesn't have asset.
        </div>
    {% endif %}
{% endblock content %}

