Пример #1
0
 public function do_execute()
 {
     if (\thebuggenie\core\framework\Context::isInstallmode()) {
         $this->cliEcho("The Bug Genie is not installed\n", 'red');
     } else {
         $this->cliEcho("Finding times to fix\n", 'white', 'bold');
         $issuetimes = \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->getAllSpentTimesForFixing();
         $error_issues = array();
         foreach ($issuetimes as $issue_id => $times) {
             if (count($times) > 1) {
                 $this->cliEcho("Fixing times spent for issue ID {$issue_id}, " . count($times) . " entries\n");
                 $prev_times = \thebuggenie\core\entities\common\Timeable::getZeroedUnitsWithPoints();
                 foreach ($times as $k => $row) {
                     if ($row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_POINTS] < $prev_times['points'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_HOURS] < $prev_times['minutes'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_HOURS] < $prev_times['hours'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_DAYS] < $prev_times['days'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_WEEKS] < $prev_times['weeks'] || $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_MONTHS] < $prev_times['months']) {
                         $error_issues[] = $issue_id;
                     } else {
                         \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->fixRow($row, $prev_times);
                         $prev_times['points'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_POINTS];
                         $prev_times['minutes'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_MINUTES];
                         $prev_times['hours'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_HOURS];
                         $prev_times['days'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_DAYS];
                         $prev_times['weeks'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_WEEKS];
                         $prev_times['months'] += $row[\thebuggenie\core\entities\tables\IssueSpentTimes::SPENT_MONTHS];
                     }
                 }
             }
         }
         foreach (\thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->getAllSpentTimesForFixing() as $issue_id => $times) {
             foreach ($times as $row) {
                 \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->fixHours($row);
             }
             \thebuggenie\core\entities\tables\Issues::getTable()->fixHours($issue_id);
         }
         if (count($error_issues) > 0) {
             $this->cliEcho("\n");
             $this->cliEcho("All spent times have been attempted fixed, but there were some issues that could not be fixed automatically!\n");
             $this->cliEcho("This happens if there has been adjustments in time spent, lowering the value for spent points, minutes, hours, days, weeks or months.\n\n");
             $this->cliEcho("You should fix the issues manually (issue ids corresponding to issue_ids in the timesspent table): ");
             $this->cliEcho(join(', ', $error_issues) . "\n\n");
             $this->cliEcho("Spent times fixed!\n\n", 'green');
         } else {
             $this->cliEcho("All spent times fixed successfully!\n\n", 'green');
         }
         $this->cliEcho("IMPORTANT: Don't run this task again!\n", 'white', 'bold');
     }
 }
Пример #2
0
 public function runIssueEditTimeSpent(framework\Request $request)
 {
     try {
         $entry_id = $request['entry_id'];
         $spenttime = $entry_id ? tables\IssueSpentTimes::getTable()->selectById($entry_id) : new entities\IssueSpentTime();
         if ($issue_id = $request['issue_id']) {
             $issue = entities\Issue::getB2DBTable()->selectById($issue_id);
         } else {
             throw new \Exception('no issue');
         }
         framework\Context::loadLibrary('common');
         $spenttime->editOrAdd($issue, $this->getUser(), array_only_with_default($request->getParameters(), array_merge(array('timespent_manual', 'timespent_specified_type', 'timespent_specified_value', 'timespent_activitytype', 'timespent_comment', 'edited_at'), \thebuggenie\core\entities\common\Timeable::getUnitsWithPoints())));
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('edited' => 'error', 'error' => $e->getMessage()));
     }
     $this->return_data = array('edited' => 'ok');
 }
