Commits

Wez Furlong committed 1be3913

fix burndown charts; need to factor in initial estimate.

Comments (0)

Files changed (1)

inc/milestone.php

       return "Not authorized to view milestone $name<br>\n";
     }
 
+    $last_estimate = 0;
+    /* compute total "initial estimate" value */
+    foreach (MTrackDB::q(<<<SQL
+select sum(estimated)
+ from ticket_milestones tm
+ left join tickets t on (tm.tid = t.tid)
+where (mid = ?
+  or (mid in (select mid from milestones where pmid = ?))
+)
+SQL
+      , $m->mid, $m->mid)->fetchAll(PDO::FETCH_NUM) as $row) {
+      $last_estimate = round($row[0]);
+    }
+
     /* step 1: find all changes on this milestone and its children */
     $effort = MTrackDB::q("
       select expended, remaining, changedate
     $accum_spent_by_day = array();
     /* accumulated remaining hours by day */
     $accum_remain_by_day = array();
-    $last_remain = 0;
+    $last_remain = $last_estimate;
 
     $current_estimate = null;
     $min_day = null;
     $flot = "bd_graph_" . sha1(join(':', $args) . time());
 
     $height = (int)$params['height'];
-    /* compute total "initial estimate" value */
-    foreach (MTrackDB::q(<<<SQL
-select sum(estimated)
- from ticket_milestones tm
- left join tickets t on (tm.tid = t.tid)
-where (mid = ?
-  or (mid in (select mid from milestones where pmid = ?))
-)
-SQL
-      , $m->mid, $m->mid)->fetchAll(PDO::FETCH_NUM) as $row) {
-      $last_estimate = round($row[0]);
-    }
     $max_y = max($max_y, $last_estimate);
 
     $html = "