id = $data['id'] ?? null; $task->id_department = $data['id_department'] ?? null; $task->id_label = $data['id_label'] ?? null; $task->id_account = $data['id_account'] ?? null; $task->column_id = $data['column_id'] ?? null; $task->order = $data['order'] ?? null; $task->date = $data['date'] ?? null; $task->title = $data['title'] ?? ''; $task->descript = $data['descript'] ?? ''; $task->descript_full = $data['descript_full'] ?? ''; $result = $task->update(); RestApi::response($result); } // Создание задачи if ($action === 'create') { $task->id_project = $data['id_project'] ?? null; $task->id_department = $data['id_department'] ?? null; $task->id_label = $data['id_label'] ?? null; $task->id_account = $data['id_account'] ?? null; $task->column_id = $data['column_id'] ?? null; $task->order = $data['order'] ?? 0; $task->date = $data['date'] ?? null; $task->title = $data['title'] ?? ''; $task->descript = $data['descript'] ?? ''; $task->descript_full = $data['descript_full'] ?? ''; $files = $data['files'] ?? []; $result = $task->create($files); RestApi::response($result); } // Удаление задачи if ($action === 'delete') { $id = $data['id'] ?? null; $result = Task::delete($id); RestApi::response($result); } // Установка статуса архивации задачи if ($action === 'set_archive') { $id = $data['id'] ?? null; $archive = $data['archive'] ?? 1; $result = Task::setArchive($id, $archive); RestApi::response($result); } // Метод не указан if (!$action) { RestApi::response(['success' => false, 'error' => 'Укажите метод'], 400); } } if ($method === 'GET') { // Получение задач проекта // ?id_project=1 (обязательный) // ?archive=0 (неархивные, по умолчанию), ?archive=1 (архивные), ?archive=all (все) $id_project = $_GET['id_project'] ?? null; if (!$id_project) { RestApi::response(['success' => false, 'errors' => ['id_project' => 'Проект не указан']], 400); } $archive = $_GET['archive'] ?? 0; if ($archive === 'all') { $archive = null; } else { $archive = (int)$archive; } $task = new Task(); $tasks = $task->getAll($id_project, $archive); RestApi::response(['success' => true, 'data' => $tasks]); } ?>