Create kitchen task on order submission for KDS display
submitCash.php had no task creation — cash orders were invisible to KDS. submit.php also lacked it (tab orders never hit webhook.php). Both now create "Prepare Order #X for Table" task at StatusID=1. submit.php includes duplicate guard since webhook.php also creates tasks for card payments. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5d9be247c8
commit
07abcee2fd
2 changed files with 37 additions and 0 deletions
|
|
@ -191,6 +191,27 @@ try {
|
||||||
[$OrderID]
|
[$OrderID]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Create kitchen task for KDS display
|
||||||
|
$spID = (int) ($qOrder['ServicePointID'] ?? 0);
|
||||||
|
$spName = 'Table';
|
||||||
|
if ($spID > 0) {
|
||||||
|
$qSP = queryOne("SELECT Name FROM ServicePoints WHERE ID = ?", [$spID]);
|
||||||
|
$spName = !empty(trim($qSP['Name'] ?? '')) ? $qSP['Name'] : 'Table';
|
||||||
|
}
|
||||||
|
$taskTitle = "Prepare Order #{$OrderID} for {$spName}";
|
||||||
|
|
||||||
|
// Prevent duplicates (webhook.php also creates a task for card payments)
|
||||||
|
$qExistingTask = queryOne(
|
||||||
|
"SELECT ID FROM Tasks WHERE OrderID = ? AND Title LIKE 'Prepare Order%' LIMIT 1",
|
||||||
|
[$OrderID]
|
||||||
|
);
|
||||||
|
if (!$qExistingTask) {
|
||||||
|
queryTimed("
|
||||||
|
INSERT INTO Tasks (BusinessID, OrderID, ServicePointID, Title, CreatedOn, ClaimedByUserID)
|
||||||
|
VALUES (?, ?, ?, ?, NOW(), 0)
|
||||||
|
", [$qOrder['BusinessID'], $OrderID, $spID > 0 ? $spID : null, $taskTitle]);
|
||||||
|
}
|
||||||
|
|
||||||
// Tab running total update
|
// Tab running total update
|
||||||
if ($tabID > 0) {
|
if ($tabID > 0) {
|
||||||
queryTimed("UPDATE Tabs SET LastActivityOn = NOW() WHERE ID = ?", [$tabID]);
|
queryTimed("UPDATE Tabs SET LastActivityOn = NOW() WHERE ID = ?", [$tabID]);
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,22 @@ try {
|
||||||
WHERE ID = ?
|
WHERE ID = ?
|
||||||
", [$PaymentID, $paymentStatus, $platformFee, $Tip, $balanceApplied, $fullyPaidByBalance ? 1 : 0, $OrderID]);
|
", [$PaymentID, $paymentStatus, $platformFee, $Tip, $balanceApplied, $fullyPaidByBalance ? 1 : 0, $OrderID]);
|
||||||
|
|
||||||
|
// Create kitchen task for KDS display (same as webhook.php does for card payments)
|
||||||
|
$spName = '';
|
||||||
|
$spID = (int) ($qOrder['ServicePointID'] ?? 0);
|
||||||
|
if ($spID > 0) {
|
||||||
|
$qSP = queryOne("SELECT Name FROM ServicePoints WHERE ID = ?", [$spID]);
|
||||||
|
$spName = !empty(trim($qSP['Name'] ?? '')) ? $qSP['Name'] : 'Table';
|
||||||
|
} else {
|
||||||
|
$spName = 'Table';
|
||||||
|
}
|
||||||
|
$taskTitle = "Prepare Order #{$OrderID} for {$spName}";
|
||||||
|
|
||||||
|
queryTimed("
|
||||||
|
INSERT INTO Tasks (BusinessID, OrderID, ServicePointID, Title, CreatedOn, ClaimedByUserID)
|
||||||
|
VALUES (?, ?, ?, ?, NOW(), 0)
|
||||||
|
", [$qOrder['BusinessID'], $OrderID, $spID > 0 ? $spID : null, $taskTitle]);
|
||||||
|
|
||||||
$response = [
|
$response = [
|
||||||
'OK' => true,
|
'OK' => true,
|
||||||
'OrderID' => $OrderID,
|
'OrderID' => $OrderID,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue