Hi bradgrafelman
Please find the following code and help me
if (empty($query_string)) {
$query_string = "?m=$m&a=$a";
}
// Number of columns (used to calculate how many columns to span things through)
$cols = 13;
/****
// Let's figure out which tasks are selected
*/
global $tasks_opened;
global $tasks_closed;
$tasks_closed = array();
$tasks_opened = $AppUI->getState("tasks_opened");
if(!$tasks_opened){
$tasks_opened = array();
}
$task_id = intval( dPgetParam( $_GET, "task_id", 0 ) );
$pinned_only = intval( dPgetParam( $_GET, 'pinned', 0) );
if (isset($_GET['pin']))
{
$pin = intval( dPgetParam( $_GET, "pin", 0 ) );
$msg = '';
// load the record data
if($pin) {
$sql = "INSERT INTO user_task_pin (user_id, task_id) VALUES($AppUI->user_id, $task_id)";
} else {
$sql = "DELETE FROM user_task_pin WHERE user_id=$AppUI->user_id AND task_id=$task_id";
}
if (!db_exec( $sql )) {
$AppUI->setMsg( "ins/del err", UI_MSG_ERROR, true );
}
$AppUI->redirect('', -1);
}
else if($task_id > 0){
$_GET["open_task_id"] = $task_id;
}
$AppUI->savePlace();
if(($open_task_id = dPGetParam($_GET, "open_task_id", 0)) > 0 && !in_array($_GET["open_task_id"], $tasks_opened)) {
$tasks_opened[] = $_GET["open_task_id"];
}
// Closing tasks needs also to be within tasks iteration in order to
// close down all child tasks
if(($close_task_id = dPGetParam($_GET, "close_task_id", 0)) > 0) {
closeOpenedTask($close_task_id);
}
// We need to save tasks_opened until the end because some tasks are closed within tasks iteration
//echo "<pre>"; print_r($tasks_opened); echo "</pre>";
/// End of tasks_opened routine
$durnTypes = dPgetSysVal( 'TaskDurationType' );
$taskPriority = dPgetSysVal( 'TaskPriority' );
$task_project = intval( dPgetParam( $_GET, 'task_project', null ) );
//$task_id = intval( dPgetParam( $_GET, 'task_id', null ) );
$task_sort_item1 = dPgetParam( $_GET, 'task_sort_item1', '' );
$task_sort_type1 = dPgetParam( $_GET, 'task_sort_type1', '' );
$task_sort_item2 = dPgetParam( $_GET, 'task_sort_item2', '' );
$task_sort_type2 = dPgetParam( $_GET, 'task_sort_type2', '' );
$task_sort_order1 = intval( dPgetParam( $_GET, 'task_sort_order1', 0 ) );
$task_sort_order2 = intval( dPgetParam( $_GET, 'task_sort_order2', 0 ) );
if (isset($_POST['show_task_options'])) {
$AppUI->setState('TaskListShowIncomplete', dPgetParam($_POST, 'show_incomplete', 0));
}
$showIncomplete = $AppUI->getState('TaskListShowIncomplete', 0);
$where = '';
require_once $AppUI->getModuleClass('projects');
$project =& new CProject;
// $allowedProjects = $project->getAllowedRecords($AppUI->user_id, 'project_id, project_name');
$allowedProjects = $project->getAllowedSQL($AppUI->user_id);
$where = "";
if ( count($allowedProjects))
$where = "WHERE " . implode(" AND ", $allowedProjects);
$psql = "
SELECT project_id, project_color_identifier, project_name,
COUNT(t1.task_id) as total_tasks,
SUM(t1.task_duration*t1.task_percent_complete)/SUM(t1.task_duration) as project_percent_complete,
company_name
FROM projects
LEFT JOIN tasks t1 ON projects.project_id = t1.task_project" .
" LEFT JOIN companies ON company_id = project_company
" . $where . "
GROUP BY project_id
ORDER BY project_name
";
//echo "<pre>$psql</pre>";
$perms =& $AppUI->acl();
$projects = array();
$canViewTask = $perms->checkModule('tasks', 'view');
if ($canViewTask) {
$prc = db_exec( $psql );
echo db_error();
while ($row = db_fetch_assoc( $prc )) {
$projects[$row["project_id"]] = $row;
}
}
$join = "";
// pull tasks
$select = "
distinct t.task_id, t.task_parent, t.task_name, t.task_start_date, t.task_end_date, t.task_dynamic, pin.task_pinned, pin.user_id as pin_user,
t.task_priority, t.task_percent_complete, t.task_duration, t.task_duration_type,t.task_project,
t.task_description, t.task_owner, t.task_status, usernames.user_username, usernames.user_id,t.task_milestone,
assignees.user_username as assignee_username, count(distinct assignees.user_id) as assignee_count, co.contact_first_name, co.contact_last_name,
count(distinct files.file_task) as file_count, tlog.task_log_problem";
$from = "tasks as t";
//echo $select." ".$from; die;
$mods = $AppUI->getActiveModules();
if (!empty($mods['history']) && !getDenyRead('history'))
{
$select .= ", MAX(history_date) as last_update";
$join = "LEFT JOIN history ON history_item = t.task_id AND history_table='tasks' ";
}
$join .= "LEFT JOIN projects ON project_id = t.task_project";
$join .= " LEFT JOIN users as usernames ON task_owner = usernames.user_id";
// patch 2.12.04 show assignee and count
$join .= " LEFT JOIN user_tasks as ut ON ut.task_id = t.task_id";
$join .= " LEFT JOIN users as assignees ON assignees.user_id = ut.user_id";
$join .= " LEFT JOIN contacts as co ON co.contact_id = usernames.user_contact";
// check if there is log report with the problem flag enabled for the task
$join .= " LEFT JOIN task_log AS tlog ON tlog.task_log_task = t.task_id AND tlog.task_log_problem > '0'";
// to figure out if a file is attached to task
$join .= " LEFT JOIN files on t.task_id = files.file_task";
$join .= ' LEFT JOIN user_task_pin as pin ON t.task_id = pin.task_id AND pin.user_id = ';
$join .= $user_id ? $user_id : $AppUI->user_id;
$where = $project_id ? "\ntask_project = $project_id" : "project_active <> 0";
if ($pinned_only)
$where .= ' AND pin.task_pinned = 1 ';
switch ($f) {
case 'all':
break;
case 'myfinished7days':
$where .= " AND user_tasks.user_id = $user_id";
case 'allfinished7days': // patch 2.12.04 tasks finished in the last 7 days
//$from .= ", user_tasks as ut";
$where .= "
AND t.task_project = p.project_id
AND ut.task_id = t.task_id
AND t.task_percent_complete = '100'
AND t.task_end_date >= '" . date("Y-m-d 00:00:00", mktime(0, 0, 0, date("m"), date("d")-7, date("Y"))) . "'";
break;