Example #1
0
 */
 $period_clause = period2sql($period, $span, "open_date");
 if ($what == "aging") {
     patch_header(array("title" => "Aging Report"));
     patch_reporting_header($group_id);
     echo "\n<H2>Aging Report</H2>";
     $time_now = time();
     //			echo $time_now."<P>";
     if (!$period || $period == "lifespan") {
         $period = "month";
         $span = 12;
     }
     if (!$span) {
         $span = 1;
     }
     $sub_duration = period2seconds($period, 1);
     //                        echo $sub_duration,"<br>";
     for ($counter = 1; $counter <= $span; $counter++) {
         $start = $time_now - $counter * $sub_duration;
         $end = $time_now - ($counter - 1) * $sub_duration;
         $sql = "SELECT avg((close_date-open_date)/(24*60*60)) " . "FROM patch " . "WHERE close_date > 0 " . "AND (open_date >= {$start} AND open_date <= {$end}) " . "AND group_id='{$group_id}'";
         $result = db_query($sql);
         $names[$counter - 1] = date("Y-m-d", $start) . " to " . date("Y-m-d", $end);
         $values[$counter - 1] = (int) (db_result($result, 0, 0) * 1000) / 1000;
     }
     GraphIt($names, $values, "Average Turnaround Time For Closed Patches (days)");
     echo "<P>";
     for ($counter = 1; $counter <= $span; $counter++) {
         $start = $time_now - $counter * $sub_duration;
         $end = $time_now - ($counter - 1) * $sub_duration;
         $sql = "SELECT count(*) " . "FROM patch " . "WHERE open_date >= {$start} " . "AND open_date <= {$end} " . "AND group_id='{$group_id}'";
function period2sql($period_name, $span, $field_name)
{
    $time_now = time();
    $seconds = period2seconds($period_name, $span);
    if (!$seconds) {
        return "";
    }
    return "AND {$field_name}>=" . (string) ($time_now - $seconds) . " \n";
}