Print test report for multiple stock items at once

This commit is contained in:
Oliver Walters 2021-01-18 21:42:55 +11:00
parent 0a566c062d
commit 952da19600
3 changed files with 24 additions and 1 deletions

View File

@ -29,8 +29,17 @@ function selectTestReport(reports, items, options={}) {
); );
// Construct form // Construct form
var html = ` var html = '';
if (items.length > 0) {
html += `
<div class='alert alert-block alert-info'>
${items.length} {% trans "stock items selected" %}
</div>`;
}
html += `
<form method='post' action='' class='js-modal-form' enctype='multipart/form-data'> <form method='post' action='' class='js-modal-form' enctype='multipart/form-data'>
<div class='form-group'> <div class='form-group'>
<label class='control-label requiredField' for='id_report'> <label class='control-label requiredField' for='id_report'>

View File

@ -665,6 +665,7 @@ function loadStockTable(table, options) {
} }
// Automatically link button callbacks // Automatically link button callbacks
$('#multi-item-print-label').click(function() { $('#multi-item-print-label').click(function() {
var selections = $('#stock-table').bootstrapTable('getSelections'); var selections = $('#stock-table').bootstrapTable('getSelections');
@ -677,6 +678,18 @@ function loadStockTable(table, options) {
printStockItemLabels(items); printStockItemLabels(items);
}); });
$('#multi-item-print-test-report').click(function() {
var selections = $('#stock-table').bootstrapTable('getSelections');
var items = [];
selections.forEach(function(item) {
items.push(item.pk);
});
printTestReports(items);
})
$('#multi-item-stocktake').click(function() { $('#multi-item-stocktake').click(function() {
stockAdjustment('count'); stockAdjustment('count');
}); });

View File

@ -18,6 +18,7 @@
<button id='stock-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button> <button id='stock-options' class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{% trans "Options" %}<span class="caret"></span></button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href='#' id='multi-item-print-label' title='{% trans "Print labels" %}'><span class='fas fa-tags'></span> {% trans "Print labels" %}</a></li> <li><a href='#' id='multi-item-print-label' title='{% trans "Print labels" %}'><span class='fas fa-tags'></span> {% trans "Print labels" %}</a></li>
<li><a href='#' id='multi-item-print-test-report' title='{% trans "Print test reports" %}'><span class='fas fa-file-pdf'></span> {% trans "Print test reports" %}</a></li>
{% if roles.stock.change %} {% if roles.stock.change %}
<li><a href="#" id='multi-item-add' title='{% trans "Add to selected stock items" %}'><span class='fas fa-plus-circle'></span> {% trans "Add stock" %}</a></li> <li><a href="#" id='multi-item-add' title='{% trans "Add to selected stock items" %}'><span class='fas fa-plus-circle'></span> {% trans "Add stock" %}</a></li>
<li><a href="#" id='multi-item-remove' title='{% trans "Remove from selected stock items" %}'><span class='fas fa-minus-circle'></span> {% trans "Remove stock" %}</a></li> <li><a href="#" id='multi-item-remove' title='{% trans "Remove from selected stock items" %}'><span class='fas fa-minus-circle'></span> {% trans "Remove stock" %}</a></li>