summaryrefslogtreecommitdiff
path: root/app/Model/SubtaskTimeTracking.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/SubtaskTimeTracking.php')
-rw-r--r--app/Model/SubtaskTimeTracking.php45
1 files changed, 16 insertions, 29 deletions
diff --git a/app/Model/SubtaskTimeTracking.php b/app/Model/SubtaskTimeTracking.php
index a984533f..6d4a3467 100644
--- a/app/Model/SubtaskTimeTracking.php
+++ b/app/Model/SubtaskTimeTracking.php
@@ -135,8 +135,13 @@ class SubtaskTimeTracking extends Base
public function getUserCalendarEvents($user_id, $start, $end)
{
$result = $this->getUserQuery($user_id)
- ->addCondition($this->getCalendarCondition($start, $end))
- ->findAll();
+ ->addCondition($this->getCalendarCondition(
+ $this->dateParser->getTimestampFromIsoFormat($start),
+ $this->dateParser->getTimestampFromIsoFormat($end),
+ 'start',
+ 'end'
+ ))
+ ->findAll();
$result = $this->timetable->calculateEventsIntersect($user_id, $result, $start, $end);
@@ -154,38 +159,20 @@ class SubtaskTimeTracking extends Base
*/
public function getProjectCalendarEvents($project_id, $start, $end)
{
- $result = $this->getProjectQuery($project_id)
- ->addCondition($this->getCalendarCondition($start, $end))
- ->findAll();
+ $result = $this
+ ->getProjectQuery($project_id)
+ ->addCondition($this->getCalendarCondition(
+ $this->dateParser->getTimestampFromIsoFormat($start),
+ $this->dateParser->getTimestampFromIsoFormat($end),
+ 'start',
+ 'end'
+ ))
+ ->findAll();
return $this->toCalendarEvents($result);
}
/**
- * Get time slots that should be displayed in the calendar time range
- *
- * @access private
- * @param string $start ISO8601 start date
- * @param string $end ISO8601 end date
- * @return string
- */
- private function getCalendarCondition($start, $end)
- {
- $start_time = $this->dateParser->getTimestampFromIsoFormat($start);
- $end_time = $this->dateParser->getTimestampFromIsoFormat($end);
- $start_column = $this->db->escapeIdentifier('start');
- $end_column = $this->db->escapeIdentifier('end');
-
- $conditions = array(
- "($start_column >= '$start_time' AND $start_column <= '$end_time')",
- "($start_column <= '$start_time' AND $end_column >= '$start_time')",
- "($start_column <= '$start_time' AND $end_column = '0')",
- );
-
- return '('.implode(' OR ', $conditions).')';
- }
-
- /**
* Convert a record set to calendar events
*
* @access private