Updated company templates

This commit is contained in:
eeintech 2021-03-24 12:08:45 -04:00
parent afd2dacfc7
commit 4abd8587ab
4 changed files with 76 additions and 17 deletions

View File

@ -51,12 +51,12 @@
<col width='25'> <col width='25'>
<col> <col>
<tr> <tr>
<td><span class='fas fa-industry'></span></td> <td><span class='fas fa-building'></span></td>
<td>{% trans "Manufacturer" %}</td> <td>{% trans "Manufacturer" %}</td>
<td>{% include "yesnolabel.html" with value=company.is_manufacturer %}</td> <td>{% include "yesnolabel.html" with value=company.is_manufacturer %}</td>
</tr> </tr>
<tr> <tr>
<td><span class='fas fa-building'></span></td> <td><span class='fas fa-warehouse'></span></td>
<td>{% trans "Supplier" %}</td> <td>{% trans "Supplier" %}</td>
<td>{% include 'yesnolabel.html' with value=company.is_supplier %}</td> <td>{% include 'yesnolabel.html' with value=company.is_supplier %}</td>
</tr> </tr>

View File

@ -17,9 +17,16 @@
<div class='button-toolbar container-fluid'> <div class='button-toolbar container-fluid'>
<div class='btn-group role='group'> <div class='btn-group role='group'>
{% if roles.purchase_order.add %} {% if roles.purchase_order.add %}
<button class="btn btn-success" id='part-create' title='{% trans "Create new supplier part" %}'> {% if company.is_manufacturer %}
<span class='fas fa-plus-circle'></span> {% trans "New Supplier Part" %} <button class="btn btn-success" id='manufacturer-part-create' title='{% trans "Create new manufacturer part" %}'>
</button> <span class='fas fa-plus-circle'></span> {% trans "New Manufacturer Part" %}
</button>
{% endif %}
{% if company.is_supplier %}
<button class="btn btn-success" id='supplier-part-create' title='{% trans "Create new supplier part" %}'>
<span class='fas fa-plus-circle'></span> {% trans "New Supplier Part" %}
</button>
{% endif %}
{% endif %} {% endif %}
<div class='btn-group'> <div class='btn-group'>
<div class="dropdown" style="float: right;"> <div class="dropdown" style="float: right;">
@ -51,13 +58,37 @@
{% block js_ready %} {% block js_ready %}
{{ block.super }} {{ block.super }}
$("#part-create").click(function () { $("#manufacturer-part-create").click(function () {
launchModalForm(
"{% url 'manufacturer-part-create' %}",
{
data: {
manufacturer: {{ company.id }},
},
reload: true,
secondary: [
{
field: 'part',
label: '{% trans "New Part" %}',
title: '{% trans "Create new Part" %}',
url: "{% url 'part-create' %}"
},
{
field: 'manufacturer',
label: '{% trans "New Manufacturer" %}',
title: '{% trans "Create new Manufacturer" %}',
url: "{% url 'manufacturer-create' %}",
},
]
});
});
$("#supplier-part-create").click(function () {
launchModalForm( launchModalForm(
"{% url 'supplier-part-create' %}", "{% url 'supplier-part-create' %}",
{ {
data: { data: {
{% if company.is_supplier %}supplier: {{ company.id }},{% endif %} supplier: {{ company.id }},
{% if company.is_manufacturer %}manufacturer: {{ company.id }},{% endif %}
}, },
reload: true, reload: true,
secondary: [ secondary: [
@ -73,16 +104,25 @@
title: "{% trans 'Create new Supplier' %}", title: "{% trans 'Create new Supplier' %}",
url: "{% url 'supplier-create' %}", url: "{% url 'supplier-create' %}",
}, },
{
field: 'manufacturer',
label: '{% trans "New Manufacturer" %}',
title: '{% trans "Create new Manufacturer" %}',
url: "{% url 'manufacturer-create' %}",
},
] ]
}); });
}); });
{% if company.is_manufacturer %}
loadManufacturerPartTable(
"#part-table",
"{% url 'api-manufacturer-part-list' %}",
{
params: {
part_detail: true,
manufacturer_detail: true,
company: {{ company.id }},
},
}
);
{% endif %}
{% if company.is_supplier %}
loadSupplierPartTable( loadSupplierPartTable(
"#part-table", "#part-table",
"{% url 'api-supplier-part-list' %}", "{% url 'api-supplier-part-list' %}",
@ -95,6 +135,7 @@
}, },
} }
); );
{% endif %}
$("#multi-part-delete").click(function() { $("#multi-part-delete").click(function() {
var selections = $("#part-table").bootstrapTable("getSelections"); var selections = $("#part-table").bootstrapTable("getSelections");
@ -105,7 +146,14 @@
parts.push(item.pk); parts.push(item.pk);
}); });
launchModalForm("{% url 'supplier-part-delete' %}", { {% if company.is_manufacturer %}
var url = "{% url 'manufacturer-part-delete' %}"
{% endif %}
{% if company.is_supplier %}
var url = "{% url 'supplier-part-delete' %}"
{% endif %}
launchModalForm(url, {
data: { data: {
parts: parts, parts: parts,
}, },

View File

@ -16,14 +16,25 @@
</a> </a>
</li> </li>
{% if company.is_supplier or company.is_manufacturer %} {% if company.is_manufacturer %}
<li class='list-group-item {% if tab == "parts" %}active{% endif %}' title='{% trans "Manufactured Parts" %}'>
<a href='{% url "company-detail-parts" company.id %}'>
<span class='fas fa-shapes'></span>
{% trans "Parts" %}
</a>
</li>
{% endif %}
{% if company.is_supplier %}
<li class='list-group-item {% if tab == "parts" %}active{% endif %}' title='{% trans "Supplied Parts" %}'> <li class='list-group-item {% if tab == "parts" %}active{% endif %}' title='{% trans "Supplied Parts" %}'>
<a href='{% url "company-detail-parts" company.id %}'> <a href='{% url "company-detail-parts" company.id %}'>
<span class='fas fa-shapes'></span> <span class='fas fa-shapes'></span>
{% trans "Parts" %} {% trans "Parts" %}
</a> </a>
</li> </li>
{% endif %}
{% if company.is_manufacturer or company.is_supplier %}
<li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Stock Items" %}'> <li class='list-group-item {% if tab == "stock" %}active{% endif %}' title='{% trans "Stock Items" %}'>
<a href='{% url "company-detail-stock" company.id %}'> <a href='{% url "company-detail-stock" company.id %}'>
<span class='fas fa-boxes'></span> <span class='fas fa-boxes'></span>

View File

@ -352,7 +352,7 @@ class ManufacturerPartEdit(AjaxUpdateView):
model = ManufacturerPart model = ManufacturerPart
context_object_name = 'part' context_object_name = 'part'
form_class = EditSupplierPartForm form_class = EditManufacturerPartForm
ajax_template_name = 'modal_form.html' ajax_template_name = 'modal_form.html'
ajax_form_title = _('Edit Manufacturer Part') ajax_form_title = _('Edit Manufacturer Part')