{% extends BASE_TEMPLATE %}

{% load staticfiles %}

{% block head-title %}Upload Parts{% endblock %}

{% block title %}
<link rel="stylesheet" type="text/css" href="{% static 'bom/style.css' %}" />
{% endblock %}

{% block menu %}
<li><a href="{% url 'bom:home' %}">Cancel</a></li>
{% endblock%}

{% block content %}
<h5>Upload Parts</h5>

<p>To batch add parts, upload a csv that contains at least three columns with the headers: <b>'part_class'</b>, <b>'description'</b>, and <b>'revision'</b> at a minimum. You may also specify a 'manufacturer_part_number' and a 'manufacturer'. If neither is specified the manufacturer_part_number will default to the generated part number, and the manufacturer will default to your organization.</i></p>
<form action="{% url 'bom:upload-parts' %}" method="post" enctype="multipart/form-data">
    {% csrf_token %}
    <div class="row">
        <div class="col s8 file-field input-field">
            <div class="green lighten-1 btn">
                <span>File</span>
                {{ form.file }}
            </div>
            <div class="file-path-wrapper">
                <input class="file-path validate" type="text" placeholder="Upload a file.">
                {{ form.file.errors }}
            </div>
        </div>
        <div class="col s1 input-field">
            <input class="green lighten-1 btn" type="submit" value="Upload"/>
        </div>
    </div>
</form>
<h5>Part Classes Available</h5>
<table>
    <thead>
        <th class="tighter text-normal">Code</th>
        <th class="tighter text-normal">Name</th>
        <th class="tighter text-normal">Description</th>
    </thead>
    {% for partclass in partclasses %}
    <tbody>
        <td class="tighter text-normal">{{ partclass.code }}</td>
        <td class="tighter text-normal">{{ partclass.name }}</td>
        <td class="tighter text-normal">{{ partclass.comment }}</td>
    </tbody>
    {% endfor %}
</table>
{% endblock %}