account
This commit is contained in:
@@ -2784,85 +2784,76 @@ async function submitEditEntry(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function openEntryOrdersModal(entryNo) {
|
function openEntryOrdersModal(entryNo) {
|
||||||
// header la entry no show kar
|
document.getElementById('entryOrdersEntryNo-span').textContent = `(${entryNo})`;
|
||||||
document.getElementById('entryOrdersEntryNo-span').textContent = `(${entryNo})`;
|
|
||||||
|
|
||||||
// table clean / loading state
|
const tbody = document.getElementById('entryOrdersTableBody');
|
||||||
const tbody = document.getElementById('entryOrdersTableBody');
|
|
||||||
tbody.innerHTML = `
|
|
||||||
<tr>
|
|
||||||
<td colspan="7" class="empty-state">Loading orders...</td>
|
|
||||||
</tr>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// API call: /admin/account/entry-orders/{entryno}
|
|
||||||
jsonFetch(`/admin/account/entry-orders/${encodeURIComponent(entryNo)}`, {
|
|
||||||
method: 'GET'
|
|
||||||
})
|
|
||||||
.then(res => {
|
|
||||||
if (!res.success) {
|
|
||||||
tbody.innerHTML = `
|
tbody.innerHTML = `
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="7" class="empty-state">Failed to load orders</td>
|
<td colspan="7" class="empty-state">Loading orders...</td>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const orders = res.orders || [];
|
jsonFetch(`/admin/account/entry-orders/${encodeURIComponent(entryNo)}`, {
|
||||||
if (!orders.length) {
|
method: 'GET'
|
||||||
tbody.innerHTML = `
|
})
|
||||||
<tr>
|
.then(res => {
|
||||||
<td colspan="7" class="empty-state">No orders associated with this entry</td>
|
if (!res.success) {
|
||||||
</tr>
|
tbody.innerHTML = `
|
||||||
`;
|
<tr>
|
||||||
return;
|
<td colspan="7" class="empty-state">Failed to load orders</td>
|
||||||
}
|
</tr>
|
||||||
|
`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tbody.innerHTML = '';
|
const orders = res.orders || [];
|
||||||
orders.forEach(order => {
|
if (!orders.length) {
|
||||||
const tr = document.createElement('tr');
|
tbody.innerHTML = `
|
||||||
|
<tr>
|
||||||
|
<td colspan="7" class="empty-state">No orders associated with this entry</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const idString = (order.orderid ?? order.id ?? '').toString().trim();
|
tbody.innerHTML = '';
|
||||||
const numericId = parseInt(idString, 10);
|
|
||||||
const formattedId = isNaN(numericId)
|
|
||||||
? escapeHtml(idString)
|
|
||||||
: 'KNT-25-' + String(numericId).padStart(8, '0');
|
|
||||||
|
|
||||||
// इथे वेगवेगळी शक्य keys try कर
|
orders.forEach(order => {
|
||||||
const amountValue =
|
const tr = document.createElement('tr');
|
||||||
order.ttl_amount ??
|
|
||||||
order.ttlamount ??
|
|
||||||
order.total_amount ??
|
|
||||||
order.order_amount ??
|
|
||||||
order.amount ??
|
|
||||||
0;
|
|
||||||
|
|
||||||
tr.innerHTML = `
|
const amountValue =
|
||||||
<td>${formattedId}</td>
|
order.ttl_amount ??
|
||||||
<td>${escapeHtml(order.markno ?? order.mark_no ?? '')}</td>
|
order.ttlamount ??
|
||||||
<td>${escapeHtml(order.origin ?? '')}</td>
|
order.total_amount ??
|
||||||
<td>${escapeHtml(order.destination ?? '')}</td>
|
order.order_amount ??
|
||||||
<td>${escapeHtml(order.ctn ?? '')}</td>
|
order.amount ??
|
||||||
<td>${escapeHtml(order.qty ?? '')}</td>
|
0;
|
||||||
<td>${formatCurrency(amountValue)}</td>
|
|
||||||
`;
|
|
||||||
tbody.appendChild(tr);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
tr.innerHTML = `
|
||||||
|
<td>${escapeHtml(order.order_id)}</td>
|
||||||
|
<td>${escapeHtml(order.mark_no ?? '')}</td>
|
||||||
|
<td>${escapeHtml(order.origin ?? '')}</td>
|
||||||
|
<td>${escapeHtml(order.destination ?? '')}</td>
|
||||||
|
<td>${escapeHtml(order.ctn ?? '')}</td>
|
||||||
|
<td>${escapeHtml(order.qty ?? '')}</td>
|
||||||
|
<td>${formatCurrency(amountValue)}</td>
|
||||||
|
`;
|
||||||
|
|
||||||
})
|
tbody.appendChild(tr);
|
||||||
.catch(() => {
|
});
|
||||||
tbody.innerHTML = `
|
})
|
||||||
<tr>
|
.catch(() => {
|
||||||
<td colspan="7" class="empty-state">Error loading orders</td>
|
tbody.innerHTML = `
|
||||||
</tr>
|
<tr>
|
||||||
`;
|
<td colspan="7" class="empty-state">Error loading orders</td>
|
||||||
});
|
</tr>
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('entryOrdersModal').classList.add('modal-open');
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('entryOrdersModal').classList.add('modal-open');
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeEntryOrdersModal() {
|
function closeEntryOrdersModal() {
|
||||||
document.getElementById('entryOrdersModal').classList.remove('modal-open');
|
document.getElementById('entryOrdersModal').classList.remove('modal-open');
|
||||||
|
|||||||
Reference in New Issue
Block a user