コード例 #1
0
function task_activity_graph($id_task, $width = 900, $height = 230, $area = false, $return = false)
{
    global $config;
    $task = get_db_row("ttask", "id", $id_task);
    $output = "";
    $start_unixdate = strtotime($task["start"]);
    $end_unixdate = strtotime("now");
    $period = $end_unixdate - $start_unixdate;
    $resolution = 50;
    $interval = (int) ($period / $resolution);
    if (!$area) {
        $output .= __("Each bar is") . " " . human_time_description_raw($interval);
        $output .= "<br>";
    }
    $data = get_db_all_rows_sql("SELECT tworkunit.duration as duration, \n            tworkunit.timestamp as timestamp  FROM tworkunit, tworkunit_task, ttask \n\t\t\tWHERE tworkunit_task.id_task = {$id_task}\n\t\t\tAND tworkunit_task.id_workunit = tworkunit.id GROUP BY tworkunit.id  ORDER BY timestamp ASC");
    if ($data === false) {
        $data = array();
    }
    $min_necessary = 1;
    // Check available data
    if (count($data) < $min_necessary) {
        return;
    }
    // Set initial conditions
    $chart = array();
    $names = array();
    $chart2 = array();
    // Calculate chart data
    for ($i = 0; $i < $resolution; $i++) {
        $timestamp = $start_unixdate + $interval * $i;
        $total = 0;
        $j = 0;
        while (isset($data[$j])) {
            $dftime = strtotime($data[$j]['timestamp']);
            if ($dftime >= $timestamp && $dftime < $timestamp + $interval) {
                $total += $data[$j]['duration'];
            }
            $j++;
        }
        $time_format = "M d";
        $timestamp_human = clean_flash_string(date($time_format, $timestamp));
        $chart2[$timestamp_human] = $total;
    }
    $colors['1day']['color'] = "#2179B1";
    $colors['1day']['border'] = "#000";
    $colors['1day']['alpha'] = 100;
    foreach ($chart2 as $key => $ch) {
        $chart3[$key]['1day'] = $ch;
    }
    $legend = array();
    $xaxisname = __('Days');
    $yaxisname = __('Hours');
    if ($area) {
        $output .= area_graph($config['flash_charts'], $chart3, $width, $height, $colors, $legend, '', '', '', $yaxisname, '', '', $config['font'], $config['fontsize']);
    } else {
        $output .= vbar_graph($config['flash_charts'], $chart3, $width, $height, $colors, $legend, $xaxisname, $yaxisname, "", "", $config['font'], $config['fontsize']);
    }
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
コード例 #2
0
//TOP 10 ESTIMATED SALES
$where_clause_top10 = $where_clause . " AND progress < 100";
$leads_sales = crm_get_total_sales_lead($where_clause_top10);
if ($read && $enterprise) {
    $leads_sales = crm_get_user_leads($config['id_user'], $leads_sales);
}
if ($leads_sales != false) {
    $leads_sales_content = print_table(crm_print_estimated_sales_leads($leads_sales), true);
} else {
    $leads_sales_content = '<br><div class="pie_frame">' . __('No data to show') . '</div>';
}
echo print_container('top_10_sales', __('Top 10 estimated sales'), $leads_sales_content, 'no', true, true, "container_simple_title", "container_simple_div");
//NEW LEADS
$leads_creation = crm_get_total_leads_creation($where_clause);
if ($read && $enterprise) {
    $leads_creation = crm_get_user_leads($config['id_user'], $leads_creation);
}
$leads_creation = crm_get_data_lead_creation_graph($leads_creation);
if ($leads_creation !== false) {
    $area_width = 400;
    $area_height = 250;
    if ($clean_output) {
        $area_width = 240;
        $area_height = 155;
    }
    $leads_creation_content = area_graph($config['flash_charts'], $leads_creation, $area_width, $area_height, "#2179B1", '', '', '', "", "", $config["base_url"], "", '', '', '', $ttl);
} else {
    $leads_creation_content = __('No data to show');
}
$leads_creation_content = '<br><div class="pie_frame"><br>' . $leads_creation_content . '</div>';
echo print_container('new_leads', __('New leads'), $leads_creation_content, 'no', true, true, "container_simple_title", "container_simple_div");