payfrit-api/api/admin/quickTasks/list.php
John Mizerek 4d806d4e1e Port admin, cron, and receipt endpoints from CFML to PHP
- 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>
2026-03-14 15:57:25 -07:00

63 lines
1.9 KiB
PHP

<?php
require_once __DIR__ . '/../../helpers.php';
runAuth();
/**
* Returns quick task templates for a business.
* GET/POST: { BusinessID }
*/
$data = readJsonBody();
$businessID = (int) ($data['BusinessID'] ?? headerValue('X-Business-ID') ?? $_GET['BusinessID'] ?? 0);
if ($businessID <= 0) {
apiAbort(['OK' => false, 'ERROR' => 'missing_params', 'MESSAGE' => 'BusinessID is required']);
}
try {
$rows = queryTimed("
SELECT
qt.ID,
qt.Name,
qt.TaskCategoryID AS CategoryID,
qt.Title,
qt.Details,
qt.Icon,
qt.Color,
qt.SortOrder,
qt.IsActive,
tc.Name AS CategoryName,
tc.Color AS CategoryColor
FROM QuickTaskTemplates qt
LEFT JOIN TaskCategories tc ON qt.TaskCategoryID = tc.ID
WHERE qt.BusinessID = ?
AND qt.IsActive = 1
ORDER BY qt.SortOrder, qt.ID
", [$businessID]);
$templates = [];
foreach ($rows as $row) {
$templates[] = [
'QuickTaskTemplateID' => (int) $row['ID'],
'Name' => $row['Name'],
'CategoryID' => $row['CategoryID'] ?? '',
'Title' => $row['Title'],
'Details' => $row['Details'] ?? '',
'Icon' => $row['Icon'] ?? 'add_box',
'Color' => $row['Color'] ?? '#6366f1',
'SortOrder' => (int) $row['SortOrder'],
'IsActive' => (int) $row['IsActive'],
'CategoryName' => $row['CategoryName'] ?? '',
'CategoryColor' => $row['CategoryColor'] ?? '',
];
}
jsonResponse([
'OK' => true,
'TEMPLATES' => $templates,
'COUNT' => count($templates),
]);
} catch (Exception $e) {
jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => $e->getMessage()]);
}