Пример #3
0
 protected function _upgradeFrom3dot2(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGMilestone::getB2DBTable());
     \thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGProjectsTable::getTable());
     \thebuggenie\core\entities\tables\Log::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGLogTable::getTable());
     \thebuggenie\core\entities\tables\Users::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable());
     \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssuesTable::getTable());
     \thebuggenie\core\entities\tables\Workflows::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGWorkflowsTable::getTable());
     \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssueSpentTimesTable::getTable());
     \thebuggenie\core\entities\tables\Comments::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGCommentsTable::getTable());
     \thebuggenie\core\entities\tables\SavedSearches::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSavedSearchesTable::getTable());
     \thebuggenie\core\entities\tables\Settings::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSettingsTable::getTable());
     \thebuggenie\core\entities\tables\Notifications::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGNotificationsTable::getTable());
     \thebuggenie\core\entities\tables\Permissions::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGPermissionsTable::getTable());
     \thebuggenie\core\entities\Dashboard::getB2DBTable()->create();
     \thebuggenie\core\entities\DashboardView::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGDashboardViewsTable::getTable());
     \thebuggenie\core\entities\ApplicationPassword::getB2DBTable()->create();
     \thebuggenie\core\entities\NotificationSetting::getB2DBTable()->create();
     $transaction = \b2db\Core::startTransaction();
     // Upgrade user passwords
     switch ($request['upgrade_passwords']) {
         case 'manual':
             $password = $request['manual_password'];
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 $user->setPassword($password);
                 $user->save();
             }
             break;
         case 'auto':
             $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email';
             foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) {
                 if ($field == 'username' && trim($user->getUsername())) {
                     $user->setPassword(trim($user->getUsername()));
                     $user->save();
                 } elseif ($field == 'email' && trim($user->getEmail())) {
                     $user->setPassword(trim($user->getEmail()));
                     $user->save();
                 }
             }
             break;
     }
     $adminuser = \thebuggenie\core\entities\User::getB2DBTable()->selectById(1);
     $adminuser->setPassword($request['admin_password']);
     $adminuser->save();
     // Add new settings
     framework\Settings::saveSetting(framework\Settings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1);
     foreach ($request->getParameter('status') as $scope_id => $status_id) {
         $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->selectById((int) $scope_id);
         if ($scope instanceof \thebuggenie\core\entities\Scope) {
             $epic = new \thebuggenie\core\entities\Issuetype();
             $epic->setName('Epic');
             $epic->setIcon('epic');
             $epic->setDescription('Issue type suited for entering epics');
             $epic->setScope($scope_id);
             $epic->save();
             framework\Settings::saveSetting('issuetype_epic', $epic->getID(), 'core', $scope_id);
             foreach (\thebuggenie\core\entities\tables\Workflows::getTable()->getAll((int) $scope_id) as $workflow) {
                 $transition = new \thebuggenie\core\entities\WorkflowTransition();
                 $steps = $workflow->getSteps();
                 $step = array_shift($steps);
                 $step->setLinkedStatusID((int) $status_id);
                 $step->save();
                 $transition->setOutgoingStep($step);
                 $transition->setName('Issue created');
                 $transition->setWorkflow($workflow);
                 $transition->setScope($scope);
                 $transition->setDescription('This is the initial transition for issues using this workflow');
                 $transition->save();
                 $workflow->setInitialTransition($transition);
                 $workflow->save();
             }
             \thebuggenie\core\entities\ActivityType::loadFixtures($scope);
         }
     }
     $transaction->commitAndEnd();
     framework\Context::finishUpgrading();
     foreach (framework\Context::getModules() as $module) {
         $module->upgrade();
     }
     $this->upgrade_complete = true;
 }
Пример #4
0
 protected function _upgradeFrom4dot1dot5(framework\Request $request)
 {
     set_time_limit(0);
     \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\Issue::getB2DBTable());
     \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\IssueSpentTime::getB2DBTable());
     \thebuggenie\core\entities\tables\IssueEstimates::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\IssueEstimatesTable::getTable());
     $this->upgrade_complete = true;
     $this->current_version = '4.1.6';
 }
