function sch_summary($fixfor, $unfixed_thres, $fixed_thres) { global $bug_h; bug_init(); if ($unfixed_thres == "") { $unfixed_thres = 6; } if ($fixed_thres == "") { $fixed_thres = 2; } $ret = ""; $ff = addslashes($fixfor); $allpeople = array(); $result = mysql_query("select distinct sPerson from schedulator.Task " . " where fValid=1 and fDone=0 " . " and sPerson not like '-%-'" . " order by sPerson ", $bug_h); while ($result && ($row = mysql_fetch_row($result))) { $person = $row[0]; $schedname = strtoupper(substr($person, 0, 1)) . substr($person, 1) . "Schedule"; $allpeople[$person] = "<a href='index.php?{$schedname}' title=\"{$person}'s schedulator\">" . "{$person}</a>"; } $query = "select dtDue, sPerson, sTask, sSubTask, " . " fResolved, ixPriority, hrsCurrEst " . " from schedulator.Task " . " where fValid=1 and sFixFor='{$ff}' and fDone=0 " . " order by dtDue, ixPriority, sTask, sSubTask "; $result = mysql_query($query, $bug_h); $dates = array(); $bugs = array(); $skipped = array(); $total_skipped = $total_unfixed = $total_fixed = 0; while ($row = mysql_fetch_row($result)) { $due = $row[0]; $person = $row[1]; $task = $row[2]; $subtask = $row[3]; $resolved = $row[4]; $priority = $row[5]; $currest = $row[6]; # $nicedue = ereg_replace("-", " ", $due); $nicedue = ereg_replace("(....)-(..)-(..)", "\\3", $due); $important_unfixed = !$resolved && $priority <= $unfixed_thres; $important_fixed = $resolved && $priority <= $fixed_thres; if ($important_unfixed || $important_fixed) { if ($important_unfixed) { $total_unfixed++; } if ($important_fixed) { $total_fixed++; } $last_date = $due; } else { $total_skipped++; $skipped[$person]++; continue; } $dates[$due] = $nicedue; $bugs[$person][$due][] = array("task" => $task, "subtask" => $subtask, "resolved" => $resolved, "priority" => $priority, "currest" => $currest); unset($allpeople[$person]); } $nextbounce = sch_next_milestone($fixfor); if ($nextbounce) { $next_str = " (Scheduled for {$nextbounce})"; $daystobounce = (strtotime($nextbounce) - time()) / 24 / 60 / 60; } else { $next_str = " (No bounces scheduled)"; $daystobounce = 365; } $ret .= "<h1>Schedulator Summary for '{$fixfor}'</h1>\n"; $ret .= "<p>Predicted Bounce: {$last_date}{$next_str}<br>\n"; $ret .= " (Bounce goals: " . "fix {$total_unfixed} bugs up to priority {$unfixed_thres}; " . "verify {$total_fixed} bugs up to priority {$fixed_thres}; " . "+{$total_skipped} more bugs not shown.)</p>\n"; $ret .= <<<EOF <style type='text/css'> /* headings */ table.schedsum th { \tfont-weight:normal; margin:0pt; text-align:left; } /* headings except topleft corner */ table.schedsum th.year,th.day,th.person { \tbackground: lightgray } /* typical font size */ table.schedsum th.day,td.bugs { \tfont-size: 8pt; } /* cell backgrounds */ table.schedsum td.superlate { \tbackground: #ee9999; } table.schedsum td.late { \tbackground: #f0f0c0 } /* normal vs. late vs. super-late bugs */ table.schedsum a { \ttext-decoration: none; } table.schedsum span.superlate,a.superlate:link,a.superlate:visited { \tcolor: yellow; background: #aa0000 } table.schedsum span.late,a.late:link,a.late:visited { \tcolor: red; background: yellow } /* resolved vs. unresolved bugs */ table.schedsum a.resolved:link,a.resolved:visited { \tfont-style: italic; } table.schedsum a.unresolved:link,a.unresolved:visited { \tborder-style: solid; border-width: 1px; } /* bug priorities */ table.schedsum a.pri1,a.pri2 { \tfont-size: 150%; } table.schedsum a.pri3 { \tfont-size: 125%; } table.schedsum a.pri6,a.pri7 { \tfont-size: 80%; } /* mouseovers on bugs */ table.schedsum a:hover:link,a:hover:visited { \tcolor: white; background: green; } </style> EOF; $date_list = array_keys($dates); sort($date_list); $person_list = array_keys($bugs); sort($person_list); $rowcount = 2 + count($person_list); $ret .= "<table class='schedsum'>\n"; $ret .= "<tr class='schedsum'><th></th>"; $lastyear = 0; $yearcount = 0; foreach ($date_list as $due) { $year = ereg_replace("(....)-(..)-(..)", "\\1", $due); if (!$lastyear) { $lastyear = $year; } if ($year != $lastyear) { $ret .= "<th class='year' colspan={$yearcount}>{$lastyear}</th>"; $lastyear = $year; $yearcount = 0; } $yearcount++; } $ret .= "<th class='year' colspan={$yearcount}>{$lastyear}</th>"; $ret .= "</tr>\n"; $ret .= "<tr class='schedsum'><th></th>"; $lastmonth = 0; $monthcount = 0; foreach ($date_list as $due) { $month = ereg_replace("(....)-(..)-(..)", "\\1 \\2", $due); if (!$lastmonth) { $lastmonth = $month; } if ($month != $lastmonth) { $ret .= sch_month_out($lastmonth, $monthcount); $lastmonth = $month; $monthcount = 0; } $monthcount++; } $ret .= sch_month_out($lastmonth, $monthcount); $ret .= "</tr>\n"; $ret .= "<tr><th></th>"; foreach ($date_list as $due) { $day = ereg_replace("(....)-(..)-(..)", "\\3", $due); $colclass = sch_dateclass($due, $daystobounce); $ret .= "<th class='day {$colclass}'>" . $day . "</th>\n"; } $ret .= "</tr>\n"; foreach ($person_list as $person) { $schedname = strtoupper(substr($person, 0, 1)) . substr($person, 1) . "Schedule"; $skippy = ""; if ($skipped[$person]) { $skippy = " (+{$skipped[$person]})"; } $ret .= "<tr><th class='person'>" . "<a href='index.php?{$schedname}' title=\"{$person}'s schedulator\">" . "{$person}</a>{$skippy}</th>"; foreach ($date_list as $due) { $dateclass = sch_dateclass($due, $daystobounce); $n = 0; $num_important = 0; $v = ""; if (is_array($bugs[$person][$due])) { foreach ($bugs[$person][$due] as $bug) { $n++; $task = $bug["task"]; $subtask = $bug["subtask"]; $pri = $bug["priority"]; $priclass = "pri{$pri}"; $isbug = $task + 0 . "" == $task; $resolved = $bug["resolved"] || !$isbug; $resclass = $resolved ? "resolved" : "unresolved"; $important = $resolved && $pri <= $fixed_thres || !$resolved && $pri <= $unfixed_thres; if ($important) { $dateclass2 = $dateclass; $num_important++; } else { $dateclass2 = ""; } if ($resolved) { $bugclass = "resolved {$priclass} {$dateclass2}"; } else { $bugclass = "unresolved {$priclass} {$dateclass2}"; } if ($isbug) { $v .= "<a class='{$bugclass}' " . "href='http://fogbugz/?{$task}' " . "title='Bug {$task}: {$subtask}'>{$pri}</a>"; } else { $v .= "<span class='bugclass' " . "title=\"{$task}: {$subtask}\">{$pri}</span>"; } if ($bug["currest"] < 0.05) { $v .= "<sup>?</sup>"; } $v .= " "; } } if ($v == "" || $num_important == 0) { $colclass = ""; } else { $colclass = $dateclass; } $ret .= "<td class='bugs {$colclass}'>{$v}</td>"; } $ret .= "</tr>\n"; } $ret .= "</table>\n"; $allpeople_annotate = array(); foreach ($allpeople as $person => $htmlperson) { if ($skipped[$person]) { $allpeople_annotate[$person] = "{$htmlperson} (+{$skipped[$person]})"; } else { $allpeople_annotate[$person] = "{$htmlperson}"; } } $ret .= "<p><b>Done for this bounce:</b> " . join(", ", array_values($allpeople_annotate)) . "</p>\n"; return $ret; }
function parse($args, $page) { $this->page = $page; global $bug_h; bug_init(); $this->bug_h = $bug_h; $this->savecookie("filter-user"); $this->savecookie("filter-fixfor"); $userix = $_REQUEST["filter-user"]; $fixforix = $_REQUEST["filter-fixfor"]; $this->db = new FogTables($userix, $fixforix); if (!preg_match_all('/"[^"]*"|[^ \\t]+/', $args, $words)) { return "regmatch failed!\n"; } $words = $words[0]; // don't know why I have to do this, exactly... foreach ($words as $key => $value) { if (preg_match('/^"(.*)"$/', $value, $result)) { $words[$key] = $result[1]; } } $this->outdata = ""; $this->out("TaskMaster {$words['0']}"); if ($words[0] == "ESTIMATE") { $this->do_estimate_form(); } else { if ($words[0] == "CREATE") { if ($_REQUEST["cmdCreate"] || $_REQUEST["cmdTestPlans"]) { $this->do_create(); } else { $this->do_create_form(); } } else { if ($words[0] == "ASSIGN") { if ($_REQUEST["cmd"] == "Assign") { $this->do_assign(); unset($this->db); $this->db = new FogTables($userix, $fixforix); } if ($_REQUEST["cmd"] == "Retarget") { $this->do_retarget(); unset($this->db); $this->db = new FogTables($userix, $fixforix); } $this->do_assign_form($_REQUEST["new-user"]); } } } return $this->outdata; }