diff --git a/task-endpoints.js b/task-endpoints.js index 4356801..0544ebf 100644 --- a/task-endpoints.js +++ b/task-endpoints.js @@ -714,11 +714,12 @@ app.get('/api/document-approval-tasks', requireAuth, (req, res) => { db.serialize(() => { const startDate = new Date().toISOString(); - + const taskType = req.body.taskType || 'regular'; + db.run( - "INSERT INTO tasks (title, description, created_by, original_task_id, start_date, due_date) VALUES (?, ?, ?, ?, ?, ?)", - [title, description, createdBy, originalTaskId || null, startDate, dueDate || null], - function(err) { + "INSERT INTO tasks (title, description, created_by, original_task_id, start_date, due_date, task_type) VALUES (?, ?, ?, ?, ?, ?, ?)", + [title, description, createdBy, originalTaskId || null, startDate, dueDate || null, taskType], + function(err) { if (err) { res.status(500).json({ error: err.message }); return; @@ -807,8 +808,8 @@ app.get('/api/document-approval-tasks', requireAuth, (req, res) => { const startDate = new Date().toISOString(); db.run( - "INSERT INTO tasks (title, description, created_by, original_task_id, start_date, due_date) VALUES (?, ?, ?, ?, ?, ?)", - [newTitle, originalTask.description, createdBy, taskId, startDate, dueDate || null], + "INSERT INTO tasks (title, description, created_by, original_task_id, start_date, due_date, task_type) VALUES (?, ?, ?, ?, ?, ?, ?)", + [newTitle, originalTask.description, createdBy, taskId, startDate, dueDate || null, originalTask.task_type || 'regular'], function(err) { if (err) { res.status(500).json({ error: err.message }); @@ -890,11 +891,11 @@ app.get('/api/document-approval-tasks', requireAuth, (req, res) => { if (!canUserEditTask(task, req.session.user)) { return res.status(403).json({ error: 'У вас нет прав для редактирования этой задачи' }); } - + const taskType = req.body.taskType || 'regular'; db.serialize(() => { db.run( - "UPDATE tasks SET title = ?, description = ?, due_date = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?", - [title, description, dueDate || null, taskId], + "UPDATE tasks SET title = ?, description = ?, due_date = ?, task_type = ?, updated_at = CURRENT_TIMESTAMP WHERE id = ?", + [title, description, dueDate || null, taskType, taskId], function(err) { if (err) { res.status(500).json({ error: err.message });