summaryrefslogtreecommitdiff
path: root/app/Model/SubtaskTimeTracking.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-24 20:39:06 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-24 20:39:06 -0400
commit6efac784fcc1a2e83bb7b43fc7841448b5975cba (patch)
treea083b3c8b86deca9c4f23bcb15cfafeec86924e8 /app/Model/SubtaskTimeTracking.php
parent58c96b8c4ec3f326b25e6b55f133fc067345cd57 (diff)
Add timer for subtasks and remove settings for subtask time tracking
Diffstat (limited to 'app/Model/SubtaskTimeTracking.php')
-rw-r--r--app/Model/SubtaskTimeTracking.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/app/Model/SubtaskTimeTracking.php b/app/Model/SubtaskTimeTracking.php
index 93a698b6..51743198 100644
--- a/app/Model/SubtaskTimeTracking.php
+++ b/app/Model/SubtaskTimeTracking.php
@@ -20,6 +20,27 @@ class SubtaskTimeTracking extends Base
const TABLE = 'subtask_time_tracking';
/**
+ * Get query to check if a timer is started for the given user and subtask
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @return string
+ */
+ public function getTimerQuery($user_id)
+ {
+ return sprintf(
+ "SELECT %s FROM %s WHERE %s='%d' AND %s='0' AND %s=%s",
+ $this->db->escapeIdentifier('start'),
+ $this->db->escapeIdentifier(self::TABLE),
+ $this->db->escapeIdentifier('user_id'),
+ $user_id,
+ $this->db->escapeIdentifier('end'),
+ $this->db->escapeIdentifier('subtask_id'),
+ Subtask::TABLE.'.id'
+ );
+ }
+
+ /**
* Get query for user timesheet (pagination)
*
* @access public
@@ -217,7 +238,7 @@ class SubtaskTimeTracking extends Base
{
return $this->db
->table(self::TABLE)
- ->insert(array('subtask_id' => $subtask_id, 'user_id' => $user_id, 'start' => time()));
+ ->insert(array('subtask_id' => $subtask_id, 'user_id' => $user_id, 'start' => time(), 'end' => 0));
}
/**