Пример #5
0
 public function fixHours($issue_id)
 {
     $times = IssueSpentTimes::getTable()->getSpentTimeSumsByIssueId($issue_id);
     $crit = $this->getCriteria();
     $crit->addUpdate(self::SPENT_HOURS, $times['hours']);
     $this->doUpdateById($crit, $issue_id);
 }
Пример #6
0
 protected function _populateBurndownData()
 {
     if ($this->_burndowndata === null) {
         $this->_burndowndata = array();
         $issues = array();
         foreach ($this->getIssues() as $issue) {
             $issues[] = (int) $issue->getID();
             foreach ($issue->getChildIssues() as $child_issue) {
                 $issues[] = (int) $child_issue->getID();
             }
         }
         $estimations = tables\IssueEstimates::getTable()->getEstimatesByDateAndIssueIDs($this->getStartingDate(), $this->getScheduledDate(), $issues);
         $spent_times = tables\IssueSpentTimes::getTable()->getSpentTimesByDateAndIssueIDs($this->getStartingDate(), $this->getScheduledDate(), $issues);
         $burndown = array();
         foreach ($spent_times['hours'] as $key => $val) {
             $spent_times['hours'][$key] = round($spent_times['hours'][$key] / 100, 2);
         }
         foreach ($estimations['hours'] as $key => $val) {
             $burndown['hours'][$key] = array_key_exists($key, $spent_times['hours']) ? $val - $spent_times['hours'][$key] : $val;
         }
         foreach ($estimations['points'] as $key => $val) {
             $burndown['points'][$key] = array_key_exists($key, $spent_times['points']) ? $val - $spent_times['points'][$key] : $val;
         }
         $this->_burndowndata = array('estimations' => $estimations, 'spent_times' => $spent_times, 'burndown' => $burndown);
     }
 }
Пример #7
0
 protected function _recalculateIssueTimes()
 {
     $times = tables\IssueSpentTimes::getTable()->getSpentTimeSumsByIssueId($this->getIssueID());
     $this->getIssue()->setSpentPoints($times['points']);
     $this->getIssue()->setSpentMinutes($times['minutes']);
     $this->getIssue()->setSpentHours($times['hours']);
     $this->getIssue()->setSpentDays($times['days']);
     $this->getIssue()->setSpentWeeks($times['weeks']);
     $this->getIssue()->setSpentMonths($times['months']);
 }
Пример #8
0
 public function componentIssueSpenttime()
 {
     $this->entry = tables\IssueSpentTimes::getTable()->selectById($this->entry_id);
 }
Пример #9
0
 public function runIssueEditTimeSpent(framework\Request $request)
 {
     $entry_id = $request['entry_id'];
     $spenttime = $entry_id ? tables\IssueSpentTimes::getTable()->selectById($entry_id) : new entities\IssueSpentTime();
     if ($issue_id = $request['issue_id']) {
         try {
             $issue = entities\Issue::getB2DBTable()->selectById($issue_id);
         } catch (\Exception $e) {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderText('fail');
         }
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderText('no issue');
     }
     framework\Context::loadLibrary('common');
     $spenttime->editOrAdd($issue, $this->getUser(), array_only_with_default($request->getParameters(), array_merge(array('timespent_manual', 'timespent_specified_type', 'timespent_specified_value', 'timespent_activitytype', 'timespent_comment', 'edited_at'), \thebuggenie\core\entities\common\Timeable::getUnitsWithPoints())));
     return $this->renderJSON(array('edited' => 'ok', 'issue_id' => $issue_id, 'timesum' => array_sum($spenttime->getIssue()->getSpentTime()), 'spenttime' => entities\Issue::getFormattedTime($spenttime->getIssue()->getSpentTime(true, true)), 'percentbar' => $this->getComponentHTML('main/percentbar', array('percent' => $issue->getEstimatedPercentCompleted(), 'height' => 3)), 'timeentries' => $this->getComponentHTML('main/issuespenttimes', array('issue' => $spenttime->getIssue()))));
 }
