Example #1
0
function incident_details_list($id_incident, $return = false)
{
    $output = '';
    $incident = get_incident($id_incident);
    $output .= '<ul id="incident-details-list" class="sidemenu">';
    $output .= '&nbsp;&nbsp;<strong>' . __('Open at') . '</strong>: ' . human_time_comparation($incident['inicio']);
    if ($incident['estado'] == 7) {
        $output .= '<br />&nbsp;&nbsp;<strong>' . __('Closed at') . '</strong>: ' . human_time_comparation($incident['cierre']);
    }
    if ($incident['actualizacion'] != $incident['inicio']) {
        $output .= '<br />&nbsp;&nbsp;<strong>' . __('Last update') . '</strong>: ' . human_time_comparation($incident['actualizacion']);
    }
    /* Show workunits if there are some */
    $workunit_count = get_incident_count_workunits($id_incident);
    if ($workunit_count) {
        $work_hours = get_incident_workunit_hours($id_incident);
        $workunits = get_incident_workunits($id_incident);
        $workunit_data = get_workunit_data($workunits[0]['id_workunit']);
        $output .= '<br />&nbsp;&nbsp;<strong>' . __('Last work at') . '</strong>: ' . human_time_comparation($workunit_data['timestamp']);
        $output .= '<br />&nbsp;&nbsp;<strong>' . __('Workunits') . '</strong>: ' . $workunit_count;
        $output .= '<br />&nbsp;&nbsp;<strong>' . __('Time used') . '</strong>: ' . $work_hours;
        $output .= '<br />&nbsp;&nbsp;<strong>' . _('Done by') . '</strong>: <em>' . $workunit_data['id_user'] . '</em>';
    }
    $output .= '</ul>';
    if ($return) {
        return $output;
    }
    echo $output;
}
				$incident_detail .= "<td><strong>".__("Total time spent")."</strong>:</td>";
				$incident_detail .= "<td style='text-align:right;'>".give_human_time($stats[INCIDENT_METRIC_TOTAL_TIME],true,true,true)."</td>";
				$incident_detail .= "</tr>";
				$incident_detail .= "<tr>";
				$incident_detail .= "<td><strong>".__("Time no third people")."</strong>:</td>";
				$incident_detail .= "<td style='text-align:right;'>".give_human_time($stats[INCIDENT_METRIC_TOTAL_TIME_NO_THIRD],true,true,true)."</td>";
				$incident_detail .= "</tr>";
				//$incident_detail .= "</table>";
				
				echo print_container('incident_tracking_detail', __('General statistics'), $incident_detail, 'open', true, '20px', '', '', 1, 'less_widht');
			echo "</td>";
			echo "<td style='vertical-align:top; width: 33%;'>";
				$workunit_count = get_incident_count_workunits ($id);
				//$workunit_detail = "<table class='details_table alternate'>";
				if ($workunit_count) {
					$work_hours = get_incident_workunit_hours ($id);
					$workunits = get_incident_workunits ($id);	
					$workunit_data = get_workunit_data ($workunits[0]['id_workunit']);
					$workunit_detail = "<tr>";
					$workunit_detail .= "<td><strong>".__("Last work at")."</strong>:</td>";
					$workunit_detail .= "<td style='text-align:right;'>".human_time_comparation ($workunit_data['timestamp'])."</td>";
					$workunit_detail .= "</tr>";
					$workunit_detail .= "<tr>";
					$workunit_detail .= "<td><strong>".__("Workunits")."</strong>:</td>";
					$workunit_detail .= "<td style='text-align:right;'>".$workunit_count."</td>";
					$workunit_detail .= "</tr>";				
					$workunit_detail .= "<tr>";
					$workunit_detail .= "<td><strong>".__("Time used")."</strong>:</td>";
					$workunit_detail .= "<td style='text-align:right;'>".give_human_time($work_hours*SECONDS_1HOUR,true,true,true)."</td>";
					$workunit_detail .= "</tr>";
					$workunit_detail .= "<tr>";
/**
 * Print a table with statistics of a list of incidents.
 *
 * @param array List of incidents to get stats.
 * @param bool Whether to return an output string or echo now (optional, echo by default).
 *
 * @return Incidents stats if return parameter is true. Nothing otherwise
 */
function print_incidents_stats_simply($incidents, $return = false, $simple_mode = false)
{
    global $config;
    require_once $config["homedir"] . "/include/functions_graph.php";
    $pdf_output = (int) get_parameter('pdf_output', 0);
    $ttl = $pdf_output + 1;
    // Max graph legend string length (without the '...')
    $max_legend_strlen = 17;
    // Necessary for flash graphs
    include_flash_chart_script();
    // TODO: Move this function to function_graphs to encapsulate flash
    // chart script inclusion or make calls to functions_graph when want
    // print a flash chart
    $output = '';
    $total = sizeof($incidents);
    $opened = 0;
    $total_hours = 0;
    $total_workunits = 0;
    $total_lifetime = 0;
    $max_lifetime = 0;
    $oldest_incident = false;
    $scoring_sum = 0;
    $scoring_valid = 0;
    if ($incidents === false) {
        $incidents = array();
    }
    $assigned_users = array();
    $creator_users = array();
    $submitter_label = "";
    $user_assigned_label = "";
    $incident_id_array = array();
    //Initialize incident status array
    $incident_status = array();
    $incident_status[STATUS_NEW] = 0;
    $incident_status[STATUS_UNCONFIRMED] = 0;
    $incident_status[STATUS_ASSIGNED] = 0;
    $incident_status[STATUS_REOPENED] = 0;
    $incident_status[STATUS_VERIFIED] = 0;
    $incident_status[STATUS_RESOLVED] = 0;
    $incident_status[STATUS_PENDING_THIRD_PERSON] = 0;
    $incident_status[STATUS_CLOSED] = 0;
    //Initialize priority array
    $incident_priority = array();
    $incident_priority[PRIORITY_INFORMATIVE] = 0;
    $incident_priority[PRIORITY_LOW] = 0;
    $incident_priority[PRIORITY_MEDIUM] = 0;
    $incident_priority[PRIORITY_SERIOUS] = 0;
    $incident_priority[PRIORITY_VERY_SERIOUS] = 0;
    $incident_priority[PRIORITY_MAINTENANCE] = 0;
    //Initialize status timing array
    $incident_status_timing = array();
    $incident_status_timing[STATUS_NEW] = 0;
    $incident_status_timing[STATUS_UNCONFIRMED] = 0;
    $incident_status_timing[STATUS_ASSIGNED] = 0;
    $incident_status_timing[STATUS_REOPENED] = 0;
    $incident_status_timing[STATUS_VERIFIED] = 0;
    $incident_status_timing[STATUS_RESOLVED] = 0;
    $incident_status_timing[STATUS_PENDING_THIRD_PERSON] = 0;
    $incident_status_timing[STATUS_CLOSED] = 0;
    //Initialize users time array
    $users_time = array();
    //Initialize groups time array
    $groups_time = array();
    foreach ($incidents as $incident) {
        $inc_stats = incidents_get_incident_stats($incident["id_incidencia"]);
        if ($incident['actualizacion'] != '0000-00-00 00:00:00') {
            $lifetime = $inc_stats[INCIDENT_METRIC_TOTAL_TIME];
            if ($lifetime > $max_lifetime) {
                $oldest_incident = $incident;
                $max_lifetime = $lifetime;
            }
            $total_lifetime += $lifetime;
        }
        //Complete incident status timing array
        foreach ($inc_stats[INCIDENT_METRIC_STATUS] as $key => $value) {
            $incident_status_timing[$key] += $value;
        }
        //fill users time array
        foreach ($inc_stats[INCIDENT_METRIC_USER] as $user => $time) {
            if (!isset($users_time[$user])) {
                $users_time[$user] = $time;
            } else {
                $users_time[$user] += $time;
            }
        }
        //Inidents by group time
        foreach ($inc_stats[INCIDENT_METRIC_GROUP] as $key => $time) {
            if (!isset($groups_time[$key])) {
                $groups_time[$key] = $time;
            } else {
                $groups_time[$key] += $time;
            }
        }
        //Get only id from incident filter array
        //used for filter in some functions
        array_push($incident_id_array, $incident['id_incidencia']);
        // Take count of assigned / creator users
        if (isset($assigned_users[$incident["id_usuario"]])) {
            $assigned_users[$incident["id_usuario"]]++;
        } else {
            $assigned_users[$incident["id_usuario"]] = 1;
        }
        if (isset($creator_users[$incident["id_creator"]])) {
            $creator_users[$incident["id_creator"]]++;
        } else {
            $creator_users[$incident["id_creator"]] = 1;
        }
        // Scoring avg.
        if ($incident["score"] > 0) {
            $scoring_valid++;
            $scoring_sum = $scoring_sum + $incident["score"];
        }
        $hours = get_incident_workunit_hours($incident['id_incidencia']);
        $workunits = get_incident_workunits($incident['id_incidencia']);
        $total_hours += $hours;
        $total_workunits = $total_workunits + sizeof($workunits);
        //Open incidents
        if ($incident["estado"] != 7) {
            $opened++;
        }
        //Incidents by status
        $incident_status[$incident["estado"]]++;
        //Incidents by priority
        $incident_priority[$incident["prioridad"]]++;
    }
    $closed = $total - $opened;
    $opened_pct = 0;
    $mean_work = 0;
    $mean_lifetime = 0;
    if ($total != 0) {
        $opened_pct = format_numeric($opened / $total * 100);
        $mean_work = format_numeric($total_hours / $total, 2);
    }
    $mean_lifetime = $total_lifetime / $total;
    // Get avg. scoring
    if ($scoring_valid > 0) {
        $scoring_avg = format_numeric($scoring_sum / $scoring_valid);
    } else {
        $scoring_avg = "N/A";
    }
    // Get incident SLA compliance
    $sla_compliance = get_sla_compliance($incidents);
    //Create second table
    // Find the 5 most active users (more hours worked)
    $most_active_users = array();
    if ($incident_id_array) {
        $most_active_users = get_most_active_users(8, $incident_id_array);
    }
    $users_label = '';
    $users_data = array();
    foreach ($most_active_users as $user) {
        $users_data[$user['id_user']] = $user['worked_hours'];
    }
    // Remove the items with no value
    foreach ($users_data as $key => $value) {
        if (!$value || $value <= 0) {
            unset($users_data[$key]);
        }
    }
    if (empty($most_active_users) || empty($users_data)) {
        $users_label = "<div class='container_adaptor_na_graphic2'>";
        $users_label .= graphic_error(false);
        $users_label .= __("N/A");
        $users_label .= "</div>";
    } else {
        arsort($users_data);
        $users_label .= pie3d_graph($config['flash_charts'], $users_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // Find the 5 most active incidents (more worked hours)
    $most_active_incidents = get_most_active_incidents(5, $incident_id_array);
    $incidents_label = '';
    foreach ($most_active_incidents as $incident) {
        $incidents_data[$incident['id_incidencia']] = $incident['worked_hours'];
    }
    // Remove the items with no value
    foreach ($incidents_data as $key => $value) {
        if (!$value || $value <= 0) {
            unset($incidents_data[$key]);
        }
    }
    if (empty($most_active_incidents) || empty($incidents_data)) {
        $incidents_label .= graphic_error(false);
        $incidents_label .= __("N/A");
        $incidents_label = "<div class='container_adaptor_na_graphic'>" . $incidents_label . "</div>";
    } else {
        arsort($incidents_data);
        $incidents_label .= pie3d_graph($config['flash_charts'], $incidents_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // TOP X creator users
    $creator_assigned_data = array();
    foreach ($creator_users as $clave => $valor) {
        $creator_assigned_data["{$clave} ({$valor})"] = $valor;
    }
    if (empty($creator_assigned_data)) {
        $submitter_label = "<div style='width:300px; height:150px;'>";
        $submitter_label .= graphic_error(false);
        $submitter_label .= __("N/A");
        $submitter_label .= "</div>";
    } else {
        arsort($creator_assigned_data);
        $submitter_label .= "<br/>" . pie3d_graph($config['flash_charts'], $creator_assigned_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // TOP X scoring users
    $scoring_label = "";
    $top5_scoring = get_best_incident_scoring(5, $incident_id_array);
    foreach ($top5_scoring as $submitter) {
        $scoring_data[$submitter["id_usuario"]] = $submitter["total"];
    }
    if (empty($top5_scoring)) {
        $scoring_label .= graphic_error(false);
        $scoring_label .= __("N/A");
        $scoring_label = "<div class='container_adaptor_na_graphic2'>" . $scoring_label . "</div>";
    } else {
        arsort($scoring_data);
        $scoring_label .= "<br/>" . pie3d_graph($config['flash_charts'], $scoring_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // TOP X assigned users
    $user_assigned_data = array();
    foreach ($assigned_users as $clave => $valor) {
        $user_assigned_data["{$clave} ({$valor})"] = $valor;
    }
    if (empty($user_assigned_data)) {
        $user_assigned_label = "<div style='width:300px; height:150px;'>";
        $user_assigned_label .= graphic_error(false);
        $user_assigned_label .= __("N/A");
        $user_assigned_label .= "</div>";
    } else {
        arsort($user_assigned_data);
        $user_assigned_label .= "<br/>" . pie3d_graph($config['flash_charts'], $user_assigned_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    }
    // Show graph with incidents by group
    foreach ($incidents as $incident) {
        $grupo = safe_output(dame_grupo($incident["id_grupo"]));
        if (strlen($grupo) > $max_legend_strlen) {
            $grupo = substr($grupo, 0, $max_legend_strlen) . "...";
        }
        if (!isset($incident_group_data[$grupo])) {
            $incident_group_data[$grupo] = 0;
        }
        $incident_group_data[$grupo] = $incident_group_data[$grupo] + 1;
    }
    arsort($incident_group_data);
    // Show graph with incidents by source group
    foreach ($incidents as $incident) {
        $grupo_src = safe_output(dame_grupo($incident["id_group_creator"]));
        if (strlen($grupo_src) > $max_legend_strlen) {
            $grupo_src = substr($grupo_src, 0, $max_legend_strlen) . "...";
        }
        if (!isset($incident_group_data2[$grupo_src])) {
            $incident_group_data2[$grupo_src] = 0;
        }
        $incident_group_data2[$grupo_src] = $incident_group_data2[$grupo_src] + 1;
    }
    arsort($incident_group_data2);
    // Show graph with tickets open/close histogram
    $ticket_oc_graph = '<div class="pie_frame">' . graph_ticket_oc_histogram($incidents, 650, 250, $ttl) . "</div>";
    $container_title = __("Ticket Open/Close histogram");
    $container_ticket_oc = print_container('container_ticket_oc', $container_title, $ticket_oc_graph, 'open', true, true, "container_simple_title", "container_simple_div");
    // Show graph with tickets open/close histogram
    $ticket_activity_graph = '<div class="pie_frame">' . graph_ticket_activity_calendar($incidents) . "</div>";
    $container_title = __("Ticket activity");
    $container_ticket_activity = print_container('container_ticket_activity', $container_title, $ticket_activity_graph, 'open', true, true, "container_simple_title", "container_simple_div");
    //Print first table
    $output .= "<table class='listing' width=190px border=0 cellspacing=0 cellpadding=0 border=0 >";
    $output .= "<tr>";
    $output .= "<th>" . __("Metric") . "</th>";
    $output .= "<th>" . __("Value") . "</th>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>" . __('Total tickets') . "</strong></td>";
    $output .= "<td valign=top align=center>";
    $output .= $total;
    $output .= "</td>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>" . __('Avg. life time') . "</strong></td>";
    $output .= "<td valign=top align=center>";
    $output .= format_numeric($mean_lifetime / 86400, 2) . " " . __("Days");
    $output .= "</td>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>";
    $output .= __('Avg. work time');
    $output .= "</strong></td>";
    $output .= "<td align=center>" . $mean_work . ' ' . __('Hours') . "</td>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>";
    $output .= __('Avg. Scoring');
    $output .= "</strong></td>";
    $output .= "<td align=center>" . $scoring_avg . "</td>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>";
    $output .= __('Total work time');
    $output .= "</strong></td>";
    $output .= "<td align=center>" . $total_hours . " " . __("Hours") . "</td>";
    $output .= "</tr>";
    $output .= "<tr>";
    $output .= "<td align=center><strong>";
    $output .= __('Total work units');
    $output .= "</strong></td>";
    $output .= "<td align=center>" . $total_workunits . "</td>";
    $output .= "</tr></table>";
    $container_title = __("Tickets statistics");
    $container_incident_statistics = print_container('container_incident_statistics', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $output = "<div class='pie_frame'>" . $incidents_label . "</div>";
    $container_title = __("Top 5 active tickets");
    $container_top5_incidents = print_container('container_top5_incidents', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    if ($incidents) {
        $output = graph_incident_statistics_sla_compliance($incidents, 300, 150, $ttl);
    } else {
        $output = "<div style='width:300px; height:150px;'>";
        $output .= graphic_error(false);
        $output .= __("N/A");
        $output .= "</div>";
    }
    $output = "<div class='container_adaptor_graphic'>" . $output . "</div>";
    $output = "<div class='pie_frame'>" . $output . "</div>";
    $container_title = __("SLA compliance");
    $container_sla_compliance = print_container('container_sla_compliance', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $status_aux .= "<table class='listing' style='width: 420px; margin: 10px auto;' cellspacing=0 cellpadding=0 border=0>";
    $status_aux .= "<tr>";
    $status_aux .= "<th style='text-align:center;'><strong>" . __("Status") . "</strong></th>";
    $status_aux .= "<th style='text-align:center;'><strong>" . __("Number") . "</strong></th>";
    $status_aux .= "<th style='text-align:center;'><strong>" . __("Total time") . "</strong></th>";
    $status_aux .= "</tr>";
    foreach ($incident_status as $key => $value) {
        $name = get_db_value('name', 'tincident_status', 'id', $key);
        $status_aux .= "<tr>";
        $status_aux .= "<td>" . $name . "</td>";
        $status_aux .= "<td style='text-align:center;'>" . $value . "</td>";
        $time = $incident_status_timing[$key];
        $status_aux .= "<td style='text-align:center;'>" . give_human_time($time, true, true, true) . "</td>";
        $status_aux .= "</tr>";
    }
    $status_aux .= "</table>";
    $container_title = __("Ticket by status");
    $container_status_incidents = print_container('container_status_incidents', $container_title, $status_aux, 'no', true, true, "container_simple_title", "container_simple_div");
    $priority_aux .= "<table class='listing table_priority_report' style='width: 420px;' cellspacing=0 cellpadding=0 border=0>";
    $priority_aux .= "<tr>";
    $priority_aux .= "<th style='text-align:center;'><strong>" . __("Priority") . "</strong></th>";
    $priority_aux .= "<th style='text-align:center;'><strong>" . __("Number") . "</strong></th>";
    $priority_aux .= "</tr>";
    foreach ($incident_priority as $key => $value) {
        $priority_aux .= "<tr>";
        $priority_aux .= "<td>" . get_priority_name($key) . "</td>";
        $priority_aux .= "<td style='text-align:center;'>" . $value . "</td>";
        $priority_aux .= "</tr>";
    }
    $priority_aux .= "</table>";
    $priority_aux = $priority_aux;
    $container_title = __("Tickets by priority");
    $container_priority_incidents = print_container('container_priority_incidents', $container_title, $priority_aux, 'no', true, true, "container_simple_title", "container_simple_div");
    if ($oldest_incident) {
        $oldest_incident_time = get_incident_workunit_hours($oldest_incident["id_incidencia"]);
        $output = "<table class='listing'>";
        $output .= "<th>";
        $output .= __("Metric");
        $output .= "</th>";
        $output .= "<th>";
        $output .= __("Value");
        $output .= "</th>";
        $output .= "</tr>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<strong>" . __("Ticket Id") . "</strong>";
        $output .= "</td>";
        $output .= "<td>";
        $output .= '<a href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $oldest_incident['id_incidencia'] . '">#' . $oldest_incident['id_incidencia'] . "</strong></a>";
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<strong>" . __("Ticket title") . "</strong>";
        $output .= "</td>";
        $output .= "<td>";
        $output .= '<a href="index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=' . $oldest_incident['id_incidencia'] . '">' . $oldest_incident['titulo'] . "</strong></a>";
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<strong>" . __("Worktime hours") . "</strong>";
        $output .= "</td>";
        $output .= "<td>";
        $output .= $oldest_incident_time . " " . __("Hours");
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "<tr>";
        $output .= "<td>";
        $output .= "<strong>" . __("Lifetime") . "</strong>";
        $output .= "</td>";
        $output .= "<td>";
        $output .= format_numeric($max_lifetime / 86400) . " " . __("Days");
        $output .= "</td>";
        $output .= "</tr>";
        $output .= "</table>";
    } else {
        $output = graphic_error(false);
        $output .= __("N/A");
    }
    $output_aux = "<div style='width:100%; height:170px;'>";
    $output_aux .= $output;
    $output_aux .= "</div>";
    $container_title = __("Longest closed ticket");
    $container_longest_closed = print_container('container_longest_closed', $container_title, $output_aux, 'no', true, true, "container_simple_title", "container_simple_div");
    $data = array(__('Open') => $opened, __('Closed') => $total - $opened);
    $data = array(__('Close') => $total - $opened, __('Open') => $opened);
    $output = pie3d_graph($config['flash_charts'], $data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'], $ttl);
    $output = "<div class='pie_frame'>" . $output . "</div>";
    $container_title = __("Open / Close ticket");
    $container_openclose_incidents = print_container('container_openclose_incidents', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $clean_output = get_parameter("clean_output");
    $container_title = __("Top active users");
    $output = "<div class='pie_frame'>" . $users_label . "</div>";
    $container_topactive_users = print_container('container_topactive_users', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Top ticket submitters");
    $output = "<div class='pie_frame'>" . $submitter_label . "</div>";
    $container_topincident_submitter = print_container('container_topincident_submitter', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Top assigned users");
    $output = "<div class='pie_frame'>" . $user_assigned_label . "</div>";
    $container_user_assigned = print_container('container_user_assigned', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Tickets by group");
    $output = "<br/>" . pie3d_graph($config['flash_charts'], $incident_group_data, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'] - 1, $ttl);
    $output = "<div class='pie_frame'>" . $output . "</div>";
    $container_incidents_group = print_container('container_incidents_group', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Tickets by creator group");
    $output = "<br/>" . pie3d_graph($config['flash_charts'], $incident_group_data2, 300, 150, __('others'), $config["base_url"], "", $config['font'], $config['fontsize'] - 1, $ttl);
    $output = "<div class='pie_frame'>" . $output . "</div>";
    $container_incident_creator_group = print_container('container_incident_creator_group', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $container_title = __("Top 5 average scoring by user");
    $output = "<div class='pie_frame'>" . $scoring_label . "</div>";
    $container_top5_scoring = print_container('container_top5_scoring', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    //Print second table
    $output = "<table class='listing' style='width: 320px; margin: 10px auto'>";
    $output .= "<tr>";
    $output .= "<th style='text-align:center;'><strong>" . __("Group") . "</strong></th>";
    $output .= "<th style='text-align:center;'><strong>" . __("Time") . "</strong></th>";
    $output .= "</tr>";
    $count = 1;
    arsort($groups_time);
    foreach ($groups_time as $key => $value) {
        //Only show first 5
        if ($count == 5) {
            break;
        }
        $output .= "<tr>";
        $group_name = get_db_value('nombre', 'tgrupo', 'id_grupo', $key);
        $output .= "<td>" . $group_name . "</td>";
        $output .= "<td style='text-align: center'>" . give_human_time($value, true, true, true) . "</td>";
        $output .= "</tr>";
        $count++;
    }
    $output .= "</table>";
    $output .= '<br>';
    $output .= '<br>';
    $container_title = __("Top 5 group by time");
    $container_top5_group_time = print_container('container_top5_group_time', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    $output = "<table class='listing' style='width: 420px; margin: 10px'>";
    $output .= "<tr>";
    $output .= "<th style='text-align:center;'><strong>" . __("User") . "</strong></th>";
    $output .= "<th style='text-align:center;'><strong>" . __("Time") . "</strong></th>";
    $output .= "</tr>";
    $count = 1;
    arsort($users_time);
    foreach ($users_time as $key => $value) {
        //Only show first 5
        if ($count == 5) {
            break;
        }
        $output .= "<tr>";
        $user_real = get_db_value('nombre_real', 'tusuario', 'id_usuario', $key);
        $output .= "<td>" . $user_real . "</td>";
        $output .= "<td style='text-align: center'>" . give_human_time($value, true, true, true) . "</td>";
        $output .= "</tr>";
        $count++;
    }
    $output .= "</table>";
    $output .= "</table>";
    $container_title = __("Top 5 users by time");
    $container_top5_user_time = print_container('container_top5_user_time', $container_title, $output, 'no', true, true, "container_simple_title", "container_simple_div");
    if ($simple_mode) {
        // First row
        echo $container_incidents_group;
        echo $container_topincident_submitter;
        echo $container_user_assigned;
        // Second row
        echo $container_incident_statistics;
        echo $container_top5_group_time;
        echo $container_sla_compliance;
    } else {
        // First row
        echo $container_incidents_group;
        echo $container_topincident_submitter;
        echo $container_user_assigned;
        // Second row
        echo $container_incident_statistics;
        echo $container_top5_group_time;
        echo $container_sla_compliance;
        echo '<br><br>';
        // Third row
        echo $container_status_incidents;
        echo $container_priority_incidents;
        //Fourth row
        echo $container_topactive_users;
        echo $container_top5_incidents;
        echo $container_openclose_incidents;
        echo '<br><br><br>';
        //~ // Fifth row
        echo $container_ticket_oc;
        echo '<br><br><br><br><br><br><br><br><br><br><br><br>';
        //~ // Sixth row
        echo $container_ticket_activity;
    }
}
Example #4
0
function api_get_incidents($return_type, $user, $params)
{
    $filter = array();
    $filter['string'] = $params[0];
    $filter['status'] = $params[1];
    $filter['id_group'] = $params[2];
    $filter["limit"] = 5000;
    // If the user is admin, all the incidents are showed
    if (!get_admin_user($user)) {
        $filter['id_user_or_creator'] = $user;
    }
    global $config;
    $config['id_user'] = $user;
    $result = filter_incidents($filter);
    if ($result === false) {
        switch ($return_type) {
            case "xml":
                return "<xml></xml>";
                break;
            case "csv":
                return;
                break;
        }
    }
    $ret = '';
    if ($return_type == 'xml') {
        $ret = "<xml version='1.0' encoding='UTF-8'>\n";
    }
    $result = clean_numerics($result);
    foreach ($result as $index => $item) {
        $item['workunits_hours'] = get_incident_workunit_hours($item['id_incidencia']);
        $item['workunits_count'] = get_incident_count_workunits($item['id_incidencia']);
        switch ($return_type) {
            case "xml":
                $ret .= xml_node($item, 'incident', false);
                break;
            case "csv":
                $ret .= array_to_csv($item);
                break;
        }
    }
    if ($return_type == 'xml') {
        $ret .= "</xml>\n";
    }
    return $ret;
}
Example #5
0
		$table->head[2] = __('Creation datetime');
		$table->head[3] = __('Status');
		$table->head[4] = __('WU time (hr)');

		$statuses = get_indicent_status ();

		foreach ($incidents as $incident) {
			$data = array ();
			if ((user_belong_incident ($config["id_user"], $incident["id_incidencia"]))
			OR (dame_admin ($config["id_user"]))) {

				$data[0] = $incident["id_incidencia"];
				$data[1] = "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_dashboard_detail&id=".$incident["id_incidencia"]."'>".$incident["titulo"]."</a>";
				$data[2] = $incident["inicio"];
				$data[3] = $statuses[$incident['estado']];
				$data[4] = get_incident_workunit_hours($incident["id_incidencia"]);
				array_push ($table->data, $data);
			}
		}

		print_table ($table);
	}
}


// Projects
if (give_acl($config["id_user"], 0, "PR") && $show_projects != MENU_HIDDEN){

	$sql = "SELECT tproject.id as project_id, ttask.id as task_id, tproject.name as pname, ttask.name as tname FROM 
			tproject, ttask WHERE tproject.disabled = 0 AND ttask.id_project = tproject.id AND (ttask.name LIKE '%$search_string%' 
			OR tproject.name  LIKE '%$search_string%')";
Example #6
0
}
echo "<h3>" . __('Related incidents');
echo " - " . __('Task') . " - " . $task_name . "</h3>";
echo "<table width=90% class='listing'>";
echo "<tr><th>";
echo __('Incident');
echo "<th>";
echo __('Title');
echo "<th>";
echo __('WU Hours');
echo "<th>";
echo __('Start');
echo "<th>";
echo __('End');
$incidents = print_array_pagination($incidents, "index.php");
foreach ($incidents as $incident) {
    echo "<tr>";
    echo "<td>";
    echo $incident["id_incidencia"];
    echo "<td>";
    echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident&id=" . $incident["id_incidencia"] . "'>";
    echo $incident["titulo"];
    echo "</a>";
    echo "<td>";
    echo get_incident_workunit_hours($incident["id_incidencia"]);
    echo "<td class='f9'>";
    echo $incident["inicio"];
    echo "<td class='f9'>";
    echo $incident["cierre"];
}
echo "</table>";
Example #7
0
echo "</div>";
echo "</h1>";
$incidents = filter_incidents($filter);
if (empty($incidents)) {
    $incidents = array();
}
$incidents_by_user = array();
foreach ($incidents as $incident) {
    $row = array();
    $user_name = get_db_value('nombre_real', 'tusuario', 'id_usuario', $incident['id_creator']);
    $row['id_creator'] = $incident['id_creator'];
    $row['id_incident'] = $incident['id_incidencia'];
    $row['incident_name'] = safe_output($incident['titulo']);
    $row['user_name'] = safe_output($user_name);
    $row['workunits'] = get_incident_count_workunits($incident['id_incidencia']);
    $row['hours'] = get_incident_workunit_hours($incident['id_incidencia']);
    $row['files'] = get_number_files_incident($incident['id_incidencia']);
    $incidents_by_user[] = $row;
}
/* Add a form to carry filter between statistics and search views */
echo '<form id="search_form" method="post" action="index.php?sec=incidents&sec2=operation/incidents/incident_search&option=search" style="clear: both">';
foreach ($filter as $key => $value) {
    print_input_hidden("search_" . $key, $value);
}
print_input_hidden("offset", get_parameter("offset"));
echo "</form>";
if (empty($incidents_by_user)) {
    ui_print_error_message(__('There are not tickets with this filter.'));
} else {
    print_bubble_incidents_per_user_graph($incidents_by_user);
}
Example #8
0
					// Status and resolution
					$status = get_indicent_status();
					echo "<td>".$status[$incident["istatus"]];
					echo "<br>";
					echo render_resolution ($incident["resolution"]); 
					echo "</td>";

					// Date
					echo "<td class=datos width=80 style='font-size: 9px'>";
					echo substr($incident["date_start"],0,11). "<br>";
					echo substr($incident["date_end"],0,11)."</td>";

					// User vs Total wu hours
					echo "<td>".$incident["suma"]."<br>";
					$incident_user  += $incident["suma"];
					$this_incident = get_incident_workunit_hours($incident["id"]);
					echo $this_incident."</td>";
					$incident_totals +=  $this_incident;
					
					// Score
					echo "<td>";
					if (give_acl ($config["id_user"], 0, "IM"))
						if ($incident["score"] != 0)
							echo $incident["score"];
						else
							echo "-";
					else
						echo "N/A";
					echo "</td>";
					
					// SLA Compliance    
Example #9
0
     // Doesn't have access to this page
     audit_db($id_user, $config["REMOTE_ADDR"], "ACL Violation", "Trying to access to ticket " . $id_inc . " '" . $titulo . "'");
     include "general/noaccess.php";
     exit;
 }
 echo "<div id='menu_tab'><ul class='mn'>";
 // Incident main
 echo "<li class='nomn'>";
 echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_detail&id={$id_inc}'><img src='images/page_white_text.png' class='top' border=0> " . __('Ticket') . " </a>";
 echo "</li>";
 // Tracking
 echo "<li class='nomn'>";
 echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_tracking&id={$id_inc}'><img src='images/eye.png' class='top' border=0> " . __('Tracking') . " </a>";
 echo "</li>";
 // Workunits
 $timeused = get_incident_workunit_hours($id_inc);
 echo "<li class='nomn'>";
 if ($timeused > 0) {
     echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_work&id_inc={$id_inc}'><img src='images/award_star_silver_1.png' class='top' border=0> " . __('Workunits') . " ({$timeused})</a>";
 } else {
     echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_work&id_inc={$id_inc}'><img src='images/award_star_silver_1.png' class='top' border=0> " . __('Workunits') . "</a>";
 }
 echo "</li>";
 // Attach
 $file_number = get_number_files_incident($id_inc);
 if ($file_number > 0) {
     echo "<li class='nomn'>";
     echo "<a href='index.php?sec=incidents&sec2=operation/incidents/incident_files&id={$id_inc}'><img src='images/disk.png' class='top' border=0> " . __('Files') . " ({$file_number}) </a>";
     echo "</li>";
 }
 echo "</ul>";