{% extends "base.html" %}

{% load static %}

{% block page_title %}
InvenTree | Supplier List 
{% endblock %}

{% block content %}

<h3>Supplier List</h3>
<hr>

<div id='button-toolbar'>
    <div class='btn-group'>
        <button type='button' class="btn btn-success" id='new-company' title='Add new supplier'>New Supplier</button>
    </div>
</div>


<table class='table table-striped' id='company-table' data-toolbar='#button-toolbar'>
</table>

{% endblock %}
{% block js_ready %}
{{ block.super }}
    $('#new-company').click(function () {
        launchModalForm(
                        "{% url 'company-create' %}",
                        {
                            follow: true
                        });
    });

    $("#company-table").bootstrapTable({
        sortable: true,
        search: true,
        pagination: true,
        pageSize: 50,
        formatNoMatches: function() { return "No company information found"; },
        columns: [
            {
                field: 'pk',
                title: 'ID',
                visible: false,
            },
            {
                field: 'name',
                title: 'Supplier',
                sortable: true,
                formatter: function(value, row, index, field) {
                    return imageHoverIcon(row.image) + renderLink(value, row.url);
                }
            },
            {
                field: 'description',
                title: 'Description',
            },
            {
                field: 'website',
                title: 'Website',
                formatter: function(value, row, index, field) {
                    if (value) {
                        return renderLink(value, value);
                    }
                    return '';
                }
            },
            {
                field: 'part_count',
                title: 'Parts',
                formatter: function(value, row, index, field) {
                    return renderLink(value, row.url + 'parts/');
                }
            },
        ],
        url: "{% url 'api-company-list' %}"
    });

{% endblock %}