diff --git a/api/orders/_createOrderTasks.cfm b/api/orders/_createOrderTasks.cfm new file mode 100644 index 0000000..31e3d64 --- /dev/null +++ b/api/orders/_createOrderTasks.cfm @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/api/orders/listForKDS.cfm b/api/orders/listForKDS.cfm index c704705..5bd94b3 100644 --- a/api/orders/listForKDS.cfm +++ b/api/orders/listForKDS.cfm @@ -120,6 +120,7 @@ oli.Quantity, oli.Remark, oli.IsDeleted, + oli.StatusID, i.Name, i.ParentItemID, i.IsCheckedByDefault, @@ -146,7 +147,8 @@ "ParentItemID": qLineItems.ParentItemID, "ItemParentName": qLineItems.ItemParentName, "IsCheckedByDefault": qLineItems.IsCheckedByDefault, - "StationID": qLineItems.StationID + "StationID": qLineItems.StationID, + "StatusID": val(qLineItems.StatusID) })> diff --git a/api/orders/markStationDone.cfm b/api/orders/markStationDone.cfm new file mode 100644 index 0000000..50f7a4f --- /dev/null +++ b/api/orders/markStationDone.cfm @@ -0,0 +1,149 @@ + + + + + + + #serializeJSON(arguments.payload)# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + AND oli.StatusID = 0 + ", [ { value = OrderID, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })> + + + + + + + + + + + + + + + + + + + diff --git a/api/orders/updateStatus.cfm b/api/orders/updateStatus.cfm index 49f48d5..c269317 100644 --- a/api/orders/updateStatus.cfm +++ b/api/orders/updateStatus.cfm @@ -86,165 +86,7 @@ ---> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -116,6 +126,6 @@ - + \ No newline at end of file diff --git a/kds/kds.js b/kds/kds.js index da5b0e9..f007411 100644 --- a/kds/kds.js +++ b/kds/kds.js @@ -366,8 +366,9 @@ function renderLineItem(item, allItems, isOtherStation = false) { const modifiers = allItems.filter(mod => mod.ParentOrderLineItemID === item.OrderLineItemID); console.log(`Item: ${item.Name} (ID: ${item.OrderLineItemID}) has ${modifiers.length} direct modifiers:`, modifiers.map(m => m.Name)); const otherClass = isOtherStation ? ' other-station' : ''; + const doneClass = (item.StatusID === 1) ? ' line-item-done' : ''; return ` -
+
${escapeHtml(item.Name)}
x${item.Quantity}
@@ -433,8 +434,36 @@ function renderAllModifiers(modifiers, allItems) { return html; } +// Check if this station's items are all done for an order +function isStationDoneForOrder(order) { + if (!config.stationId || config.stationId === 0) return false; + const stationRootItems = order.LineItems.filter(li => + li.ParentOrderLineItemID === 0 && (parseInt(li.StationID) || 0) === config.stationId + ); + if (stationRootItems.length === 0) return true; // no items for this station + return stationRootItems.every(li => li.StatusID === 1); +} + // Render action buttons based on order status function renderActionButtons(order) { + const isFiltering = config.stationId && config.stationId > 0; + + if (isFiltering) { + // Station worker view: per-station "Done" button + if (order.StatusID === STATUS.NEW || order.StatusID === STATUS.PREPARING) { + if (isStationDoneForOrder(order)) { + return ``; + } else { + return ``; + } + } + if (order.StatusID === STATUS.READY) { + return ``; + } + return ''; + } + + // Manager view (no station selected): whole-order buttons switch (order.StatusID) { case STATUS.NEW: return ``; @@ -467,6 +496,26 @@ async function updateOrderStatus(orderId, newStatusId) { } } +// Mark station's items as done for an order +async function markStationDone(orderId) { + try { + const response = await fetch(`${config.apiBaseUrl}/orders/markStationDone.cfm`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ OrderID: orderId, StationID: config.stationId }) + }); + const data = await response.json(); + if (data.OK) { + await loadOrders(); + } else { + alert(`Failed to mark station done: ${data.MESSAGE || data.ERROR}`); + } + } catch (error) { + console.error('Failed to mark station done:', error); + alert('Failed to mark station done. Please try again.'); + } +} + // Helper functions // Get location label based on order type (Table vs Type)