function view_milestones() { ajx_current("empty"); $project = active_project(); $tag = active_tag(); $assigned_by = array_var($_GET, 'assigned_by', ''); $assigned_to = array_var($_GET, 'assigned_to', ''); $status = array_var($_GET, 'status', "pending"); // $assigned_to = explode(':', $assigned_to); $to_company = array_var($assigned_to, 0, null); $to_user = array_var($assigned_to, 1, null); $assigned_by = explode(':', $assigned_by); $by_company = array_var($assigned_by, 0, null); $by_user = array_var($assigned_by, 1, null); $milestones = ProjectMilestones::getProjectMilestones($project, null, 'ASC', $tag, $to_company, $to_user, $by_user, $status == 'pending'); $milestones_bottom_complete = array(); $ms = array(); foreach ($milestones as $milestone) { if (!$milestone->isCompleted()) { $milestones_bottom_complete[] = $milestone; $ms[] = $this->milestone_item($milestone); } } foreach ($milestones as $milestone) { if ($milestone->isCompleted()) { $milestones_bottom_complete[] = $milestone; $ms[] = $this->milestone_item($milestone); } } ajx_extra_data(array("milestones" => $ms)); tpl_assign('milestones', $milestones_bottom_complete); tpl_assign('project', $project); }
<div class="dashboard" style="width:100%;"> <div class="dashWorkspace"> <span class="name"> <?php if(active_project() instanceof Project) echo clean(active_project()->getName()); else echo lang('all projects'); $use_24_hours = user_config_option('time_format_use_24'); if($use_24_hours) $timeformat = 'G:i'; else $timeformat = 'g:i A'; $tags = active_tag(); $hasPendingTasks = isset($dashtasks) && is_array($dashtasks) && count($dashtasks) > 0; $hasLateMilestones = (isset($today_milestones) && is_array($today_milestones) && count($today_milestones)) || (isset($late_milestones) && is_array($late_milestones) && count($late_milestones)); $hasMessages = isset($messages) && is_array($messages) && count($messages) > 0; $hasDocuments = isset($documents) && is_array($documents) && count($documents) > 0; $hasCharts = (isset($charts) && is_array($charts) && count($charts) > 0) || (isset($billing_chart_data) && is_array($billing_chart_data) && count($billing_chart_data) > 0); $hasEmails = (isset($unread_emails) && is_array($unread_emails) && count($unread_emails) > 0) || (isset($ws_emails) && is_array($ws_emails) && count($ws_emails) > 0); $hasToday = (isset($today_milestones) && is_array($today_milestones) && count($today_milestones)) || (isset($today_tasks) && is_array($today_tasks) && count($today_tasks)); $hasLate = (isset($late_tasks) && is_array($late_tasks) && count($late_tasks)) || (isset($late_milestones) && is_array($late_milestones) && count($late_milestones)); $hasComments = isset($comments) && is_array($comments) && count($comments) > 0;
function new_list_tasks() { //load config options into cache for better performance load_user_config_options_by_category_name('task panel'); // get query parameters, save user preferences if necessary $status = array_var($_GET, 'status', null); if (is_null($status) || $status == '') { $status = user_config_option('task panel status', 2); } else { if (user_config_option('task panel status') != $status) { set_user_config_option('task panel status', $status, logged_user()->getId()); } } $previous_filter = user_config_option('task panel filter', 'assigned_to'); $filter = array_var($_GET, 'filter'); if (is_null($filter) || $filter == '') { $filter = user_config_option('task panel filter', 'assigned_to'); } else { if (user_config_option('task panel filter') != $filter) { set_user_config_option('task panel filter', $filter, logged_user()->getId()); } } if ($filter != 'no_filter') { $filter_value = array_var($_GET, 'fval'); if (is_null($filter_value) || $filter_value == '') { $filter_value = user_config_option('task panel filter value', logged_user()->getCompanyId() . ':' . logged_user()->getId()); set_user_config_option('task panel filter value', $filter_value, logged_user()->getId()); $filter = $previous_filter; set_user_config_option('task panel filter', $filter, logged_user()->getId()); } else { if (user_config_option('task panel filter value') != $filter_value) { set_user_config_option('task panel filter value', $filter_value, logged_user()->getId()); } } } $isJson = array_var($_GET, 'isJson', false); if ($isJson) { ajx_current("empty"); } $project = active_project(); $tag = active_tag(); $template_condition = "`is_template` = 0 "; //Get the task query conditions $task_filter_condition = ""; switch ($filter) { case 'assigned_to': $assigned_to = explode(':', $filter_value); $assigned_to_user = array_var($assigned_to, 1, 0); $assigned_to_company = array_var($assigned_to, 0, 0); if ($assigned_to_user > 0) { $task_filter_condition = " AND (`assigned_to_user_id` = " . $assigned_to_user . " OR (`assigned_to_company_id` = " . $assigned_to_company . " AND `assigned_to_user_id` = 0)) "; } else { if ($assigned_to_company > 0) { $task_filter_condition = " AND `assigned_to_company_id` = " . $assigned_to_company . " AND `assigned_to_user_id` = 0"; } else { if ($assigned_to_company == -1 && $assigned_to_user == -1) { $task_filter_condition = " AND `assigned_to_company_id` = 0 AND `assigned_to_user_id` = 0 "; } } } break; case 'assigned_by': if ($filter_value != 0) { $task_filter_condition = " AND `assigned_by_id` = " . $filter_value . " "; } break; case 'created_by': if ($filter_value != 0) { $task_filter_condition = " AND `created_by_id` = " . $filter_value . " "; } break; case 'completed_by': if ($filter_value != 0) { $task_filter_condition = " AND `completed_by_id` = " . $filter_value . " "; } break; case 'milestone': $task_filter_condition = " AND `milestone_id` = " . $filter_value . " "; break; case 'priority': $task_filter_condition = " AND `priority` = " . $filter_value . " "; break; case 'subtype': if ($filter_value != 0) { $task_filter_condition = " AND `object_subtype` = " . $filter_value . " "; } break; case 'no_filter': $task_filter_condition = ""; break; default: flash_error(lang('task filter criteria not recognised', $filter)); } if ($project instanceof Project) { $pids = $project->getAllSubWorkspacesQuery(true); $projectstr = " AND " . ProjectTasks::getWorkspaceString($pids); } else { $pids = ""; $projectstr = ""; } $permissions = " AND " . permissions_sql_for_listings(ProjectTasks::instance(), ACCESS_LEVEL_READ, logged_user()); $task_status_condition = ""; switch ($status) { case 0: // Incomplete tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME); break; case 1: // Complete tasks $task_status_condition = " AND `completed_on` > " . DB::escape(EMPTY_DATETIME); break; case 10: // Active tasks $now = date('Y-m-j 00:00:00'); $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}'"; break; case 11: // Overdue tasks $now = date('Y-m-j 00:00:00'); $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` < '{$now}'"; break; case 12: // Today tasks $now = date('Y-m-j 00:00:00'); $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` = '{$now}'"; break; case 13: // Today + Overdue tasks $now = date('Y-m-j 00:00:00'); $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'"; break; case 14: // Today + Overdue tasks $now = date('Y-m-j 00:00:00'); $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'"; break; case 20: // Actives task by current user $now = date('Y-m-j 00:00:00'); $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}' AND `assigned_to_user_id` = " . logged_user()->getId(); break; case 21: // Subscribed tasks by current user $res20 = DB::execute("SELECT object_id FROM " . TABLE_PREFIX . "object_subscriptions WHERE `object_manager` LIKE 'ProjectTasks' AND `user_id` = " . logged_user()->getId()); $subs_rows = $res20->fetchAll($res20); foreach ($subs_rows as $row) { $subs[] = $row['object_id']; } unset($res20, $subs_rows, $row); $now = date('Y-m-j 00:00:00'); $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `id` IN(" . implode(',', $subs) . ")"; break; case 2: // All tasks break; default: throw new Exception('Task status "' . $status . '" not recognised'); } if (!$tag) { $tagstr = ""; } else { $tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_tasks.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectTasks' ) > 0 "; } $conditions = $template_condition . $task_filter_condition . $task_status_condition . $permissions . $tagstr . $projectstr . " AND `trashed_by_id` = 0 AND `archived_by_id` = 0"; //Now get the tasks $tasks = ProjectTasks::findAll(array('conditions' => $conditions, 'order' => 'created_on DESC', 'limit' => user_config_option('task_display_limit') > 0 ? user_config_option('task_display_limit') + 1 : null)); ProjectTasks::populateData($tasks); //Find all internal milestones for these tasks $internalMilestones = ProjectMilestones::getProjectMilestones(active_or_personal_project(), null, 'DESC', "", null, null, null, $status == 0, false); ProjectMilestones::populateData($internalMilestones); //Find all external milestones for these tasks $milestone_ids = array(); if ($tasks) { foreach ($tasks as $task) { if ($task->getMilestoneId() != 0) { $milestone_ids[$task->getMilestoneId()] = $task->getMilestoneId(); } } } $milestone_ids_condition = ''; if (count($milestone_ids) > 0) { $milestone_ids_condition = ' OR id in (' . implode(',', $milestone_ids) . ')'; } if ($status == 0) { $pendingstr = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " "; } else { $pendingstr = ""; } if (!$tag) { $tagstr = ""; } else { $tagstr = " AND (select count(*) from " . TABLE_PREFIX . "tags where " . TABLE_PREFIX . "project_milestones.id = " . TABLE_PREFIX . "tags.rel_object_id and " . TABLE_PREFIX . "tags.tag = " . DB::escape($tag) . " and " . TABLE_PREFIX . "tags.rel_object_manager ='ProjectMilestones' ) > 0 "; } $projectstr = " AND (" . ProjectMilestones::getWorkspaceString($pids) . $milestone_ids_condition . ")"; $archivedstr = " AND `archived_by_id` = 0 "; $milestone_conditions = " `is_template` = false " . $archivedstr . $projectstr . $pendingstr; $externalMilestonesTemp = ProjectMilestones::findAll(array('conditions' => $milestone_conditions)); $externalMilestones = array(); if ($externalMilestonesTemp) { foreach ($externalMilestonesTemp as $em) { $found = false; if ($internalMilestones) { foreach ($internalMilestones as $im) { if ($im->getId() == $em->getId()) { $found = true; break; } } } if (!$found) { $externalMilestones[] = $em; } } } ProjectMilestones::populateData($externalMilestones); //Get Users Info if (logged_user()->isMemberOfOwnerCompany()) { $users = Users::getAll(); $allUsers = array(); } else { $users = logged_user()->getAssignableUsers(); $allUsers = Users::getAll(); } //Get Companies Info if (logged_user()->isMemberOfOwnerCompany()) { $companies = Companies::getCompaniesWithUsers(); } else { $companies = logged_user()->getAssignableCompanies(); } if (!$isJson) { if (active_project() instanceof Project) { $task_templates = WorkspaceTemplates::getTemplatesByWorkspace(active_project()->getId()); } else { $task_templates = array(); } tpl_assign('project_templates', $task_templates); tpl_assign('all_templates', COTemplates::findAll()); if (user_config_option('task_display_limit') > 0 && count($tasks) > user_config_option('task_display_limit')) { tpl_assign('displayTooManyTasks', true); array_pop($tasks); } tpl_assign('tasks', $tasks); tpl_assign('object_subtypes', ProjectCoTypes::getObjectTypesByManager('ProjectTasks')); tpl_assign('internalMilestones', $internalMilestones); tpl_assign('externalMilestones', $externalMilestones); tpl_assign('users', $users); tpl_assign('allUsers', $allUsers); tpl_assign('companies', $companies); tpl_assign('userPreferences', array('filterValue' => isset($filter_value) ? $filter_value : '', 'filter' => $filter, 'status' => $status, 'showWorkspaces' => user_config_option('tasksShowWorkspaces', 1), 'showTime' => user_config_option('tasksShowTime', 0), 'showDates' => user_config_option('tasksShowDates', 0), 'showTags' => user_config_option('tasksShowTags', 0), 'showEmptyMilestones' => user_config_option('tasksShowEmptyMilestones', 0), 'groupBy' => user_config_option('tasksGroupBy', 'milestone'), 'orderBy' => user_config_option('tasksOrderBy', 'priority'), 'defaultNotifyValue' => user_config_option('can notify from quick add'))); ajx_set_no_toolbar(true); } }
function icalendar_export() { $this->setTemplate('cal_export'); $calendar_name = array_var($_POST, 'calendar_name'); if ($calendar_name != '') { $from = getDateValue(array_var($_POST, 'from_date')); $to = getDateValue(array_var($_POST, 'to_date')); $tags = ''; $events = ProjectEvents::getRangeProjectEvents($from, $to, active_tag(), active_project()); $buffer = CalFormatUtilities::generateICalInfo($events, $calendar_name); $filename = rand() . '.tmp'; $handle = fopen(ROOT . '/tmp/' . $filename, 'wb'); fwrite($handle, $buffer); fclose($handle); $_SESSION['calendar_export_filename'] = $filename; $_SESSION['calendar_name'] = $calendar_name; flash_success(lang('success export calendar', count($events))); ajx_current("back", 2); } else { unset($_SESSION['calendar_export_filename']); unset($_SESSION['calendar_name']); return; } }
/** * 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); }
</legend> <div id="<?php echo $genid; ?> attachments"></div> <a href="#" onclick="og.attachFromWorkspace('<?php echo $genid; ?> ')"> <?php echo lang('attach from workspace'); ?> </a> <br/> <a href="#" onclick="og.attachFromFileSystem(<?php echo active_or_personal_project()->getId() . ',\'' . active_tag() . '\''; ?> , '<?php echo $genid; ?> ')"> <?php echo lang('attach from file system'); ?> </a> <script type="text/javascript"> // add attachments var container = document.getElementById('<?php echo $genid; ?> attachments');
$tempParent = $x->getParentId(); $ant = $x; $x = $x->getParentWorkspace(); } if (!$x instanceof Project) { $tempParent = 0; $sub_wss[] = $w; } } } $sub_wss_csv = array(); foreach ($sub_wss as $sub_ws) { $sub_wss_csv[] = $sub_ws->getId(); } $linked_object_actions = array(); $activities = ApplicationLogs::getLastActivities($ws, active_tag(), user_config_option('activity widget elements')); $groups = array(); $first = null; $obj_wss_cache = array(); foreach ($activities as $act) { $user = Users::findById($act->getCreatedById()); $object = get_object_by_manager_and_id($act->getRelObjectId(), $act->getRelObjectManager()); if (!$user || !$object) { continue; } /* if ($user && $object && $act->getAction() != 'login' && $act->getAction() != 'logout' && !can_access($user, $object, ACCESS_LEVEL_READ)) continue; */ $avatar_url = $user->getAvatarUrl(); $date = $act->getCreatedOn() instanceof DateTimeValue ? friendly_date($act->getCreatedOn()) : lang('n/a'); $dontshow = false;