mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add option to print build report
This commit is contained in:
parent
e72aaf2e07
commit
b222119653
@ -45,27 +45,35 @@ src="{% static 'img/blank_image.png' %}"
|
|||||||
</h3>
|
</h3>
|
||||||
<hr>
|
<hr>
|
||||||
<p>{{ build.title }}</p>
|
<p>{{ build.title }}</p>
|
||||||
<div class='btn-row'>
|
|
||||||
<div class='btn-group action-buttons'>
|
<div class='btn-group action-buttons' role='group'>
|
||||||
{% if roles.build.change %}
|
<!-- Printing options -->
|
||||||
<button type='button' class='btn btn-default' id='build-edit' title='{% trans "Edit Build" %}'>
|
<div class='btn-group'>
|
||||||
<span class='fas fa-edit icon-green'/>
|
<button id='print-options' title='{% trans "Print actions" %}' class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>
|
||||||
|
<span class='fas fa-print'></span> <span class='caret'></span>
|
||||||
</button>
|
</button>
|
||||||
{% if build.is_active %}
|
<ul class='dropdown-menu' role='menu'>
|
||||||
<button type='button' class='btn btn-default' id='build-complete' title='{% trans "Complete Build" %}'>
|
<li><a href='#' id='print-build-report'><span class='fas fa-file-pdf'></span> {% trans "Print Build Order" %}</a></li>
|
||||||
<span class='fas fa-tools'/>
|
</ul>
|
||||||
</button>
|
|
||||||
<button type='button' class='btn btn-default btn-glyph' id='build-cancel' title='{% trans "Cancel Build" %}'>
|
|
||||||
<span class='fas fa-times-circle icon-red'/>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% if build.status == BuildStatus.CANCELLED and roles.build.delete %}
|
|
||||||
<button type='button' class='btn btn-default btn-glyph' id='build-delete' title='{% trans "Delete Build" %}'>
|
|
||||||
<span class='fas fa-trash-alt icon-red'/>
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
{% if roles.build.change %}
|
||||||
|
<button type='button' class='btn btn-default' id='build-edit' title='{% trans "Edit Build" %}'>
|
||||||
|
<span class='fas fa-edit icon-green'/>
|
||||||
|
</button>
|
||||||
|
{% if build.is_active %}
|
||||||
|
<button type='button' class='btn btn-default' id='build-complete' title='{% trans "Complete Build" %}'>
|
||||||
|
<span class='fas fa-tools'/>
|
||||||
|
</button>
|
||||||
|
<button type='button' class='btn btn-default btn-glyph' id='build-cancel' title='{% trans "Cancel Build" %}'>
|
||||||
|
<span class='fas fa-times-circle icon-red'/>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if build.status == BuildStatus.CANCELLED and roles.build.delete %}
|
||||||
|
<button type='button' class='btn btn-default btn-glyph' id='build-delete' title='{% trans "Delete Build" %}'>
|
||||||
|
<span class='fas fa-trash-alt icon-red'/>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@ -151,6 +159,10 @@ src="{% static 'img/blank_image.png' %}"
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#print-build-report').click(function() {
|
||||||
|
printBuildReports([{{ build.pk }}]);
|
||||||
|
});
|
||||||
|
|
||||||
$("#build-delete").on('click', function() {
|
$("#build-delete").on('click', function() {
|
||||||
launchModalForm(
|
launchModalForm(
|
||||||
"{% url 'build-delete' build.id %}",
|
"{% url 'build-delete' build.id %}",
|
||||||
|
@ -142,6 +142,59 @@ function printTestReports(items, options={}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function printBuildReports(builds, options={}) {
|
||||||
|
/**
|
||||||
|
* Print Build report for the provided build(s)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (builds.length == 0) {
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "Select Builds" %}',
|
||||||
|
'{% trans "Build(s) must be selected before printing reports" %}',
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
inventreeGet(
|
||||||
|
'{% url "api-build-report-list" %}',
|
||||||
|
{
|
||||||
|
enabled: true,
|
||||||
|
builds: builds,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
success: function(response) {
|
||||||
|
if (response.length == 0) {
|
||||||
|
showAlertDialog(
|
||||||
|
'{% trans "No Reports Found" %}',
|
||||||
|
'{% trans "No report templates found which match selected build(s)" %}'
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select which report to print
|
||||||
|
selectReport(
|
||||||
|
response,
|
||||||
|
builds,
|
||||||
|
{
|
||||||
|
success: function(pk) {
|
||||||
|
var href = `/api/report/build/${pk}/print/?`;
|
||||||
|
|
||||||
|
builds.forEach(function(build) {
|
||||||
|
href += `builds[]=${build}&`;
|
||||||
|
});
|
||||||
|
|
||||||
|
window.location.href = href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function printBomReports(parts, options={}) {
|
function printBomReports(parts, options={}) {
|
||||||
/**
|
/**
|
||||||
* Print BOM reports for the provided part(s)
|
* Print BOM reports for the provided part(s)
|
||||||
|
Loading…
Reference in New Issue
Block a user