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); }
/** * Show dashboard index page * * @param void * @return null */ function index() { $this->setHelp('dashboard'); $tag = array_var($_GET, 'active_tag'); $logged_user = logged_user(); if (active_project() instanceof Project) { $wscsv = active_project()->getAllSubWorkspacesQuery(true); } else { $wscsv = null; } $activity_log = null; $include_private = $logged_user->isMemberOfOwnerCompany(); $include_silent = $logged_user->isAdministrator(); $activity_log = ApplicationLogs::getOverallLogs($include_private, $include_silent, $wscsv, config_option('dashboard_logs_count', 15)); if (user_config_option('show charts widget') && module_enabled('reporting')) { $charts = ProjectCharts::getChartsAtProject(active_project(), active_tag()); tpl_assign('charts', $charts); if (BillingCategories::count() > 0 && active_project() instanceof Project) { tpl_assign('billing_chart_data', active_project()->getBillingTotalByUsers(logged_user())); } } if (user_config_option('show messages widget') && module_enabled('notes')) { list($messages, $pagination) = ProjectMessages::getMessages(active_tag(), active_project(), 0, 10, '`updated_on`', 'DESC', false); tpl_assign('messages', $messages); } if (user_config_option('show comments widget')) { $comments = Comments::getSubscriberComments(active_project(), $tag); tpl_assign('comments', $comments); } if (user_config_option('show documents widget') && module_enabled('documents')) { list($documents, $pagination) = ProjectFiles::getProjectFiles(active_project(), null, false, ProjectFiles::ORDER_BY_MODIFYTIME, 'DESC', 1, 10, false, active_tag(), null); tpl_assign('documents', $documents); } if (user_config_option('show emails widget') && module_enabled('email')) { $activeWs = active_project(); list($unread_emails, $pagination) = MailContents::getEmails($tag, null, 'received', 'unread', '', $activeWs, 0, 10); if ($activeWs && user_config_option('always show unread mail in dashboard')) { // add unread unclassified emails list($all_unread, $pagination) = MailContents::getEmails($tag, null, 'received', 'unread', 'unclassified', null, 0, 10); $unread_emails = array_merge($unread_emails, $all_unread); } tpl_assign('unread_emails', $unread_emails); } //Tasks widgets $show_pending = user_config_option('show pending tasks widget') && module_enabled('tasks'); $show_in_progress = user_config_option('show tasks in progress widget') && module_enabled('tasks'); $show_late = user_config_option('show late tasks and milestones widget') && module_enabled('tasks'); if ($show_pending || $show_in_progress || $show_late) { $assigned_to = explode(':', user_config_option('pending tasks widget assigned to filter')); $to_company = array_var($assigned_to, 0, 0); $to_user = array_var($assigned_to, 1, 0); tpl_assign('assigned_to_user_filter', $to_user); tpl_assign('assigned_to_company_filter', $to_company); } if ($show_pending) { $tasks = ProjectTasks::getProjectTasks(active_project(), ProjectTasks::ORDER_BY_DUEDATE, 'ASC', null, null, $tag, $to_company, $to_user, null, true, 'all', false, false, false, 10); tpl_assign('dashtasks', $tasks); } if ($show_in_progress) { $tasks_in_progress = ProjectTasks::getOpenTimeslotTasks(logged_user(), logged_user(), active_project(), $tag, $to_company, $to_user); tpl_assign('tasks_in_progress', $tasks_in_progress); } if ($show_late) { tpl_assign('today_milestones', $logged_user->getTodayMilestones(active_project(), $tag, 10)); tpl_assign('late_milestones', $logged_user->getLateMilestones(active_project(), $tag, 10)); tpl_assign('today_tasks', ProjectTasks::getDayTasksByUser(DateTimeValueLib::now(), $logged_user, active_project(), $tag, $to_company, $to_user, 10)); tpl_assign('late_tasks', ProjectTasks::getLateTasksByUser($logged_user, active_project(), $tag, $to_company, $to_user, 10)); } tpl_assign('activity_log', $activity_log); $usu = logged_user(); $conditions = array("conditions" => array("`state` >= 200 AND (`state`%2 = 0) AND `trashed_by_id`=0 AND `created_by_id` =" . $usu->getId())); $outbox_mails = MailContents::findAll($conditions); if ($outbox_mails != null) { if (count($outbox_mails) == 1) { flash_error(lang('outbox mail not sent', 1)); } else { if (count($outbox_mails) > 1) { flash_error(lang('outbox mails not sent', count($outbox_mails))); } } } ajx_set_no_toolbar(true); }