{% extends "company/company_base.html" %} {% load static %} {% load i18n %} {% load markdownify %} {% block menubar %} {% include 'company/navbar.html' with tab='details' %} {% endblock %} {% block page_content %}

{% trans "Supplier Parts" %}

{% if roles.purchase_order.change %}
{% if roles.purchase_order.add %} {% endif %}
{% endif %}

{% trans "Manufacturer Parts" %}

{% if roles.purchase_order.change %}
{% if roles.purchase_order.add %} {% endif %}
{% endif %}

{% trans "Supplier Stock" %}

{% include "stock_table.html" %}

{% trans "Purchase Orders" %}

{% if roles.purchase_order.add %}
{% endif %}

{% trans "Sales Orders" %}

{% if roles.sales_order.add %}
{% endif %}

{% trans "Assigned Stock" %}

{% trans "Company Notes" %}

{% if company.notes %} {{ company.notes | markdownify }} {% endif %}
{% endblock %} {% block js_ready %} {{ block.super }} $('#edit-notes').click(function() { constructForm('{% url "api-company-detail" company.pk %}', { fields: { notes: { multiline: true, } }, title: '{% trans "Edit Notes" %}', reload: true, }); }); loadStockTable($("#assigned-stock-table"), { params: { customer: {{ company.id }}, part_detail: true, location_detail: true, }, url: "{% url 'api-stock-list' %}", filterKey: "customerstock", }); {% if company.is_customer %} loadSalesOrderTable("#sales-order-table", { url: "{% url 'api-so-list' %}", params: { customer: {{ company.id }}, } }); $("#new-sales-order").click(function() { createSalesOrder({ customer: {{ company.pk }}, }); }); {% endif %} {% if company.is_supplier %} loadPurchaseOrderTable("#purchase-order-table", { url: "{% url 'api-po-list' %}", params: { supplier: {{ company.id }}, } }); function newOrder() { createPurchaseOrder({ supplier: {{ company.pk }}, }); } $("#company-order").click(function() { newOrder(); }); $("#company-order2").click(function() { newOrder(); }); {% endif %} loadStockTable($('#stock-table'), { url: "{% url 'api-stock-list' %}", params: { company: {{ company.id }}, part_detail: true, supplier_part_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; }, }); }); {% if company.is_manufacturer %} $("#manufacturer-part-create").click(function () { constructForm('{% url "api-manufacturer-part-list" %}', { fields: { part: {}, manufacturer: { value: {{ company.pk }}, }, MPN: { icon: 'fa-hashtag', }, description: {}, link: { icon: 'fa-link', }, }, method: 'POST', title: '{% trans "Add Manufacturer Part" %}', onSuccess: function() { $("#part-table").bootstrapTable("refresh"); } }); }); loadManufacturerPartTable( "#part-table", "{% url 'api-manufacturer-part-list' %}", { params: { part_detail: true, manufacturer_detail: true, manufacturer: {{ company.id }}, }, } ); linkButtonsToSelection($("#manufacturer-table"), ['#table-options']); $("#multi-part-delete").click(function() { var selections = $("#part-table").bootstrapTable("getSelections"); deleteManufacturerParts(selections, { onSuccess: function() { $("#part-table").bootstrapTable("refresh"); } }); }); $("#multi-part-order").click(function() { var selections = $("#part-table").bootstrapTable("getSelections"); var parts = []; selections.forEach(function(item) { parts.push(item.part); }); launchModalForm("/order/purchase-order/order-parts/", { data: { parts: parts, }, }); }); {% endif %} {% if company.is_supplier %} $("#supplier-part-create").click(function () { launchModalForm( "{% url 'supplier-part-create' %}", { data: { supplier: {{ company.id }}, }, reload: true, secondary: [ { field: 'part', label: '{% trans "New Part" %}', title: '{% trans "Create new Part" %}', url: "{% url 'part-create' %}" }, { field: 'supplier', label: "{% trans 'New Supplier' %}", title: "{% trans 'Create new Supplier' %}", }, ] }); }); loadSupplierPartTable( "#supplier-part-table", "{% url 'api-supplier-part-list' %}", { params: { part_detail: true, supplier_detail: true, manufacturer_detail: true, supplier: {{ company.id }}, }, } ); {% endif %} $("#multi-part-delete").click(function() { var selections = $("#part-table").bootstrapTable("getSelections"); var parts = []; selections.forEach(function(item) { parts.push(item.pk); }); var url = "{% url 'supplier-part-delete' %}" launchModalForm(url, { data: { parts: parts, }, reload: true, }); }); $("#multi-part-order").click(function() { var selections = $("#part-table").bootstrapTable("getSelections"); var parts = []; selections.forEach(function(item) { parts.push(item.part); }); launchModalForm("/order/purchase-order/order-parts/", { data: { parts: parts, }, }); }); attachNavCallbacks({ name: 'company', default: 'company-stock' }); {% endblock %}