function graph_ticket_oc_histogram($incidents, $width = 650, $height = 250, $ttl = 1)
{
    global $config;
    $dates = array();
    $dates['start'] = array();
    $dates['end'] = array();
    // Iterates through the incidents array to fill the dates array
    foreach ($incidents as $key => $incident) {
        $start = "0000-00-00";
        if (isset($incident['inicio'])) {
            $udate = strtotime($incident['inicio']);
            $start = date("Y-m-d", $udate);
        }
        $dates['start'][] = $start;
        $end = "";
        if ($incident['estado'] == 7) {
            // Closed
            if (!isset($incident['cierre']) || $incident['cierre'] == "0000-00-00 00:00:00") {
                $end = date("Y-m-d");
            } else {
                $udate = strtotime($incident['cierre']);
                $end = date("Y-m-d", $udate);
            }
        }
        $dates['end'][] = $end;
    }
    $dates_keys = $dates['start'] + $dates['end'];
    $dates_keys[] = date("Y-m-d");
    $dates_keys = array_unique($dates_keys);
    sort($dates_keys);
    $first_date = $dates_keys[0];
    $today_time = strtotime(date("Y-m-d"));
    $dates_keys = array();
    for ($i = strtotime($first_date); $i <= $today_time; $i = strtotime('+1 day', $i)) {
        $dates_keys[] = date("Y-m-d", $i);
    }
    $data_oc = array_fill_keys($dates_keys, array(0 => 0, 1 => 0));
    // $dates['start'] and $dates['end'] has the same number of elements and
    // are correlative since they are two columns extracted from the same array
    for ($i = 0; $i < count($dates['start']); $i++) {
        foreach ($dates_keys as $date) {
            if ($date >= $dates['start'][$i] && (empty($dates['end'][$i]) || $date < $dates['end'][$i])) {
                $data_oc[$date][1] += 1;
            } elseif (!empty($dates['end'][$i]) && $date >= $dates['end'][$i]) {
                $data_oc[$date][0] += 1;
            }
        }
    }
    if ($config["flash_charts"]) {
        $color = array();
        $color[0]['color'] = "088A08";
        $color[0]['alpha'] = "0";
        $color[0]['border'] = "088A08";
        $color[1]['color'] = "B40404";
        $color[1]['alpha'] = "70";
        $color[1]['border'] = "B40404";
    }
    $legend = array();
    $legend[0] = __('Resolved');
    $legend[1] = __('Created');
    return stacked_area_graph($config["flash_charts"], $data_oc, $width, $height, $color, $legend, '', '', '', '', '', '', '', '', $ttl, $config["base_url"]);
}
Beispiel #2
0
    }
    $i++;
}
$currency_table = print_table($table, true);
switch ($search_invoice_type) {
    case 'Submitted':
        $container_title = __("Submitted billing history");
        break;
    case 'Received':
        $container_title = __("Received billing history");
        break;
    default:
        $container_title = __(" Submitted billing history");
        break;
}
$invoicing_graph = stacked_area_graph($config["flash_charts"], $inv_data_currency, 650, 250, null, $legend, '', '', '', '', '', '', '', '', $graph_ttl, $config["base_url"]);
$container_invoicing_graph = '<div class="pie_frame">' . $invoicing_graph . "</div>";
echo print_container('history_invoiced', $container_title, $container_invoicing_graph, 'no', true, true, "container_simple_title", "container_simple_div");
//Transform data for companies invoiced graph
$comp_invoiced_data = array();
foreach ($inv_data_company as $comp => $val) {
    $comp_name = safe_output($comp);
    $comp_name = substr($comp_name, 0, 15);
    $val_aux = $val / 1000;
    $val_aux = sprintf("%.2f k ", $val_aux);
    $comp_name = $comp_name . " (" . $val_aux . ")";
    $comp_invoiced_data[$comp_name] = $val;
}
switch ($search_invoice_type) {
    case 'Submitted':
        $container_title = __("Submitted billing per company");