Beispiel #1
0
/**
 * Returns an array of bugnote stats
 * @param int $p_project_id project id
 * @param string $p_from Starting date (yyyy-mm-dd) inclusive, if blank, then ignored.
 * @param string $p_to Ending date (yyyy-mm-dd) inclusive, if blank, then ignored.
 * @param int $p_cost cost
 * @return array array of bugnote stats
 * @access public
 */
function bugnote_stats_get_project_array($p_project_id, $p_from, $p_to, $p_cost)
{
    $c_project_id = db_prepare_int($p_project_id);
    $c_to = strtotime($p_to) + SECONDS_PER_DAY - 1;
    $c_from = strtotime($p_from);
    if ($c_to === false || $c_from === false) {
        error_parameters(array($p_from, $p_to));
        trigger_error(ERROR_GENERIC, ERROR);
    }
    $c_cost = db_prepare_double($p_cost);
    $t_bug_table = db_get_table('mantis_bug_table');
    $t_user_table = db_get_table('mantis_user_table');
    $t_bugnote_table = db_get_table('mantis_bugnote_table');
    if (!is_blank($c_from)) {
        $t_from_where = " AND bn.date_submitted >= {$c_from}";
    } else {
        $t_from_where = '';
    }
    if (!is_blank($c_to)) {
        $t_to_where = " AND bn.date_submitted <= {$c_to}";
    } else {
        $t_to_where = '';
    }
    if (ALL_PROJECTS != $c_project_id) {
        $t_project_where = " AND b.project_id = '{$c_project_id}' AND bn.bug_id = b.id ";
    } else {
        $t_project_where = '';
    }
    $t_results = array();
    $query = "SELECT username, realname, summary, bn.bug_id, SUM(time_tracking) AS sum_time_tracking\n\t\t\tFROM {$t_user_table} u, {$t_bugnote_table} bn, {$t_bug_table} b\n\t\t\tWHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id\n\t\t\t{$t_project_where} {$t_from_where} {$t_to_where}\n\t\t\tGROUP BY bn.bug_id, u.username, u.realname, b.summary\n\t\t\tORDER BY bn.bug_id";
    $result = db_query($query);
    $t_cost_min = $c_cost / 60;
    while ($row = db_fetch_array($result)) {
        $t_total_cost = $t_cost_min * $row['sum_time_tracking'];
        $row['cost'] = $t_total_cost;
        $t_results[] = $row;
    }
    return $t_results;
}
Beispiel #2
0
function bugnote_stats_get_project_array($p_project_id, $p_from, $p_to, $p_cost)
{
    $c_project_id = db_prepare_int($p_project_id);
    $c_to = db_prepare_date($p_to);
    $c_from = db_prepare_date($p_from);
    $c_cost = db_prepare_double($p_cost);
    // MySQL
    $t_bug_table = config_get('mantis_bug_table');
    $t_user_table = config_get('mantis_user_table');
    $t_bugnote_table = config_get('mantis_bugnote_table');
    if (!is_blank($c_from)) {
        $t_from_where = " AND bn.date_submitted >= '{$c_from} 00:00:00'";
    } else {
        $t_from_where = '';
    }
    if (!is_blank($c_to)) {
        $t_to_where = " AND bn.date_submitted <= '{$c_to} 23:59:59'";
    } else {
        $t_to_where = '';
    }
    if (ALL_PROJECTS != $c_project_id) {
        $t_project_where = " AND b.project_id = '{$c_project_id}' AND bn.bug_id = b.id ";
    } else {
        $t_project_where = '';
    }
    $t_results = array();
    $query = "SELECT username, summary, bn.bug_id, SUM(time_tracking) AS sum_time_tracking\r\n\t\t\tFROM {$t_user_table} u, {$t_bugnote_table} bn, {$t_bug_table} b\r\n\t\t\tWHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id\r\n\t\t\t{$t_project_where} {$t_from_where} {$t_to_where}\r\n\t\t\tGROUP BY bn.bug_id, u.id, u.username, b.summary\r\n\t\t\tORDER BY bn.bug_id";
    $result = db_query($query);
    $t_cost_min = $c_cost / 60;
    while ($row = db_fetch_array($result)) {
        $t_total_cost = $t_cost_min * $row['sum_time_tracking'];
        $row['cost'] = $t_total_cost;
        $t_results[] = $row;
    }
    return $t_results;
}