Пример #10
0
 public function runIssueEditTimeSpent(framework\Request $request)
 {
     $entry_id = $request['entry_id'];
     $spenttime = $entry_id ? tables\IssueSpentTimes::getTable()->selectById($entry_id) : new entities\IssueSpentTime();
     if ($issue_id = $request['issue_id']) {
         try {
             $issue = entities\Issue::getB2DBTable()->selectById($issue_id);
         } catch (\Exception $e) {
             $this->getResponse()->setHttpStatus(400);
             return $this->renderText('fail');
         }
     } else {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderText('no issue');
     }
     if (!$spenttime->getID()) {
         if ($request['timespent_manual']) {
             $times = entities\Issue::convertFancyStringToTime($request['timespent_manual']);
         } else {
             $times = array('points' => 0, 'hours' => 0, 'days' => 0, 'weeks' => 0, 'months' => 0);
             $times[$request['timespent_specified_type']] = $request['timespent_specified_value'];
         }
         $spenttime->setIssue($issue);
         $spenttime->setUser($this->getUser());
     } else {
         $times = array('points' => $request['points'], 'hours' => $request['hours'], 'days' => $request['days'], 'weeks' => $request['weeks'], 'months' => $request['months']);
         $edited_at = $request['edited_at'];
         $spenttime->setEditedAt(mktime(0, 0, 1, $edited_at['month'], $edited_at['day'], $edited_at['year']));
     }
     $times['hours'] *= 100;
     $spenttime->setSpentPoints($times['points']);
     $spenttime->setSpentHours($times['hours']);
     $spenttime->setSpentDays($times['days']);
     $spenttime->setSpentWeeks($times['weeks']);
     $spenttime->setSpentMonths($times['months']);
     $spenttime->setActivityType($request['timespent_activitytype']);
     $spenttime->setComment($request['timespent_comment']);
     $spenttime->save();
     $spenttime->getIssue()->saveSpentTime();
     $timesum = array_sum($spenttime->getIssue()->getSpentTime());
     return $this->renderJSON(array('edited' => 'ok', 'issue_id' => $issue_id, 'timesum' => $timesum, 'spenttime' => entities\Issue::getFormattedTime($spenttime->getIssue()->getSpentTime()), 'percentbar' => $this->getComponentHTML('main/percentbar', array('percent' => $issue->getEstimatedPercentCompleted(), 'height' => 3)), 'timeentries' => $this->getComponentHTML('main/issuespenttimes', array('issue' => $spenttime->getIssue()))));
 }
