Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to add sub-tasks to tasks #27

Open
ghost opened this issue Jan 21, 2016 · 2 comments
Open

Ability to add sub-tasks to tasks #27

ghost opened this issue Jan 21, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 21, 2016

Does your API framework allow the ability to add a subtask to a task? can you give an example if so?

@jhnferraris
Copy link

@dleinbach Any news on this?

@ghost
Copy link
Author

ghost commented Feb 10, 2017

Hey @jhnferraris, I did my own hack and wrote the following function in the src/Task.php... Not sure if its the absoulte best way to do it but it seems to work.

public function insertSubTask(array $data)
    {
        $parent_task_id = empty($data['parent_task_id']) ? 0 : (int) $data['parent_task_id'];
        if ($parent_task_id <= 0) {
            throw new Exception('Required field parent_task_id');
        }
        if (!empty($data['files'])) {
            $file = \TeamWorkPm\Factory::build('file');
            $data['pending_file_attachments'] = $file->upload($data['files']);
            unset($data['files']);
        }
        return $this->rest->post("tasks/$parent_task_id", $data);
    }

then it can be called by doing something like this

public function addsubtask($id,$name,$date){
		$task = TeamWorkPm::build('task');
    	$task_id = $task->insertSubTask(array(
        	'parent_task_id' => $id,
        	'content'      => $name,
        	'notify'       => false,
        	'description'  => '',
        	'due_date'     => date('Ymd', strtotime($date)),
        	'start_date'   => date('Ymd'),
        	'private'      => false,
        	'priority'     => 'low',
        	'estimated_minutes' => 1000,
        	'responsible_party_id' => $this->TwId,
    	));
    	return 'subtask added';
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant