mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Dialog for printing BOM reports
This commit is contained in:
parent
4e9b9ee6fd
commit
11099676ef
@ -35,34 +35,37 @@
|
|||||||
<span class='fas fa-trash-alt icon-red'></span>
|
<span class='fas fa-trash-alt icon-red'></span>
|
||||||
</button>
|
</button>
|
||||||
<button class='btn btn-primary' type='button' title='{% trans "Import BOM data" %}' id='bom-upload'>
|
<button class='btn btn-primary' type='button' title='{% trans "Import BOM data" %}' id='bom-upload'>
|
||||||
<span class='fas fa-file-upload'></span> {% trans "Import from File" %}
|
<span class='fas fa-file-upload'></span>
|
||||||
</button>
|
</button>
|
||||||
{% if part.variant_of %}
|
{% if part.variant_of %}
|
||||||
<button class='btn btn-default' type='button' title='{% trans "Copy BOM from parent part" %}' id='bom-duplicate'>
|
<button class='btn btn-default' type='button' title='{% trans "Copy BOM from parent part" %}' id='bom-duplicate'>
|
||||||
<span class='fas fa-clone'></span> {% trans "Copy from Parent" %}
|
<span class='fas fa-clone'></span>
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<button class='btn btn-default' type='button' title='{% trans "New BOM Item" %}' id='bom-item-new'>
|
<button class='btn btn-default' type='button' title='{% trans "New BOM Item" %}' id='bom-item-new'>
|
||||||
<span class='fas fa-plus-circle'></span> {% trans "Add Item" %}
|
<span class='fas fa-plus-circle'></span>
|
||||||
</button>
|
</button>
|
||||||
<button class='btn btn-success' type='button' title='{% trans "Finish Editing" %}' id='editing-finished'>
|
<button class='btn btn-success' type='button' title='{% trans "Finish Editing" %}' id='editing-finished'>
|
||||||
<span class='fas fa-check-circle'></span> {% trans "Finished" %}
|
<span class='fas fa-check-circle'></span>
|
||||||
</button>
|
</button>
|
||||||
{% elif part.active %}
|
{% elif part.active %}
|
||||||
{% if roles.part.change %}
|
{% if roles.part.change %}
|
||||||
<button class='btn btn-primary' type='button' title='{% trans "Edit BOM" %}' id='edit-bom'>
|
<button class='btn btn-primary' type='button' title='{% trans "Edit BOM" %}' id='edit-bom'>
|
||||||
<span class='fas fa-edit'></span> {% trans "Edit" %}
|
<span class='fas fa-edit'></span>
|
||||||
</button>
|
</button>
|
||||||
{% if part.is_bom_valid == False %}
|
{% if part.is_bom_valid == False %}
|
||||||
<button class='btn btn-success' id='validate-bom' title='{% trans "Validate Bill of Materials" %}' type='button'>
|
<button class='btn btn-success' id='validate-bom' title='{% trans "Validate Bill of Materials" %}' type='button'>
|
||||||
<span class='fas fa-clipboard-check'></span> {% trans "Validate" %}
|
<span class='fas fa-clipboard-check'></span>
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
<button title='{% trans "Export Bill of Materials" %}' class='btn btn-default' id='download-bom' type='button'>
|
<button title='{% trans "Export Bill of Materials" %}' class='btn btn-default' id='download-bom' type='button'>
|
||||||
<span class='fas fa-file-download'></span> {% trans "Export" %}
|
<span class='fas fa-file-download'></span>
|
||||||
|
</button>
|
||||||
|
<button title='{% trans "Print BOM Report" %}' class='btn btn-default' id='print-bom-report' type='button'>
|
||||||
|
<span class='fas fa-file-pdf'></span>
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
|
||||||
<div class='filter-list' id='filter-list-bom'>
|
<div class='filter-list' id='filter-list-bom'>
|
||||||
<!-- Empty div (will be filled out with avilable BOM filters) -->
|
<!-- Empty div (will be filled out with avilable BOM filters) -->
|
||||||
</div>
|
</div>
|
||||||
@ -215,4 +218,8 @@
|
|||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
$("#print-bom-report").click(function() {
|
||||||
|
printBomReports([{{ part.pk }}]);
|
||||||
|
});
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -102,7 +102,7 @@ function printTestReports(items, options={}) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request available labels from the server
|
// Request available reports from the server
|
||||||
inventreeGet(
|
inventreeGet(
|
||||||
'{% url "api-stockitem-testreport-list" %}',
|
'{% url "api-stockitem-testreport-list" %}',
|
||||||
{
|
{
|
||||||
@ -140,3 +140,57 @@ function printTestReports(items, options={}) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function printBomReports(parts, options={}) {
|
||||||
|
/**
|
||||||
|
* Print BOM reports for the provided part(s)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (parts.length == 0) {
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "Select Parts" %}',
|
||||||
|
'{% trans "Part(s) must be selected before printing reports" %}'
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request available reports from the server
|
||||||
|
inventreeGet(
|
||||||
|
'{% url "api-bom-report-list" %}',
|
||||||
|
{
|
||||||
|
enabled: true,
|
||||||
|
parts: parts,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
success: function(response) {
|
||||||
|
if (response.length == 0) {
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "No Reports Found" %}',
|
||||||
|
'{% trans "No report templates found which match selected part(s)" %}',
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select which report to print
|
||||||
|
selectReport(
|
||||||
|
response,
|
||||||
|
parts,
|
||||||
|
{
|
||||||
|
success: function(pk) {
|
||||||
|
var href = `/api/report/bom/${pk}/print/?`;
|
||||||
|
|
||||||
|
parts.forEach(function(part) {
|
||||||
|
href += `parts[]=${part}&`;
|
||||||
|
});
|
||||||
|
|
||||||
|
window.location.href = href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user