Пример #11
0
 protected function moveIssues($project_id, $to_scope_id)
 {
     $crit = Issues::getTable()->getCriteria();
     $crit->addWhere('issues.project_id', $project_id);
     $crit->addSelectionColumn('issues.id', 'id');
     $issue_ids = [];
     if ($res = Issues::getTable()->doSelect($crit)) {
         while ($row = $res->getNextRow()) {
             $issue_ids[] = $row['id'];
         }
     }
     $this->cliEcho("------------------\n");
     $this->cliEcho('Moving ');
     $this->cliEcho(count($issue_ids), 'white', 'bold');
     $this->cliEcho(" issues\n");
     $this->cliEcho("------------------\n");
     if (!$issue_ids) {
         return;
     }
     $this->cliEcho("Moving comments... ");
     $comments_crit = Comments::getTable()->getCriteria();
     $comments_crit->addUpdate('comments.scope', $to_scope_id);
     $comments_crit->addWhere('comments.target_id', $issue_ids, Criteria::DB_IN);
     $comments_crit->addWhere('comments.target_type', Comment::TYPE_ISSUE);
     Comments::getTable()->doUpdate($comments_crit);
     $this->cliEcho(" done\n");
     $this->cliEcho("Moving log items... ");
     $logs_crit = Log::getTable()->getCriteria();
     $logs_crit->addUpdate('log.scope', $to_scope_id);
     $logs_crit->addWhere('log.target', $issue_ids, Criteria::DB_IN);
     $logs_crit->addWhere('log.target_type', Log::TYPE_ISSUE);
     Log::getTable()->doUpdate($logs_crit);
     $this->cliEcho(" done\n");
     $this->cliEcho("Moving attachments... ");
     $file_ids_crit = IssueFiles::getTable()->getCriteria();
     $file_ids_crit->addWhere('issuefiles.issue_id', $issue_ids, Criteria::DB_IN);
     $file_ids_crit->addSelectionColumn('issuefiles.file_id', 'file_id');
     $file_ids_crit->addSelectionColumn('issuefiles.id', 'id');
     $file_ids = [];
     $issue_file_ids = [];
     if ($res = IssueFiles::getTable()->doSelect($file_ids_crit)) {
         while ($row = $res->getNextRow()) {
             $file_ids[] = $row['file_id'];
             $issue_file_ids[] = $row['id'];
         }
     }
     if (count($file_ids)) {
         $file_crit = Files::getTable()->getCriteria();
         $file_crit->addUpdate('files.scope', $to_scope_id);
         $file_crit->addWhere('files.id', $file_ids, Criteria::DB_IN);
         Files::getTable()->doUpdate($file_crit);
         $issue_file_crit = IssueFiles::getTable()->getCriteria();
         $issue_file_crit->addUpdate('issuefiles.scope', $to_scope_id);
         $issue_file_crit->addWhere('issuefiles.id', $issue_file_ids, Criteria::DB_IN);
         IssueFiles::getTable()->doUpdate($issue_file_crit);
     }
     $this->cliEcho(" done\n");
     $this->cliEcho("Moving calculations and estimations... ");
     $estimates_crit = IssueEstimates::getTable()->getCriteria();
     $estimates_crit->addUpdate('issue_estimates.scope', $to_scope_id);
     $estimates_crit->addWhere('issue_estimates.issue_id', $issue_ids, Criteria::DB_IN);
     IssueEstimates::getTable()->doUpdate($estimates_crit);
     $spent_crit = IssueSpentTimes::getTable()->getCriteria();
     $spent_crit->addUpdate('issue_spenttimes.scope', $to_scope_id);
     $spent_crit->addWhere('issue_spenttimes.issue_id', $issue_ids, Criteria::DB_IN);
     IssueSpentTimes::getTable()->doUpdate($spent_crit);
     $this->cliEcho(" done\n");
     $this->cliEcho("Moving links, related and affected items");
     $tables = ['\\thebuggenie\\core\\entities\\tables\\IssueAffectsBuild' => 'issueaffectsbuild', '\\thebuggenie\\core\\entities\\tables\\IssueAffectsComponent' => 'issueaffectscomponent', '\\thebuggenie\\core\\entities\\tables\\IssueAffectsEdition' => 'issueaffectsedition'];
     foreach ($tables as $class_name => $table_name) {
         $crit = $class_name::getTable()->getCriteria();
         $crit->addUpdate($table_name . '.scope', $to_scope_id);
         $crit->addWhere($table_name . '.issue', $issue_ids, Criteria::DB_IN);
         $class_name::getTable()->doUpdate($crit);
     }
     $links_crit = Links::getTable()->getCriteria();
     $links_crit->addUpdate('links.scope', $to_scope_id);
     $links_crit->addWhere('links.target_id', $issue_ids, Criteria::DB_IN);
     $links_crit->addWhere('links.target_type', 'issue');
     Links::getTable()->doUpdate($links_crit);
     $related_crit = IssueRelations::getTable()->getCriteria();
     $related_crit->addUpdate('issuerelations.scope', $to_scope_id);
     $ctn = $related_crit->returnCriterion('issuerelations.child_id', $issue_ids, Criteria::DB_IN);
     $ctn->addOr('issuerelations.parent_id', $issue_ids, Criteria::DB_IN);
     $related_crit->addWhere($ctn);
     $votes_crit = Votes::getTable()->getCriteria();
     $votes_crit->addUpdate('votes.scope', $to_scope_id);
     $votes_crit->addWhere('votes.target', $issue_ids, Criteria::DB_IN);
     Votes::getTable()->doUpdate($votes_crit);
     $this->cliEcho(" done\n");
     $this->cliEcho("Updating user issue bookmarks");
     $user_issues_crit = UserIssues::getTable()->getCriteria();
     $user_issues_crit->addUpdate('userissues.scope', $to_scope_id);
     $user_issues_crit->addWhere('userissues.issue', $issue_ids, Criteria::DB_IN);
     UserIssues::getTable()->doUpdate($user_issues_crit);
     $this->cliEcho(" done\n");
     $this->updateCustomFields($issue_ids, $to_scope_id);
     $crit = Issues::getTable()->getCriteria();
     $crit->addUpdate('issues.scope', $to_scope_id);
     $crit->addWhere('issues.id', $issue_ids, Criteria::DB_IN);
     Issues::getTable()->doUpdate($crit);
     $this->cliEcho("------------------\n");
     $this->cliEcho("Done moving issues\n");
     $this->cliEcho("------------------\n");
 }
