function index() { if (!can_manage_time(logged_user(), true)) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $tasksUserId = array_var($_GET, 'tu'); if (is_null($tasksUserId)) { $tasksUserId = user_config_option('TM tasks user filter', logged_user()->getId()); } else { if (user_config_option('TM tasks user filter') != $tasksUserId) { set_user_config_option('TM tasks user filter', $tasksUserId, logged_user()->getId()); } } $timeslotsUserId = array_var($_GET, 'tsu'); if (is_null($timeslotsUserId)) { $timeslotsUserId = user_config_option('TM user filter', 0); } else { if (user_config_option('TM user filter') != $timeslotsUserId) { set_user_config_option('TM user filter', $timeslotsUserId, logged_user()->getId()); } } $showTimeType = array_var($_GET, 'stt'); if (is_null($showTimeType)) { $showTimeType = user_config_option('TM show time type', 0); } else { if (user_config_option('TM show time type') != $showTimeType) { set_user_config_option('TM show time type', $showTimeType, logged_user()->getId()); } } $start = array_var($_GET, 'start', 0); $limit = 20; $tasksUser = Users::findById($tasksUserId); $timeslotsUser = Users::findById($timeslotsUserId); //Active tasks view $tasks = ProjectTasks::getOpenTimeslotTasks($tasksUser, logged_user()); ProjectTasks::populateData($tasks); $tasks_array = array(); //Timeslots view $total = 0; switch ($showTimeType) { case 0: //Show only timeslots added through the time panel $timeslots = Timeslots::getProjectTimeslots(logged_user()->getWorkspacesQuery(), $timeslotsUser, active_project(), $start, $limit); $total = Timeslots::countProjectTimeslots(logged_user()->getWorkspacesQuery(), $timeslotsUser, active_project()); break; case 1: //Show only timeslots added through the tasks panel / tasks throw new Error('not yet implemented' . $showTimeType); /*if (active_project() instanceof Project){ $workspacesCSV = active_project()->getAllSubWorkspacesQuery(false,logged_user()); } else { $workspacesCSV = logged_user()->getWorkspacesQuery(); } $taskTimeslots = Timeslots::getTaskTimeslots(null, $timeslotsUser, $workspacesCSV, null , null, null, null,0,20);*/ //break; /*if (active_project() instanceof Project){ $workspacesCSV = active_project()->getAllSubWorkspacesQuery(false,logged_user()); } else { $workspacesCSV = logged_user()->getWorkspacesQuery(); } $taskTimeslots = Timeslots::getTaskTimeslots(null, $timeslotsUser, $workspacesCSV, null , null, null, null,0,20);*/ //break; case 2: //Show timeslots added through both the time and tasks panel / tasks throw new Error('not yet implemented' . $showTimeType); //break; //break; default: throw new Error('Unrecognised TM show time type: ' . $showTimeType); } //Get Users Info if (logged_user()->isMemberOfOwnerCompany()) { $users = Users::getAll(); } else { $users = logged_user()->getCompany()->getUsers(); } //Get Companies Info if (logged_user()->isMemberOfOwnerCompany()) { $companies = Companies::getCompaniesWithUsers(); } else { $companies = array(logged_user()->getCompany()); } tpl_assign('timeslots', $timeslots); tpl_assign('tasks', $tasks); tpl_assign('users', $users); tpl_assign('start', $start); tpl_assign('limit', $limit); tpl_assign('total', $total); tpl_assign('companies', $companies); ajx_set_no_toolbar(true); }