mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 04:55:44 +00:00
Sales order tables (#3225)
* Add buttons to expand / collapse shipment tables (cherry picked from commit0af9fc473e
) * Updates for sales order lines table (cherry picked from commitd99ec062ad
)
This commit is contained in:
5
InvenTree/templates/collapse_rows.html
Normal file
5
InvenTree/templates/collapse_rows.html
Normal file
@ -0,0 +1,5 @@
|
||||
{% load i18n %}
|
||||
|
||||
<button id='{{ label }}-collapse' class='btn btn-outline-secondary' type='button' title='{% trans "Collapse all rows" %}'>
|
||||
<span class='fas fa-compress'></span>
|
||||
</button>
|
5
InvenTree/templates/expand_rows.html
Normal file
5
InvenTree/templates/expand_rows.html
Normal file
@ -0,0 +1,5 @@
|
||||
{% load i18n %}
|
||||
|
||||
<button id='{{ label }}-expand' class='btn btn-outline-secondary' type='button' title='{% trans "Expand all rows" %}'>
|
||||
<span class='fas fa-expand'></span>
|
||||
</button>
|
@ -2540,6 +2540,17 @@ function loadSalesOrderShipmentTable(table, options={}) {
|
||||
|
||||
setupFilterList('salesordershipment', $(table), options.filter_target);
|
||||
|
||||
// Add callbacks for expand / collapse buttons
|
||||
var prefix = options.shipped ? 'completed' : 'pending';
|
||||
|
||||
$(`#${prefix}-shipments-expand`).click(function() {
|
||||
$(table).bootstrapTable('expandAllRows');
|
||||
});
|
||||
|
||||
$(`#${prefix}-shipments-collapse`).click(function() {
|
||||
$(table).bootstrapTable('collapseAllRows');
|
||||
});
|
||||
|
||||
function makeShipmentActions(row) {
|
||||
// Construct "actions" for the given shipment row
|
||||
var pk = row.pk;
|
||||
@ -3416,6 +3427,15 @@ function loadSalesOrderLineItemTable(table, options={}) {
|
||||
// Show detail view if the PurchaseOrder is PENDING or SHIPPED
|
||||
var show_detail = pending || shipped;
|
||||
|
||||
// Add callbacks for expand / collapse buttons
|
||||
$('#sales-lines-expand').click(function() {
|
||||
$(table).bootstrapTable('expandAllRows');
|
||||
});
|
||||
|
||||
$('#sales-lines-collapse').click(function() {
|
||||
$(table).bootstrapTable('collapseAllRows');
|
||||
});
|
||||
|
||||
// Table columns to display
|
||||
var columns = [
|
||||
/*
|
||||
@ -3543,29 +3563,26 @@ function loadSalesOrderLineItemTable(table, options={}) {
|
||||
title: '{% trans "Available Stock" %}',
|
||||
formatter: function(value, row) {
|
||||
var available = row.available_stock;
|
||||
var total = row.part_detail.stock;
|
||||
var required = Math.max(row.quantity - row.allocated - row.shipped, 0);
|
||||
|
||||
var html = '';
|
||||
|
||||
if (total > 0) {
|
||||
if (available > 0) {
|
||||
var url = `/part/${row.part}/?display=part-stock`;
|
||||
|
||||
var text = available;
|
||||
|
||||
if (total != available) {
|
||||
text += ` / ${total}`;
|
||||
}
|
||||
|
||||
html = renderLink(text, url);
|
||||
} else {
|
||||
html += `<span class='badge rounded-pill bg-danger'>{% trans "No Stock Available" %}</span>`;
|
||||
}
|
||||
|
||||
if (available >= required) {
|
||||
html += `<span class='fas fa-check-circle icon-green float-right' title='{% trans "Sufficient stock available" %}'></span>`;
|
||||
} else {
|
||||
html += `<span class='fas fa-times-circle icon-red float-right' title='{% trans "Insufficient stock available" %}'></span>`;
|
||||
if (required > 0) {
|
||||
if (available >= required) {
|
||||
html += `<span class='fas fa-check-circle icon-green float-right' title='{% trans "Sufficient stock available" %}'></span>`;
|
||||
} else {
|
||||
html += `<span class='fas fa-times-circle icon-red float-right' title='{% trans "Insufficient stock available" %}'></span>`;
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
|
Reference in New Issue
Block a user