diff --git a/InvenTree/build/templates/build/build_base.html b/InvenTree/build/templates/build/build_base.html index 9ca3fff818..671f748331 100644 --- a/InvenTree/build/templates/build/build_base.html +++ b/InvenTree/build/templates/build/build_base.html @@ -45,27 +45,35 @@ src="{% static 'img/blank_image.png' %}"

{{ build.title }}

-
-
- {% if roles.build.change %} - - {% if build.is_active %} - - - {% endif %} - {% endif %} - {% if build.status == BuildStatus.CANCELLED and roles.build.delete %} - - {% endif %} +
+ {% if roles.build.change %} + + {% if build.is_active %} + + + {% endif %} + {% endif %} + {% if build.status == BuildStatus.CANCELLED and roles.build.delete %} + + {% endif %}
{% endblock %} @@ -151,6 +159,10 @@ src="{% static 'img/blank_image.png' %}" ); }); + $('#print-build-report').click(function() { + printBuildReports([{{ build.pk }}]); + }); + $("#build-delete").on('click', function() { launchModalForm( "{% url 'build-delete' build.id %}", diff --git a/InvenTree/templates/js/report.js b/InvenTree/templates/js/report.js index e79d80dc41..bb8068681a 100644 --- a/InvenTree/templates/js/report.js +++ b/InvenTree/templates/js/report.js @@ -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={}) { /** * Print BOM reports for the provided part(s)