{% extends "page_base.html" %}
{% load static %}
{% load i18n %}
{% load inventree_extras %}
{% block page_title %}
{% inventree_title %} | {% trans "Manufacturer Part" %}
{% endblock %}
{% block sidebar %}
{% include "company/manufacturer_part_sidebar.html" %}
{% endblock sidebar %}
{% block breadcrumbs %}
{% trans "Manufacturers" %}
{% if part.manufacturer %}
{{ part.manufacturer.name }}
{% endif %}
{{ part.MPN }}
{% endblock breadcrumbs %}
{% block heading %}
{% trans "Manufacturer Part" %}: {{ part.part.full_name }}
{% endblock heading %}
{% block actions %}
{% if user.is_staff and perms.company.change_company %}
{% url 'admin:company_supplierpart_change' part.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
{% if roles.purchase_order.change %}
{% if roles.purchase_order.add and part.part.purchaseable %}
{% endif %}
{% if roles.purchase_order.delete %}
{% endif %}
{% endif %}
{% endblock actions %}
{% block thumbnail %}
{% endblock thumbnail %}
{% block details %}
{% trans "Internal Part" %}
{% if part.part %}
{{ part.part.full_name }} {% include "clip.html"%}
{% endif %}
{% if part.description %}
{% trans "Description" %}
{{ part.description }}{% include "clip.html"%}
{% endif %}
{% endblock details %}
{% block details_right %}
{% trans "Manufacturer" %}
{% if part.manufacturer %}
{{ part.manufacturer.name }} {% include "clip.html"%}
{% else %}
{% trans "No manufacturer information available" %}
{% endif %}
{% trans "MPN" %}
{{ part.MPN }}{% include "clip.html"%}
{% if part.link %}
{% trans "External Link" %}
{{ part.link }} {% include "clip.html"%}
{% endif %}
{% endblock details_right %}
{% block page_content %}
{% trans "Suppliers" %}
{% include "spacer.html" %}
{% trans "New Supplier Part" %}
{% trans "Attachments" %}
{% include "spacer.html" %}
{% include "attachment_button.html" %}
{% include "attachment_table.html" %}
{% trans "Parameters" %}
{% include "spacer.html" %}
{% trans "New Parameter" %}
{% endblock %}
{% block js_ready %}
{{ block.super }}
onPanelLoad("attachments", function() {
loadAttachmentTable('{% url "api-manufacturer-part-attachment-list" %}', {
filters: {
manufacturer_part: {{ part.pk }},
},
fields: {
manufacturer_part: {
value: {{ part.pk }},
hidden: true
}
}
});
enableDragAndDrop(
'#attachment-dropzone',
'{% url "api-manufacturer-part-attachment-list" %}',
{
data: {
manufacturer_part: {{ part.id }},
},
label: 'attachment',
success: function(data, status, xhr) {
reloadAttachmentTable();
}
}
);
});
function reloadParameters() {
$("#parameter-table").bootstrapTable("refresh");
}
$('#parameter-create').click(function() {
constructForm('{% url "api-manufacturer-part-parameter-list" %}', {
method: 'POST',
fields: {
name: {},
value: {},
units: {},
manufacturer_part: {
value: {{ part.pk }},
hidden: true,
}
},
title: '{% trans "Add Parameter" %}',
onSuccess: reloadParameters
});
});
function reloadSupplierPartTable() {
$('#supplier-table').bootstrapTable('refresh');
}
$('#supplier-create').click(function () {
createSupplierPart({
manufacturer_part: {{ part.pk }},
part: {{ part.part.pk }},
onSuccess: reloadSupplierPartTable,
});
});
$("#supplier-part-delete").click(function() {
var selections = getTableData('#supplier-table');
deleteSupplierParts(selections, {
success: reloadSupplierPartTable,
});
});
$("#multi-parameter-delete").click(function() {
var selections = getTableData('#parameter-table');
deleteManufacturerPartParameters(selections, {
success: function() {
$('#parameter-table').bootstrapTable('refresh');
}
});
});
loadSupplierPartTable(
"#supplier-table",
"{% url 'api-supplier-part-list' %}",
{
params: {
part: {{ part.part.id }},
manufacturer_part: {{ part.id }},
part_detail: true,
supplier_detail: true,
manufacturer_detail: true,
},
}
);
loadManufacturerPartParameterTable(
"#parameter-table",
"{% url 'api-manufacturer-part-parameter-list' %}",
{
params: {
manufacturer_part: {{ part.id }},
}
}
);
$('#order-part, #order-part2').click(function() {
inventreeGet(
'{% url "api-part-detail" part.part.pk %}', {},
{
success: function(response) {
orderParts([response], {
manufacturer_part: {{ part.pk }},
{% if part.manufacturer %}
manufacturer: {{ part.manufacturer.pk }},
{% endif %}
});
}
}
);
});
$('#edit-part').click(function () {
editManufacturerPart({{ part.pk }}, {
onSuccess: function() {
location.reload();
}
});
});
$('#delete-part').click(function() {
inventreeGet(
'{% url "api-manufacturer-part-detail" part.pk %}',
{},
{
success: function(data) {
deleteManufacturerParts(
[data],
{
success: function() {
{% if part.manufacturer %}
window.location.href = "{% url 'company-detail' part.manufacturer.id %}";
{% else%}
window.location.href = "{% url 'index' %}";
{% endif %}
}
}
);
}
}
);
});
enableSidebar('manufacturerpart');
{% endblock %}