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

{% block details %}

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

<h4>{% trans "Sales Orders" %}</h4>
<hr>

{% if roles.sales_order.add %}
<div id='button-bar'>
    <div class='button-toolbar container-fluid' style='float: right;'>
        <button class='btn btn-primary' type='button' id='new-sales-order' title='{% trans "Create new sales order" %}'>
            <div class='fas fa-plus-circle'></div> {% trans "New Sales Order" %}
        </button>
        <div class='filter-list' id='filter-list-salesorder'>
            <!-- Empty div -->
        </div>
    </div>
</div>
{% endif %}

<table class='table table-striped table-condensed po-table' id='sales-order-table' data-toolbar='#button-bar'>
</table>

{% endblock %}

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

    loadSalesOrderTable("#sales-order-table", {
        url: "{% url 'api-so-list' %}",
        params: {
            customer: {{ company.id }},
        }
    });

    $("#new-sales-order").click(function() {
        launchModalForm(
            "{% url 'so-create' %}",
            {
                data: {
                    customer: {{ company.id }},
                },
                follow: true,
            },
        );
    });

{% endblock %}