Пример #12
0
 protected function _populateBurndownData()
 {
     if ($this->_burndowndata === null) {
         $this->_burndowndata = array();
         $issues = array();
         foreach ($this->getIssues() as $issue) {
             $issues[] = (int) $issue->getID();
             foreach ($issue->getChildIssues() as $child_issue) {
                 $issues[] = (int) $child_issue->getID();
             }
         }
         $estimations = tables\IssueEstimates::getTable()->getEstimatesByDateAndIssueIDs($this->getStartingDate(), $this->getScheduledDate(), $issues);
         $spent_times = tables\IssueSpentTimes::getTable()->getSpentTimesByDateAndIssueIDs($this->getStartingDate(), $this->getScheduledDate(), $issues);
         $burndown = array();
         foreach ($spent_times['hours'] as $key => $val) {
             $spent_times['hours'][$key] = round($spent_times['hours'][$key] / 100, 2);
         }
         $total_estimations_hours = array_sum($estimations['hours']);
         if (array_sum($spent_times['hours']) > $total_estimations_hours) {
             $total_estimations_hours = array_sum($spent_times['hours']);
         }
         $prev_key = null;
         foreach ($estimations['hours'] as $key => $val) {
             if (!is_null($prev_key) && array_key_exists($prev_key, $spent_times['hours'])) {
                 $total_estimations_hours -= $spent_times['hours'][$prev_key];
             } else {
                 if (isset($spent_times['hours_spent_before'])) {
                     $spent_times['hours_spent_before'] = round($spent_times['hours_spent_before'] / 100, 2);
                     $total_estimations_hours -= $spent_times['hours_spent_before'];
                 }
             }
             $burndown['hours'][$key] = $total_estimations_hours;
             $prev_key = $key;
         }
         $total_estimations_points = array_sum($estimations['points']);
         if (array_sum($spent_times['points']) > $total_estimations_points) {
             $total_estimations_points = array_sum($spent_times['points']);
         }
         $prev_key = null;
         foreach ($estimations['points'] as $key => $val) {
             if (!is_null($prev_key) && array_key_exists($prev_key, $spent_times['points'])) {
                 $total_estimations_points -= $spent_times['points'][$prev_key];
             } else {
                 if (isset($spent_times['points_spent_before'])) {
                     $total_estimations_points -= $spent_times['points_spent_before'];
                 }
             }
             $burndown['points'][$key] = $total_estimations_points;
             $prev_key = $key;
         }
         $this->_burndowndata = array('estimations' => $estimations, 'spent_times' => $spent_times, 'burndown' => $burndown);
     }
 }