Update PO line item table

This commit is contained in:
Oliver 2022-02-28 15:03:39 +11:00
parent df7713f6c2
commit 9e82b28e9d
2 changed files with 32 additions and 5 deletions

View File

@ -210,7 +210,7 @@ $('#new-po-line').click(function() {
loadPurchaseOrderLineItemTable('#po-line-table', { loadPurchaseOrderLineItemTable('#po-line-table', {
order: {{ order.pk }}, order: {{ order.pk }},
supplier: {{ order.supplier.pk }}, supplier: {{ order.supplier.pk }},
{% if order.status == PurchaseOrderStatus.PENDING %} {% if roles.purchase_order.change %}
allow_edit: true, allow_edit: true,
{% else %} {% else %}
allow_edit: false, allow_edit: false,

View File

@ -930,6 +930,7 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
reference: {}, reference: {},
purchase_price: {}, purchase_price: {},
purchase_price_currency: {}, purchase_price_currency: {},
target_date: {},
destination: {}, destination: {},
notes: {}, notes: {},
}, },
@ -971,7 +972,11 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
], ],
{ {
success: function() { success: function() {
// Reload the line item table
$(table).bootstrapTable('refresh'); $(table).bootstrapTable('refresh');
// Reload the "received stock" table
$('#stock-table').bootstrapTable('refresh');
} }
} }
); );
@ -1111,6 +1116,28 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
return formatter.format(total); return formatter.format(total);
} }
}, },
{
sortable: true,
field: 'target_date',
switchable: true,
title: '{% trans "Target Date" %}',
formatter: function(value, row) {
if (row.target_date) {
var html = row.target_date;
if (row.overdue) {
html += `<span class='fas fa-calendar-alt icon-red float-right' title='{% trans "This line item is overdue" %}'></span>`;
}
return html;
} else if (row.order_detail && row.order_detail.target_date) {
return `<em>${row.order_detail.target_date}</em>`;
} else {
return '-';
}
}
},
{ {
sortable: false, sortable: false,
field: 'received', field: 'received',
@ -1157,15 +1184,15 @@ function loadPurchaseOrderLineItemTable(table, options={}) {
var pk = row.pk; var pk = row.pk;
if (options.allow_receive && row.received < row.quantity) {
html += makeIconButton('fa-sign-in-alt icon-green', 'button-line-receive', pk, '{% trans "Receive line item" %}');
}
if (options.allow_edit) { if (options.allow_edit) {
html += makeIconButton('fa-edit icon-blue', 'button-line-edit', pk, '{% trans "Edit line item" %}'); html += makeIconButton('fa-edit icon-blue', 'button-line-edit', pk, '{% trans "Edit line item" %}');
html += makeIconButton('fa-trash-alt icon-red', 'button-line-delete', pk, '{% trans "Delete line item" %}'); html += makeIconButton('fa-trash-alt icon-red', 'button-line-delete', pk, '{% trans "Delete line item" %}');
} }
if (options.allow_receive && row.received < row.quantity) {
html += makeIconButton('fa-sign-in-alt', 'button-line-receive', pk, '{% trans "Receive line item" %}');
}
html += `</div>`; html += `</div>`;
return html; return html;