{% extends "company/company_base.html" %}
{% load static %}
{% load i18n %}

{% block details %}

{% include "company/tabs.html" with tab='stock' %}

<h4>{% trans "Supplier Stock" %}</h4>

<hr>

{% include "stock_table.html" %}

{% endblock %}
{% block js_ready %}
{{ block.super }}

    loadStockTable($('#stock-table'), {
        url: "{% url 'api-stock-list' %}",
        params: {
            company: {{ company.id }},
            part_detail: true,
            supplier_detail: true,
            location_detail: true,
        },
        buttons: [
            '#stock-options',
        ],
        filterKey: "companystock",
    });

    $("#stock-export").click(function() {
        launchModalForm("{% url 'stock-export-options' %}", {
            submit_text: '{% trans "Export" %}',
            success: function(response) {
                var url = "{% url 'stock-export' %}";

                url += "?format=" + response.format;
                url += "&supplier={{ company.id }}";

                location.href = url;
            },
        });
    });

{% endblock %}