diff options
author | emkael <emkael@tlen.pl> | 2020-05-05 14:25:42 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2020-05-05 14:25:42 +0200 |
commit | 62827e6cf470449c117624058fb36ad94804bcc0 (patch) | |
tree | 10cd1e4d36c34b694acfadaa69fc7f6ae2b1eabd /plugins/Timetrackingeditor/Model/SubtaskTimeTrackingCreationModel.php | |
parent | 7b66ddf2e4fbdb837e78d8b7dbaa9fc38391bc32 (diff) |
Diffstat (limited to 'plugins/Timetrackingeditor/Model/SubtaskTimeTrackingCreationModel.php')
-rw-r--r-- | plugins/Timetrackingeditor/Model/SubtaskTimeTrackingCreationModel.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/Timetrackingeditor/Model/SubtaskTimeTrackingCreationModel.php b/plugins/Timetrackingeditor/Model/SubtaskTimeTrackingCreationModel.php new file mode 100644 index 00000000..806d9345 --- /dev/null +++ b/plugins/Timetrackingeditor/Model/SubtaskTimeTrackingCreationModel.php @@ -0,0 +1,53 @@ +<?php + +namespace Kanboard\Plugin\Timetrackingeditor\Model; + +use Kanboard\Core\Base; +use Kanboard\Event\TaskEvent; +use Kanboard\Model\SubtaskTimeTrackingModel; + +/** + * Task Creation + * + * @package Kanboard\Plugin\Timetrackingeditor\Model + * @author Thomas Stinner + */ +class SubtaskTimeTrackingCreationModel extends Base +{ + /** + * Create a time tracking event + * + * @access public + * @param array $values Form values + * @return integer + */ + public function create(array $values) + { + + $this->prepare($values); + $subtrackingid = $this->db->table(SubtaskTimeTrackingModel::TABLE)->persist($values); + + return (int) $subtrackingid; + } + + /** + * Prepare data + * + * @access public + * @param array $values Form values + */ + public function prepare(array &$values) + { + if ($this->userSession->isLogged()) { + $values['user_id'] = $this->userSession->getId(); + } + + $values["subtask_id"] = $values["opposite_subtask_id"]; + + $this->helper->model->removeFields($values, array('project_id', 'task_id', 'opposite_subtask_id', 'subtask', 'add_another')); + + // Calculate end time + $values = $this->dateParser->convert($values, array('start'), true); + $values["end"] = $values["start"] + ($values['time_spent']*60*60); + } +} |