diff --git a/InvenTree/company/templates/company/assigned_stock.html b/InvenTree/company/templates/company/assigned_stock.html deleted file mode 100644 index d64719407b..0000000000 --- a/InvenTree/company/templates/company/assigned_stock.html +++ /dev/null @@ -1,38 +0,0 @@ -{% extends "company/company_base.html" %} -{% load static %} -{% load i18n %} - -{% block menubar %} -{% include "company/navbar.html" with tab="assigned" %} -{% endblock %} - -{% block heading %} -{% trans "Assigned Stock" %} -{% endblock %} - -{% block details %} - -
-
- -
-
- -
- -{% endblock %} - -{% block js_ready %} -{{ block.super }} - -loadStockTable($("#stock-table"), { - params: { - customer: {{ company.id }}, - part_detail: true, - location_detail: true, - }, - url: "{% url 'api-stock-list' %}", - filterKey: "customerstock", -}); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/company_base.html b/InvenTree/company/templates/company/company_base.html index 8c6b077137..3b8f1e7734 100644 --- a/InvenTree/company/templates/company/company_base.html +++ b/InvenTree/company/templates/company/company_base.html @@ -71,6 +71,17 @@ {{ company.website }}{% include "clip.html"%} {% endif %} + + + {% trans "Currency" %} + + {% if company.currency %} + {{ company.currency }} + {% else %} + {% trans "Uses default currency" %} + {% endif %} + + {% if company.address %} @@ -99,6 +110,22 @@ {{ company.contact }}{% include "clip.html"%} {% endif %} + + + + {%trans "Manufacturer" %} + {% include "yesnolabel.html" with value=company.is_manufacturer %} + + + + {% trans "Supplier" %} + {% include 'yesnolabel.html' with value=company.is_supplier %} + + + + {% trans "Customer" %} + {% include 'yesnolabel.html' with value=company.is_customer %} + {% endblock %} diff --git a/InvenTree/company/templates/company/detail.html b/InvenTree/company/templates/company/detail.html index 9c3cbfb84a..48f9d9895b 100644 --- a/InvenTree/company/templates/company/detail.html +++ b/InvenTree/company/templates/company/detail.html @@ -1,79 +1,430 @@ {% extends "company/company_base.html" %} {% load static %} {% load i18n %} +{% load markdownify %} {% block menubar %} {% include 'company/navbar.html' with tab='details' %} {% endblock %} -{% block heading %} -{% trans "Company Details" %} -{% endblock %} +{% block page_content %} -{% block details %} -
-
- - - - - - - - - {% if company.description %} - - - - - - {% endif %} - - - - - - - - - - +
+ +
+ +
+ +
+ + + {% endif %} + +
{% trans "Company Name" %}{{ company.name }}{% include "clip.html"%}
{% trans "Description" %}{{ company.description }}{% include "clip.html"%}
{% trans "Website" %} - {% if company.website %}{{ company.website }}{% include "clip.html"%} - {% else %}{% trans "No website specified" %} +
+
+

{% trans "Supplier Parts" %}

+
+
+ {% if roles.purchase_order.change %} +
+
+
+ {% if roles.purchase_order.add %} + {% endif %} -
{% trans "Currency" %} - {% if company.currency %}{{ company.currency }} - {% else %}{% trans "Uses default currency" %} - {% endif %} -
-
- - - - - - - - - - - - - - - - - - -
{% trans "Manufacturer" %}{% include "yesnolabel.html" with value=company.is_manufacturer %}
{% trans "Supplier" %}{% include 'yesnolabel.html' with value=company.is_supplier %}
{% trans "Customer" %}{% include 'yesnolabel.html' with value=company.is_customer %}
+
+
+
+

{% 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" %}

+
+
+
+ +
+
+
+
+
+ {{ company.notes | markdownify }}
{% 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( + "#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({ + panelClass: 'company', + default: 'company-stock' + }); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/detail_manufacturer_part.html b/InvenTree/company/templates/company/detail_manufacturer_part.html deleted file mode 100644 index 0ff261ec67..0000000000 --- a/InvenTree/company/templates/company/detail_manufacturer_part.html +++ /dev/null @@ -1,119 +0,0 @@ -{% extends "company/company_base.html" %} -{% load static %} -{% load i18n %} -{% load inventree_extras %} - -{% block menubar %} -{% include 'company/navbar.html' with tab='manufacturer_parts' %} -{% endblock %} - -{% block heading %} -{% trans "Manufacturer Parts" %} -{% endblock %} - - -{% block details %} - -{% if roles.purchase_order.change %} -
-
-
- {% if roles.purchase_order.add %} - - {% endif %} -
- -
-
-
- -
-
-
-{% endif %} - -
- -{% endblock %} -{% block js_ready %} -{{ block.super }} - - $("#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, - }, - }); - }); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/detail_stock.html b/InvenTree/company/templates/company/detail_stock.html deleted file mode 100644 index 87f88bb550..0000000000 --- a/InvenTree/company/templates/company/detail_stock.html +++ /dev/null @@ -1,49 +0,0 @@ -{% extends "company/company_base.html" %} -{% load static %} -{% load i18n %} - -{% block menubar %} -{% include "company/navbar.html" with tab='stock' %} -{% endblock %} - -{% block heading %} -{% trans "Supplier Stock" %} -{% endblock %} - -{% block details %} - -{% 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_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; - }, - }); - }); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/detail_supplier_part.html b/InvenTree/company/templates/company/detail_supplier_part.html deleted file mode 100644 index 7cf9b66a11..0000000000 --- a/InvenTree/company/templates/company/detail_supplier_part.html +++ /dev/null @@ -1,127 +0,0 @@ -{% extends "company/company_base.html" %} -{% load static %} -{% load i18n %} -{% load inventree_extras %} - -{% block menubar %} -{% include 'company/navbar.html' with tab='supplier_parts' %} -{% endblock %} - -{% block heading %} -{% trans "Supplier Parts" %} -{% endblock %} - - -{% block details %} -{% if roles.purchase_order.change %} -
-
-
- {% if roles.purchase_order.add %} - - {% endif %} -
- -
-
-
- -
-
-
-{% endif %} - - -
- -{% endblock %} -{% block js_ready %} -{{ block.super }} - - $("#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( - "#part-table", - "{% url 'api-supplier-part-list' %}", - { - params: { - part_detail: true, - supplier_detail: true, - manufacturer_detail: true, - supplier: {{ company.id }}, - }, - } - ); - - $("#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, - }, - }); - }); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/navbar.html b/InvenTree/company/templates/company/navbar.html index 715d448b0f..025b1c6b4a 100644 --- a/InvenTree/company/templates/company/navbar.html +++ b/InvenTree/company/templates/company/navbar.html @@ -9,16 +9,9 @@ -
  • - - - {% trans "Details" %} - -
  • - {% if company.is_manufacturer %} -
  • - +
  • + {% trans "Manufactured Parts" %} @@ -26,8 +19,8 @@ {% endif %} {% if company.is_supplier or company.is_manufacturer %} -
  • - +
  • + {% trans "Supplied Parts" %} @@ -35,8 +28,8 @@ {% endif %} {% if company.is_manufacturer or company.is_supplier %} -
  • - +
  • + {% trans "Stock" %} @@ -44,8 +37,8 @@ {% endif %} {% if company.is_supplier %} -
  • - +
  • + {% trans "Purchase Orders" %} @@ -53,22 +46,22 @@ {% endif %} {% if company.is_customer %} -
  • - +
  • + {% trans "Sales Orders" %}
  • -
  • - +
  • + {% trans "Assigned Stock" %}
  • {% endif %} -
  • - +
  • + {% trans "Notes" %} diff --git a/InvenTree/company/templates/company/notes.html b/InvenTree/company/templates/company/notes.html deleted file mode 100644 index 6b0e65e2d0..0000000000 --- a/InvenTree/company/templates/company/notes.html +++ /dev/null @@ -1,47 +0,0 @@ -{% extends "company/company_base.html" %} -{% load static %} -{% load i18n %} -{% load markdownify %} - -{% block menubar %} -{% include 'company/navbar.html' with tab='notes' %} -{% endblock %} - -{% block heading %} -{% trans "Company Notes" %} -{% if not editing %} - -{% endif %} -{% endblock %} - -{% block details %} -{% if editing %} -
    - {% csrf_token %} - - {{ form }} -
    - - -
    - -{{ form.media }} - -{% else %} - -{{ company.notes | markdownify }} -{% endif %} - -{% endblock %} - -{% block js_ready %} -{{ block.super }} - -{% if editing %} -{% else %} -$("#edit-notes").click(function() { - location.href = "{% url 'company-notes' company.id %}?edit=1"; -}); -{% endif %} - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/purchase_orders.html b/InvenTree/company/templates/company/purchase_orders.html deleted file mode 100644 index f23d360a8f..0000000000 --- a/InvenTree/company/templates/company/purchase_orders.html +++ /dev/null @@ -1,56 +0,0 @@ -{% extends "company/company_base.html" %} -{% load static %} -{% load i18n %} - -{% block menubar %} -{% include 'company/navbar.html' with tab='po' %} -{% endblock %} - -{% block heading %} -{% trans "Purchase Orders" %} -{% endblock %} - -{% block details %} - -{% if roles.purchase_order.add %} -
    -
    - -
    - -
    -
    -
    -{% endif %} - - -
    - -{% endblock %} - -{% block js_ready %} -{{ block.super }} - - 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(); - }); - -{% endblock %} diff --git a/InvenTree/company/templates/company/sales_orders.html b/InvenTree/company/templates/company/sales_orders.html deleted file mode 100644 index c21a9afc21..0000000000 --- a/InvenTree/company/templates/company/sales_orders.html +++ /dev/null @@ -1,51 +0,0 @@ -{% extends "company/company_base.html" %} -{% load static %} -{% load i18n %} - - -{% block menubar %} -{% include 'company/navbar.html' with tab='so' %} -{% endblock %} - -{% block heading %} -{% trans "Sales Orders" %} -{% endblock %} - -{% block details %} - -{% if roles.sales_order.add %} -
    -
    - -
    - -
    -
    -
    -{% endif %} - - -
    - -{% endblock %} - -{% block js_ready %} -{{ block.super }} - - loadSalesOrderTable("#sales-order-table", { - url: "{% url 'api-so-list' %}", - params: { - customer: {{ company.id }}, - } - }); - - $("#new-sales-order").click(function() { - - createSalesOrder({ - customer: {{ company.pk }}, - }); - }); - -{% endblock %} \ No newline at end of file diff --git a/InvenTree/company/urls.py b/InvenTree/company/urls.py index e9e125d9e4..4f844176ee 100644 --- a/InvenTree/company/urls.py +++ b/InvenTree/company/urls.py @@ -8,15 +8,6 @@ from . import views company_detail_urls = [ - # url(r'orders/?', views.CompanyDetail.as_view(template_name='company/orders.html'), name='company-detail-orders'), - - url(r'^supplier-parts/', views.CompanyDetail.as_view(template_name='company/detail_supplier_part.html'), name='company-detail-supplier-parts'), - url(r'^manufacturer-parts/', views.CompanyDetail.as_view(template_name='company/detail_manufacturer_part.html'), name='company-detail-manufacturer-parts'), - url(r'^stock/', views.CompanyDetail.as_view(template_name='company/detail_stock.html'), name='company-detail-stock'), - url(r'^purchase-orders/', views.CompanyDetail.as_view(template_name='company/purchase_orders.html'), name='company-detail-purchase-orders'), - url(r'^assigned-stock/', views.CompanyDetail.as_view(template_name='company/assigned_stock.html'), name='company-detail-assigned-stock'), - url(r'^sales-orders/', views.CompanyDetail.as_view(template_name='company/sales_orders.html'), name='company-detail-sales-orders'), - url(r'^notes/', views.CompanyNotes.as_view(), name='company-notes'), url(r'^thumb-download/', views.CompanyImageDownloadFromURL.as_view(), name='company-image-download'), diff --git a/InvenTree/company/views.py b/InvenTree/company/views.py index 03fe03d411..ab6344e810 100644 --- a/InvenTree/company/views.py +++ b/InvenTree/company/views.py @@ -7,7 +7,7 @@ Django views for interacting with Company app from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ -from django.views.generic import DetailView, ListView, UpdateView +from django.views.generic import DetailView, ListView from django.urls import reverse from django.forms import HiddenInput @@ -113,28 +113,6 @@ class CompanyIndex(InvenTreeRoleMixin, ListView): return queryset -class CompanyNotes(UpdateView): - """ View for editing the 'notes' field of a Company object. - """ - - context_object_name = 'company' - template_name = 'company/notes.html' - model = Company - fields = ['notes'] - permission_required = 'company.view_company' - - def get_success_url(self): - return reverse('company-notes', kwargs={'pk': self.get_object().id}) - - def get_context_data(self, **kwargs): - - ctx = super().get_context_data(**kwargs) - - ctx['editing'] = str2bool(self.request.GET.get('edit', '')) - - return ctx - - class CompanyDetail(DetailView): """ Detail view for Company object """ context_obect_name = 'company' diff --git a/InvenTree/templates/js/nav.js b/InvenTree/templates/js/nav.js index ed0e1dcc31..e8207f9251 100644 --- a/InvenTree/templates/js/nav.js +++ b/InvenTree/templates/js/nav.js @@ -36,15 +36,38 @@ function activatePanel(panelName, options={}) { var panelClass = options.name || 'unknown'; - // Save the selected panel - localStorage.setItem(`inventree-selected-panel-${panelClass}`, panelName); - // First, cause any other panels to "fade out" $('.panel-visible').hide(); $('.panel-visible').removeClass('panel-visible'); - + // Find the target panel var panel = `#panel-${panelName}`; + var select = `#select-${panelName}`; + + // Check that the selected panel (and select) exist + if ($(panel).length && $(select).length) { + // Yep, both are displayed + } else { + // Either the select or the panel are not displayed! + // Iterate through the available 'select' elements until one matches + panelName = null; + + console.log("no match for panel:", panelName); + + $('.nav-toggle').each(function(item) { + var panel_name = $(this).attr('id').replace('select-', ''); + + console.log("checking:", panel_name); + + if ($(`#panel-${panel_name}`).length && (panelName == null)) { + console.log("found match -", panel_name); + panelName = panel_name; + } + }); + } + + // Save the selected panel + localStorage.setItem(`inventree-selected-panel-${panelClass}`, panelName); // Display the panel $(panel).addClass('panel-visible');