Ejemplo n.º 1
0
	public function ajax ($method = false) {
		
		if (! $this->isLogged()) {
			return;
		}
		
		switch ($method) {
			case 'search_users':
				$string = (string) get_parameter ('term'); /* term is what autocomplete plugin gives */
				$users = get_user_visible_users ($this->getIdUser(),"IR", false);
				
				if ($users === false)
					return;
					
				$res = array();
				
				foreach ($users as $user) {
					if(preg_match('/'.$string.'/i', $user['id_usuario']) || preg_match('/'.$string.'/i', $user['nombre_real'])|| preg_match('/'.$string.'/i', $user['num_employee'])) {
						array_push($res, array("label" => safe_output($user['nombre_real'])." (".$user['id_usuario'].")", "value" => $user['id_usuario']));
					}
				}
				
				echo json_encode($res);
				break;
			case 'search_users_role':
				$id_project = (int) get_parameter ('id_project');
				$string = (string) get_parameter ('term'); /* term is what autocomplete plugin gives */
				
				$users = get_users_project ($id_project);
				
				if ($users === false)
					return;

				$res = array();
				
				foreach ($users as $user) {
					if(preg_match('/'.$string.'/i', $user['id_usuario']) || preg_match('/'.$string.'/i', $user['nombre_real'])|| preg_match('/'.$string.'/i', $user['num_employee'])) {
						array_push($res, array("label" => safe_output($user['nombre_real'])." (".$user['id_usuario'].")", "value" => $user['id_usuario']));
					}
				}
				
				echo json_encode($res);
				break;
		} 
		
	}
Ejemplo n.º 2
0
function print_project_timegraph($id_project, $start_date = false, $end_date = false, $id_user_filter = "")
{
    if ($id_user_filter == "") {
        $users = get_users_project($id_project);
    } else {
        $sql = "SELECT *\n                FROM trole_people_project\n                WHERE id_project = {$id_project} AND id_user = '******'";
        $users = get_db_all_rows_sql($sql);
    }
    $tasks = get_db_all_rows_field_filter('ttask', 'id_project', $id_project);
    $data = array();
    foreach ($tasks as $task) {
        foreach ($users as $user) {
            $user_name = get_db_value('nombre_real', 'tusuario', 'id_usuario', $user['id_user']);
            $hours = get_task_workunit_hours_user($task['id'], $user['id_user'], 0, $start_date, $end_date);
            if (empty($hours)) {
                continue;
            }
            $data[$task['id']][$user['id_user']] = array('parent_name' => safe_output($task['name']), 'name' => safe_output($user_name), 'value' => $hours, 'tooltip' => "<b>" . __('Task:') . "</b> " . $task['name'] . "<br />" . "<b>" . __('User:'******'Hours:') . "</b> " . $hours, 'id' => $task['id'] . "_" . $user['id_user']);
        }
    }
    if (empty($data)) {
        ui_print_error_message(__('There are not tasks with hours in this period.'));
        return;
    }
    graph_print_d3js_treemap($data);
}
Ejemplo n.º 3
0
    $res = array();
    foreach ($users as $user) {
        if (preg_match('/' . $string . '/i', $user['id_usuario']) || preg_match('/' . $string . '/i', $user['nombre_real']) || preg_match('/' . $string . '/i', $user['num_employee'])) {
            array_push($res, array("label" => safe_output($user['nombre_real']) . " (" . safe_output($user['id_usuario']) . ")", "value" => safe_output($user['id_usuario'])));
        }
    }
    echo json_encode($res);
    return;
}
if ($search_users_role) {
    require_once 'include/functions_db.php';
    $id_project = (int) get_parameter('id_project');
    $id_user = $config['id_user'];
    $string = (string) get_parameter('term');
    /* term is what autocomplete plugin gives */
    $users = get_users_project($id_project);
    if ($users === false) {
        return;
    }
    $res = array();
    foreach ($users as $user) {
        if (preg_match('/' . $string . '/i', $user['id_usuario']) || preg_match('/' . $string . '/i', $user['nombre_real']) || preg_match('/' . $string . '/i', $user['num_employee'])) {
            array_push($res, array("label" => safe_output($user['nombre_real']) . " (" . $user['id_usuario'] . ")", "value" => $user['id_usuario']));
        }
    }
    echo json_encode($res);
    return;
}
if ($get_group_info) {
    $group = get_parameter("group");
    $res = get_db_row("tgrupo", "id_grupo", $group);