payfrit-api/api/tasks/team/active.php
Mike e3933ce0c8 Add team task tracker API endpoints
New endpoints at api/tasks/team/ for centralized bot task tracking:
- POST create.php — register a new task
- POST update.php — change status, add notes (auto-sets PausedOn/CompletedOn)
- GET active.php — list active/paused tasks, optional BotName filter
- GET list.php — full listing with filters (BotName, Status, Channel, AssignedBy, Since) and pagination

Includes schema.sql for the TeamTasks table.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:00:12 +00:00

33 lines
843 B
PHP

<?php
require_once __DIR__ . '/../../helpers.php';
/**
* GET /api/tasks/team/active.php
* List all active and paused tasks.
*
* Optional query params: BotName (filter by bot)
* Returns: { OK: true, Tasks: [...] }
*/
$botName = trim($_GET['BotName'] ?? '');
try {
$sql = "SELECT ID, BotName, Title, Status, Channel, StartedOn, PausedOn, Notes, AssignedBy
FROM TeamTasks
WHERE Status IN ('active', 'paused')";
$params = [];
if ($botName !== '') {
$sql .= " AND BotName = ?";
$params[] = $botName;
}
$sql .= " ORDER BY StartedOn DESC";
$tasks = queryTimed($sql, $params);
jsonResponse(['OK' => true, 'Tasks' => $tasks]);
} catch (Throwable $e) {
http_response_code(500);
apiAbort(['OK' => false, 'ERROR' => 'Failed to fetch tasks: ' . $e->getMessage()]);
}