Example #1
0
        // if the task as only one user then update it!
        $sql = sprintf("SELECT COUNT(*) as num_users FROM trole_people_task where id_task = %d", $id);
        $result1 = process_sql($sql);
        $result2 = true;
        //To avoid strange messages with many task users
        if ($result1[0][0] == 1) {
            $sql = sprintf("SELECT id_role FROM trole_people_project \n\t\t\t\t\tWHERE id_project = %d AND id_user = '******'", $id_project, $config['id_user']);
            $id_role = process_sql($sql);
            $id_role = $id_role[0]['id_role'];
            $sql = sprintf('UPDATE trole_people_task SET id_user = "******", id_role = %d WHERE id_task = %d', $owner, $id_role, $id);
            $result2 = process_sql($sql);
        }
        if ($result !== false && $result1 !== false && $result2 !== false) {
            $succ++;
            audit_db($config['id_user'], $config["REMOTE_ADDR"], "Task updated", "Task '{$name}' updated to project '{$id_project}'");
            task_tracking($id, TASK_UPDATED);
        } else {
            echo "<h3 class='error'>" . __('Could not be updated') . "</h3>";
        }
    }
    echo '<h3 class="suc">' . sprintf(__('%d tasks successfully updated'), $succ) . '</h3>';
}
//Create a new task
if ($create) {
    $tasklist = get_parameter("tasklist");
    // Massive creation of tasks
    if ($tasklist != "") {
        $tasklist = safe_output($tasklist);
        $parent = (int) get_parameter('padre');
        $start = get_parameter('start_date2', date("Y-m-d"));
        $end = get_parameter('end_date2', date("Y-m-d"));
Example #2
0
        $result_output = "<h3 class='error'>" . __('You must select user/role') . "</h3>";
    } else {
        foreach ($all_people as $person) {
            $result = explode('/', $person);
            $id_user = $result[0];
            $id_role = $result[1];
            $filter['id_role'] = $id_role;
            $filter['id_user'] = $id_user;
            $filter['id_task'] = $id_task;
            $role_name = get_db_value('name', 'trole', 'id', $id_role);
            $result_sql = get_db_value_filter('id_user', 'trole_people_task', $filter);
            if ($result_sql !== false) {
                echo "<h3 class='error'>" . __('Not created. Role already exists: ') . $id_user . ' / ' . $role_name . "</h3>";
            } else {
                $sql = "INSERT INTO trole_people_task\n\t\t\t\t\t(id_task, id_user, id_role) VALUES\n\t\t\t\t\t({$id_task}, '{$id_user}', '{$id_role}')";
                task_tracking($id_task, TASK_MEMBER_ADDED);
                $id_task_inserted = process_sql($sql, 'insert_id');
                if ($id_task_inserted !== false) {
                    $result_output .= "<h3 class='suc'>" . __('Successfully created: ') . $id_user . ' / ' . $role_name . "</h3>";
                    audit_db($config["id_user"], $config["REMOTE_ADDR"], "User/Role added to task", "User {$id_user} added to task " . get_db_value("name", "ttask", "id", $id_task));
                } else {
                    $update_mode = 0;
                    $create_mode = 1;
                    $result_output .= "<h3 class='error'>" . __('Not created. Error inserting data: ') . $id_user . ' / ' . $role_name . "</h3>";
                }
            }
        }
    }
}
// ---------------------
// Edition / View mode
Example #3
0
	$target_project = get_parameter ("target_project");
	$id_task = get_parameter ("id_task");
	if ((dame_admin($config['id_user'])==1) OR (project_manager_check ($id_project) == 1)){
		$sql = sprintf ('UPDATE ttask
			SET id_project = %d,
			id_parent_task = 0
			WHERE id = %d', $target_project, $id_task);
		process_sql ($sql);
		
		// Move subtasks of this task
		$sql = sprintf ('UPDATE ttask
			SET id_project = %d WHERE id_parent_task = %d', $target_project, $id_task);
		process_sql ($sql);
		
		
		task_tracking ($id_task, TASK_MOVED);
	}
	else {
		no_permission ();
	}
}

// MAIN LIST OF TASKS
$search_text = (string) get_parameter ('search_text', '');


	if (!$pure) {
		// Print title and menu.
		$section_title = __('Task management');
		$section_subtitle = $project['name'];
		$p_menu = print_project_tabs('task_list');
Example #4
0
			$user_role, $id_workunit);
		$result = process_sql ($sql);
	}
	
	if ($result) {
		$task = get_db_row ('ttask', 'id', $id_task);
		$current_hours = get_task_workunit_hours ($id_task);
		if ($insert) {
			mail_project (0, $config['id_user'], $id_workunit, $id_task);
			$sql = sprintf ('INSERT INTO tworkunit_task (id_task, id_workunit)
				VALUES (%d, %d)',
				$id_task, $id_workunit);
			process_sql ($sql);
			$result_output = ui_print_success_message (__('Workunit added'), '', true, 'h3', true);
			audit_db ($config["id_user"], $config["REMOTE_ADDR"], "PWU", "Inserted PWU. $description");
			task_tracking ($id_task, TASK_WORKUNIT_ADDED, $id_workunit);

			/* Autocomplete task progress */

                	if ($task['completion'] < 100) {
	                       /* Get expected task completion, based on worked hours */
       		               $expected_completion = round_number (floor ($current_hours * 100 / $task['hours']));

	                        $current_hours += $duration;
                        	$expected_completion =  round_number (floor ($current_hours * 100 / $task['hours']));
                        	$sql = sprintf ('UPDATE ttask
                                SET completion = %d
                                WHERE id = %d',
                                $expected_completion, $id_task);
                        	process_sql ($sql);
                	}
Example #5
0
    $id_task = process_sql($sql, 'insert_id');
    if ($id_task) {
        // Add all users assigned to current project for new task or parent task if has parent
        if ($id_parent != 0) {
            $query1 = "SELECT * FROM trole_people_task WHERE id_task = {$id_parent}";
        } else {
            $query1 = "SELECT * FROM trole_people_project WHERE id_project = {$id_project}";
        }
        $resq1 = mysql_query($query1);
        while ($row = mysql_fetch_array($resq1)) {
            $id_role_tt = $row["id_role"];
            $id_user_tt = $row["id_user"];
            $sql = "INSERT INTO trole_people_task\n\t\t\t(id_task, id_user, id_role) VALUES\n\t\t\t({$id_task}, '{$id_user_tt}', {$id_role_tt})";
            mysql_query($sql);
        }
        task_tracking($id_task, TASK_CREATED);
        project_tracking($id_project, PROJECT_TASK_ADDED);
    }
    if ($id_task) {
        $msg = __("Task created");
    } else {
        $msg = __("Error creating task");
    }
    $ret = array("res" => $id_task, "msg" => $msg);
    echo json_encode($ret);
    exit;
}
if ($get_task_statistics) {
    include $config["homedir"] . "operation/projects/task_report.php";
    exit;
}