- admin/quickTasks: list, create, save, delete - admin/scheduledTasks: list, save, delete, toggle, run, runDue - cron: expireStaleChats, expireTabs - receipt: public order receipt page (no auth, UUID-secured) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../../helpers.php';
|
|
runAuth();
|
|
|
|
/**
|
|
* Create a task from a quick task template (instant creation).
|
|
* POST: { BusinessID, QuickTaskTemplateID }
|
|
*/
|
|
|
|
$data = readJsonBody();
|
|
$businessID = (int) ($data['BusinessID'] ?? headerValue('X-Business-ID') ?? 0);
|
|
$templateID = (int) ($data['QuickTaskTemplateID'] ?? 0);
|
|
|
|
if ($businessID <= 0) {
|
|
apiAbort(['OK' => false, 'ERROR' => 'missing_params', 'MESSAGE' => 'BusinessID is required']);
|
|
}
|
|
if ($templateID <= 0) {
|
|
apiAbort(['OK' => false, 'ERROR' => 'missing_params', 'MESSAGE' => 'QuickTaskTemplateID is required']);
|
|
}
|
|
|
|
try {
|
|
$template = queryOne("
|
|
SELECT Title, Details, TaskCategoryID AS CategoryID
|
|
FROM QuickTaskTemplates
|
|
WHERE ID = ? AND BusinessID = ? AND IsActive = 1
|
|
", [$templateID, $businessID]);
|
|
|
|
if (!$template) {
|
|
apiAbort(['OK' => false, 'ERROR' => 'not_found', 'MESSAGE' => 'Template not found']);
|
|
}
|
|
|
|
queryTimed("
|
|
INSERT INTO Tasks (BusinessID, CategoryID, TaskTypeID, Title, Details, CreatedOn, ClaimedByUserID)
|
|
VALUES (?, ?, 0, ?, ?, NOW(), 0)
|
|
", [
|
|
$businessID,
|
|
$template['CategoryID'],
|
|
$template['Title'],
|
|
$template['Details'],
|
|
]);
|
|
|
|
$taskID = (int) lastInsertId();
|
|
|
|
jsonResponse([
|
|
'OK' => true,
|
|
'TASK_ID' => $taskID,
|
|
'MESSAGE' => 'Task created',
|
|
]);
|
|
|
|
} catch (Exception $e) {
|
|
jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => $e->getMessage()]);
|
|
}
|