/** * Shows weekly schedule in a calendar view * * @param void * @return null */ function weekly_schedule() { $this->addHelper('textile'); // Gets desired view 'detail', 'list' or 'calendar' // $view_type is from URL, Cookie or set to default: 'calendar' $view_type = array_var($_GET, 'view', Cookie::getValue('weeklyScheduleViewType', 'calendar')); $expiration = Cookie::getValue('remember' . TOKEN_COOKIE_NAME) ? REMEMBER_LOGIN_LIFETIME : null; Cookie::setValue('weeklyScheduleViewType', $view_type, $expiration); $monthYear = array_var($_GET, 'month'); if (!isset($monthYear) || trim($monthYear) == '' || preg_match('/^(\\d{4})(\\d{2})$/', $monthYear, $matches) == 0) { $year = gmdate('Y'); $month = gmdate('m'); } else { list(, $year, $month) = $matches; } // TODO make first day of week configurable $from_date = DateTimeValueLib::makeFromString('monday' . (date('w') == 1 ? '' : ' last week')); $to_date = $from_date->advance(60 * 60 * 24 * 7 * 3, false); // +3 weeks $upcoming_milestones = ProjectMilestones::getActiveMilestonesInPeriodByUser(logged_user(), $from_date, $to_date); $upcoming_tickets = array(); if (plugin_active('tickets')) { $upcoming_tickets = ProjectTickets::getOpenTicketsInPeriodByUser(logged_user(), $from_date, $to_date); } $active_projects = array(); $projects_index = array(); $counter = 1; if (is_array($upcoming_milestones)) { foreach ($upcoming_milestones as $milestone) { if (!isset($projects_index[$milestone->getProjectId()])) { $projects_index[$milestone->getProjectId()] = $counter; $active_projects[] = $milestone->getProject(); $counter++; } // if } // foreach } // if if (is_array($upcoming_tickets)) { foreach ($upcoming_tickets as $ticket) { if (!isset($projects_index[$ticket->getProjectId()])) { $projects_index[$ticket->getProjectId()] = $counter; $active_projects[] = $ticket->getProject(); $counter++; } // if } // foreach } // if tpl_assign('from_date', $from_date); tpl_assign('to_date', $to_date); tpl_assign('view_type', $view_type); tpl_assign('upcoming_tickets', $upcoming_tickets); tpl_assign('late_tickets', array()); // logged_user()->getLateTickets()); tpl_assign('upcoming_milestones', $upcoming_milestones); tpl_assign('late_milestones', array()); // logged_user()->getLateMilestones()); tpl_assign('projects', $active_projects); tpl_assign('projects_index', $projects_index); }