Example #1
0
 public function executeGoto(sfWebRequest $request)
 {
     $q = Doctrine_Core::getTable('Discussions')->createQuery('d')->leftJoin('d.DiscussionsStatus ds')->leftJoin('d.Projects p')->leftJoin('d.Users');
     $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
     if (Users::hasAccess('view_own', 'discussions', $this->getUser(), $request->getParameter('projects_id'))) {
         $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',d.assigned_to) or d.users_id='" . $this->getUser()->getAttribute('id') . "'");
     }
     $q = Discussions::addFiltersToQuery($q, $this->getUser()->getAttribute('discussions_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
     $q = app::addListingOrder($q, 'discussions', $this->getUser(), (int) $request->getParameter('projects_id'));
     $this->menu = array();
     $ids = array();
     foreach ($q->fetchArray() as $v) {
         if (strlen($sn = app::getArrayName($v, 'DiscussionsStatus')) > 0) {
             $sn = $sn . ': ';
         } else {
             $sn = '';
         }
         if ($request->getParameter('discussions_id') == $v['id']) {
             $v['name'] = '<b>' . $v['name'] . '</b>';
         }
         $this->menu[] = array('title' => $sn . $v['name'], 'url' => 'discussionsComments/index?projects_id=' . $request->getParameter('projects_id') . '&discussions_id=' . $v['id']);
         $ids[] = $v['id'];
     }
     $current_key = array_search($request->getParameter('discussions_id'), $ids);
     $this->previous_item_id = false;
     $this->next_item_id = false;
     if (isset($ids[$current_key - 1])) {
         $this->previous_item_id = $ids[$current_key - 1];
     }
     if (isset($ids[$current_key + 1])) {
         $this->next_item_id = $ids[$current_key + 1];
     }
 }
Example #2
0
 public function executeGoto(sfWebRequest $request)
 {
     $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users');
     $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
     if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
         $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
     }
     $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('tasks_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
     $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id'));
     $this->menu = array();
     $tasks_ids = array();
     foreach ($q->fetchArray() as $tasks) {
         if (strlen($sn = app::getArrayName($tasks, 'TasksStatus')) > 0) {
             $sn = $sn . ': ';
         } else {
             $sn = '';
         }
         if ($request->getParameter('tasks_id') == $tasks['id']) {
             $tasks['name'] = '<b>' . $tasks['name'] . '</b>';
         }
         $this->menu[] = array('title' => $sn . $tasks['name'], 'url' => 'tasksComments/index?projects_id=' . $request->getParameter('projects_id') . '&tasks_id=' . $tasks['id']);
         $tasks_ids[] = $tasks['id'];
     }
     $current_key = array_search($request->getParameter('tasks_id'), $tasks_ids);
     $this->previous_tasks_id = false;
     $this->next_tasks_id = false;
     if (isset($tasks_ids[$current_key - 1])) {
         $this->previous_tasks_id = $tasks_ids[$current_key - 1];
     }
     if (isset($tasks_ids[$current_key + 1])) {
         $this->next_tasks_id = $tasks_ids[$current_key + 1];
     }
 }
Example #3
0
 public function executeGoto(sfWebRequest $request)
 {
     $q = Doctrine_Core::getTable('Tickets')->createQuery('t')->leftJoin('t.TicketsStatus ts')->leftJoin('t.TicketsTypes tt')->leftJoin('t.Departments td')->leftJoin('t.Projects p')->leftJoin('t.Users');
     $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
     if (Users::hasAccess('view_own', 'tickets', $this->getUser(), $request->getParameter('projects_id'))) {
         $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'");
     }
     $q = Tickets::addFiltersToQuery($q, $this->getUser()->getAttribute('tickets_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
     $q = app::addListingOrder($q, 'tickets', $this->getUser(), (int) $request->getParameter('projects_id'));
     $this->menu = array();
     $ids = array();
     foreach ($q->fetchArray() as $v) {
         if (strlen($sn = app::getArrayName($v, 'TicketsStatus')) > 0) {
             $sn = $sn . ': ';
         } else {
             $sn = '';
         }
         if ($request->getParameter('tickets_id') == $v['id']) {
             $v['name'] = '<b>' . $v['name'] . '</b>';
         }
         $this->menu[] = array('title' => $sn . $v['name'], 'url' => 'ticketsComments/index?projects_id=' . $request->getParameter('projects_id') . '&tickets_id=' . $v['id']);
         $ids[] = $v['id'];
     }
     $current_key = array_search($request->getParameter('tickets_id'), $ids);
     $this->previous_item_id = false;
     $this->next_item_id = false;
     if (isset($ids[$current_key - 1])) {
         $this->previous_item_id = $ids[$current_key - 1];
     }
     if (isset($ids[$current_key + 1])) {
         $this->next_item_id = $ids[$current_key + 1];
     }
 }
Example #4
0
 public function buildProjectsMenu()
 {
     $s = array();
     $reports = Doctrine_Core::getTable('ProjectsReports')->createQuery()->addWhere('(users_id="' . $this->sf_user->getAttribute('id') . '")')->addWhere('display_in_menu=1')->orderBy('sort_order, name')->execute();
     $is_hr = false;
     foreach ($reports as $r) {
         $is_hr = true;
         $q = Doctrine_Core::getTable('Projects')->createQuery('p')->leftJoin('p.ProjectsStatus ps')->leftJoin('p.ProjectsTypes pt')->leftJoin('p.Users');
         $q = ProjectsReports::addFiltersToQuery($q, $r->getId(), $this->sf_user);
         if (Users::hasAccess('view_own', 'projects', $this->sf_user)) {
             $q->addWhere("find_in_set('" . $this->sf_user->getAttribute('id') . "',p.team) or p.created_by='" . $this->sf_user->getAttribute('id') . "'");
         }
         $pm = array();
         foreach ($q->fetchArray() as $p) {
             $pm[] = array('title' => $p['name'], 'url' => 'projects/open?projects_id=' . $p['id']);
         }
         $s[] = array('title' => $r->getName(), 'url' => 'projectsReports/view?id=' . $r->getId(), 'submenu' => $pm);
     }
     if ($this->access['projects']['insert']) {
         $s[] = array('title' => __('Add Project'), 'url' => 'projects/new', 'modalbox' => true, 'is_hr' => $is_hr);
         $is_hr = false;
     }
     $s[] = array('title' => __('View All'), 'url' => 'projects/index', 'is_hr' => $is_hr);
     return array('title' => __('Projects'), 'url' => 'projects/index', 'submenu' => $s);
 }
Example #5
0
 function checkViewOwnAccess($comments, $projects)
 {
     if (Users::hasAccess('view_own', 'projectsComments', $this->getUser(), $projects->getId())) {
         if ($comments->getCreatedBy() != $this->getUser()->getAttribute('id')) {
             $this->redirect('accessForbidden/index');
         }
     }
 }
Example #6
0
 public static function checkViewOwnAccess($c, $sf_user, $discussions, $project)
 {
     if (Users::hasAccess('view_own', 'discussions', $sf_user, $project->getId())) {
         if (!in_array($sf_user->getAttribute('id'), explode(',', $discussions->getAssignedTo())) and $discussions->getUsersId() != $sf_user->getAttribute('id')) {
             $c->redirect('accessForbidden/index');
         }
     }
 }
Example #7
0
 public static function checkViewOwnAccess($c, $sf_user, $project)
 {
     if (Users::hasAccess('view_own', 'projects', $sf_user)) {
         if (!in_array($sf_user->getAttribute('id'), explode(',', $project->getTeam())) and $project->getCreatedBy() != $sf_user->getAttribute('id')) {
             $c->redirect('accessForbidden/index');
         }
     }
 }
Example #8
0
 public function executeListing(sfWebRequest $request)
 {
     if (!isset($this->reports_id)) {
         $this->reports_id = false;
     }
     $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users');
     if ($request->hasParameter('projects_id')) {
         $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
         if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     } else {
         if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
         if (Users::hasAccess('view_own', 'tasks', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     }
     if ($this->reports_id > 0) {
         $q = UserReports::addFiltersToQuery($q, $this->reports_id, $this->getUser()->getAttribute('id'));
     } elseif ($request->hasParameter('search')) {
         $q = app::addSearchQuery($q, $request->getParameter('search'), 'TasksComments', 't', $request->getParameter('search_by_extrafields'));
         $q = app::addListingOrder($q, 'tasks', $this->getUser());
     } else {
         $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('tasks_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
         $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id'));
     }
     $this->pager = false;
     if (sfConfig::get('app_rows_limit') > 0) {
         $this->pager = new sfDoctrinePager('Tasks', sfConfig::get('app_rows_limit'));
         $this->pager->setQuery($q);
         $this->pager->setPage($request->getParameter('page', 1));
         $this->pager->init();
     }
     $this->tasks_list = $q->fetchArray();
     if (isset($this->is_dashboard)) {
         $this->url_params = 'redirect_to=dashboard';
         $this->display_insert_button = true;
     } elseif ($this->reports_id > 0) {
         $this->url_params = 'redirect_to=userReports' . $this->reports_id;
         $this->display_insert_button = true;
     } else {
         $this->url_params = 'redirect_to=tasksList';
         if ($request->hasParameter('projects_id')) {
             $this->url_params = 'projects_id=' . $request->getParameter('projects_id');
         }
         $this->display_insert_button = true;
     }
     $this->tlId = rand(1111111, 9999999);
     $this->users_schema = Users::getSchema();
 }
Example #9
0
 public static function checkViewOwnAccess($c, $sf_user, $tickets, $project = false)
 {
     if ($project) {
         $has_access = Users::hasAccess('view_own', 'tickets', $sf_user, $project->getId());
     } else {
         $has_access = Users::hasAccess('view_own', 'tickets', $sf_user);
     }
     if ($has_access) {
         if (!in_array($tickets->getDepartmentsId(), Departments::getDepartmentIdByUserId($sf_user->getAttribute('id'))) and $tickets->getUsersId() != $sf_user->getAttribute('id')) {
             $c->redirect('accessForbidden/index');
         }
     }
 }
Example #10
0
 public function executeListing(sfWebRequest $request)
 {
     if (!isset($this->reports_id)) {
         $this->reports_id = false;
     }
     $q = Doctrine_Core::getTable('Tickets')->createQuery('t')->leftJoin('t.TicketsStatus ts')->leftJoin('t.TicketsTypes tt')->leftJoin('t.Departments td')->leftJoin('t.Projects p')->leftJoin('t.Users');
     if ($request->hasParameter('projects_id')) {
         $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
         if (Users::hasAccess('view_own', 'tickets', $this->getUser(), $request->getParameter('projects_id'))) {
             $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'");
         }
     } else {
         if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
         if (Users::hasAccess('view_own', 'tickets', $this->getUser())) {
             $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'");
         }
     }
     if ($this->reports_id > 0) {
         $q = TicketsReports::addFiltersToQuery($q, $this->reports_id, $this->getUser());
     } elseif ($request->hasParameter('search')) {
         $q = app::addSearchQuery($q, $request->getParameter('search'), 'TicketsComments', 't', $request->getParameter('search_by_extrafields'));
         $q = app::addListingOrder($q, 'tickets', $this->getUser());
     } else {
         $q = Tickets::addFiltersToQuery($q, $this->getUser()->getAttribute('tickets_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
         $q = app::addListingOrder($q, 'tickets', $this->getUser(), (int) $request->getParameter('projects_id'));
     }
     if (sfConfig::get('app_rows_limit') > 0) {
         $this->pager = new sfDoctrinePager('Tickets', sfConfig::get('app_rows_limit'));
         $this->pager->setQuery($q);
         $this->pager->setPage($request->getParameter('page', 1));
         $this->pager->init();
     }
     $this->tickets_list = $q->fetchArray();
     if (isset($this->is_dashboard)) {
         $this->url_params = 'redirect_to=dashboard';
         $this->display_insert_button = true;
     } elseif ($this->reports_id > 0) {
         $this->url_params = 'redirect_to=ticketsReports' . $this->reports_id;
         $this->display_insert_button = true;
     } else {
         $this->url_params = 'redirect_to=ticketsList';
         if ($request->hasParameter('projects_id')) {
             $this->url_params = 'projects_id=' . $request->getParameter('projects_id');
         }
         $this->display_insert_button = true;
     }
     $this->tlId = rand(1111111, 9999999);
 }
Example #11
0
 protected function getMoreActions(sfWebRequest $request)
 {
     $more_actions = array();
     $s = array();
     if (Users::hasAccess('edit', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
         $s[] = array('title' => t::__('Move To'), 'url' => 'tasks/moveTo?tasks_id=' . $request->getParameter('tasks_id') . '&projects_id=' . $request->getParameter('projects_id') . '&redirect_to=tasksComments', 'modalbox' => true);
     }
     if (Users::hasAccess('delete', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
         $s[] = array('title' => t::__('Delete'), 'url' => 'tasks/delete?id=' . $request->getParameter('tasks_id') . '&projects_id=' . $request->getParameter('projects_id'), 'confirm' => true);
     }
     if (count($s) > 0) {
         $more_actions[] = array('title' => t::__('More Actions'), 'submenu' => $s);
     }
     return $more_actions;
 }
Example #12
0
 public function configure()
 {
     $projects = $this->getOption('projects');
     $sf_user = $this->getOption('sf_user');
     $this->widgetSchema['discussions_status_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('DiscussionsStatus')));
     $this->setDefault('discussions_status_id', app::getDefaultValueByTable('DiscussionsStatus'));
     $this->widgetSchema['assigned_to'] = new sfWidgetFormChoice(array('choices' => Users::getChoices(array_merge(array($sf_user->getAttribute('id')), array_filter(explode(',', $projects->getTeam()))), 'discussions'), 'expanded' => true, 'multiple' => true));
     if (Users::hasAccess('edit', 'projects', $sf_user, $projects->getId())) {
         $this->widgetSchema['users_id'] = new sfWidgetFormChoice(array('choices' => Users::getChoices(array_merge(array($sf_user->getAttribute('id')), array_filter(explode(',', $projects->getTeam()))), 'discussions_insert')));
     } else {
         $this->widgetSchema['users_id'] = new sfWidgetFormInputHidden();
     }
     $this->widgetSchema['name']->setAttributes(array('size' => '60', 'class' => 'required'));
     $this->widgetSchema['description']->setAttributes(array('class' => 'editor'));
     $this->widgetSchema['projects_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema->setLabels(array('discussions_status_id' => 'Status', 'assigned_to' => 'Assigned To', 'users_id' => 'Created By'));
 }
Example #13
0
 public function configure()
 {
     $projects = $this->getOption('projects');
     $sf_user = $this->getOption('sf_user');
     $this->widgetSchema['tasks_status_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksStatus')));
     $this->setDefault('tasks_status_id', app::getDefaultValueByTable('TasksStatus'));
     $this->widgetSchema['tasks_priority_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksPriority')));
     $this->setDefault('tasks_priority_id', app::getDefaultValueByTable('TasksPriority'));
     $this->widgetSchema['tasks_type_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksTypes')));
     $this->setDefault('tasks_type_id', app::getDefaultValueByTable('TasksTypes'));
     $this->widgetSchema['tasks_label_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksLabels')));
     $this->setDefault('tasks_label_id', app::getDefaultValueByTable('TasksLabels'));
     $this->widgetSchema['tasks_groups_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TasksGroups', true, $projects->getId())));
     $this->widgetSchema['projects_phases_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('ProjectsPhases', true, $projects->getId())));
     $this->widgetSchema['versions_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('Versions', true, $projects->getId())));
     $this->widgetSchema['progress'] = new sfWidgetFormChoice(array('choices' => Tasks::getProgressChoices()));
     $this->widgetSchema['assigned_to'] = new sfWidgetFormChoice(array('choices' => Users::getChoices(array_merge(array($sf_user->getAttribute('id')), array_filter(explode(',', $projects->getTeam()))), 'tasks'), 'expanded' => true, 'multiple' => true));
     if (Users::hasAccess('edit', 'projects', $sf_user, $projects->getId())) {
         $this->widgetSchema['created_by'] = new sfWidgetFormChoice(array('choices' => Users::getChoices(array_merge(array($sf_user->getAttribute('id')), array_filter(explode(',', $projects->getTeam()))), 'tasks_insert')));
     } else {
         $this->widgetSchema['created_by'] = new sfWidgetFormInputHidden();
     }
     $this->widgetSchema['name']->setAttributes(array('size' => '60', 'class' => 'required'));
     $this->widgetSchema['description']->setAttributes(array('class' => 'editor'));
     $this->widgetSchema['estimated_time']->setAttributes(array('size' => '4'));
     $this->widgetSchema['start_date'] = new sfWidgetFormInput(array(), array('class' => 'datetimepicker'));
     $this->widgetSchema['due_date'] = new sfWidgetFormInput(array(), array('class' => 'datetimepicker'));
     $this->widgetSchema['projects_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['closed_date'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['created_at'] = new sfWidgetFormInputHidden();
     $this->setDefault('created_at', date('Y-m-d H:i:s'));
     $this->widgetSchema->setLabels(array('tasks_priority_id' => 'Priority', 'tasks_type_id' => 'Type', 'tasks_label_id' => 'Label', 'projects_phases_id' => 'Phase', 'versions_id' => 'Version', 'tasks_groups_id' => 'Group', 'tasks_status_id' => 'Status', 'estimated_time' => 'Estimated Time', 'start_date' => 'Start Date', 'due_date' => 'Due Date', 'created_by' => 'Created By'));
     unset($this->widgetSchema['discussion_id']);
     unset($this->widgetSchema['tickets_id']);
     unset($this->widgetSchema['work_hours']);
     unset($this->validatorSchema['discussion_id']);
     unset($this->validatorSchema['tickets_id']);
     unset($this->validatorSchema['work_hours']);
 }
Example #14
0
 public function configure()
 {
     $projects = $this->getOption('projects');
     $sf_user = $this->getOption('sf_user');
     $this->widgetSchema['departments_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('Departments')), array('class' => 'required'));
     $this->widgetSchema['tickets_status_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TicketsStatus')));
     $this->setDefault('tickets_status_id', app::getDefaultValueByTable('TicketsStatus'));
     $this->widgetSchema['tickets_types_id'] = new sfWidgetFormChoice(array('choices' => app::getItemsChoicesByTable('TicketsTypes')));
     $this->setDefault('tickets_types_id', app::getDefaultValueByTable('TicketsTypes'));
     if ($projects) {
         if (Users::hasAccess('edit', 'projects', $sf_user, $projects->getId())) {
             $this->widgetSchema['users_id'] = new sfWidgetFormChoice(array('choices' => Users::getChoices(array_merge(array($sf_user->getAttribute('id')), array_filter(explode(',', $projects->getTeam()))), 'tickets_insert')));
         } else {
             $this->widgetSchema['users_id'] = new sfWidgetFormInputHidden();
         }
     }
     $this->widgetSchema['name']->setAttributes(array('size' => '60', 'class' => 'required'));
     $this->widgetSchema['description']->setAttributes(array('class' => 'editor'));
     $this->widgetSchema['projects_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['created_at'] = new sfWidgetFormInputHidden();
     $this->setDefault('created_at', date('Y-m-d H:i:s'));
     $this->widgetSchema->setLabels(array('tickets_types_id' => 'Type', 'tickets_status_id' => 'Status', 'departments_id' => 'Department', 'name' => 'Subject', 'users_id' => 'Created By'));
 }
Example #15
0
 public function executeListing(sfWebRequest $request)
 {
     if (!isset($this->reports_id)) {
         $this->reports_id = false;
     }
     $q = Doctrine_Core::getTable('Projects')->createQuery('p')->leftJoin('p.ProjectsStatus ps')->leftJoin('p.ProjectsTypes pt')->leftJoin('p.Users');
     if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
         $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',p.team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
     }
     if ($this->reports_id > 0) {
         $q = ProjectsReports::addFiltersToQuery($q, $this->reports_id, $this->getUser());
     } elseif ($request->hasParameter('search')) {
         $q = app::addSearchQuery($q, $request->getParameter('search'), 'ProjectsComments', 'p', $request->getParameter('search_by_extrafields'));
         $q = app::addListingOrder($q, 'projects', $this->getUser());
     } else {
         $q = Projects::addFiltersToQuery($q, $this->getUser()->getAttribute('projects_filter'));
         $q = app::addListingOrder($q, 'projects', $this->getUser());
     }
     if (sfConfig::get('app_rows_limit') > 0) {
         $this->pager = new sfDoctrinePager('Projects', sfConfig::get('app_rows_limit'));
         $this->pager->setQuery($q);
         $this->pager->setPage($request->getParameter('page', 1));
         $this->pager->init();
     }
     $this->projects_list = $q->fetchArray();
     if (isset($this->is_dashboard)) {
         $this->url_params = 'redirect_to=dashboard';
         $this->display_insert_button = true;
     } elseif ($this->reports_id > 0) {
         $this->url_params = 'redirect_to=projectsReports' . $this->reports_id;
         $this->display_insert_button = true;
     } else {
         $this->url_params = '';
         $this->display_insert_button = true;
     }
     $this->tlId = rand(1111111, 9999999);
 }
Example #16
0
 public function executeExport(sfWebRequest $request)
 {
     /*check access*/
     Users::checkAccess($this, 'view', $this->getModuleName(), $this->getUser());
     $this->columns = array('id' => t::__('Id'), 'ProjectsStatus' => t::__('Status'), 'name' => t::__('Name'), 'description' => t::__('Description'), 'team' => t::__('Team'), 'ProjectsTypes' => t::__('Type'), 'Users' => t::__('Created By'), 'created_at' => t::__('Created At'));
     $extra_fields = ExtraFieldsList::getFieldsByType('projects', $this->getUser(), false, array('all' => true));
     foreach ($extra_fields as $v) {
         $this->columns['extra_field_' . $v['id']] = $v['name'];
     }
     $this->columns['url'] = t::__('Url');
     if ($fields = $request->getParameter('fields')) {
         $separator = "\t";
         $format = $request->getParameter('format', '.csv');
         $filename = $request->getParameter('filename', 'projects');
         header("Content-type: Application/octet-stream");
         header("Content-disposition: attachment; filename=" . $filename . "." . $format);
         header("Pragma: no-cache");
         header("Expires: 0");
         $content = '';
         foreach ($fields as $f) {
             $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $this->columns[$f]) . $separator;
         }
         $content .= "\n";
         if ($format == 'csv') {
             echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
         } else {
             echo $content;
         }
         if (strlen($request->getParameter('selected_items') == 0)) {
             exit;
         }
         $q = Doctrine_Core::getTable('Projects')->createQuery('p')->leftJoin('p.ProjectsStatus ps')->leftJoin('p.ProjectsTypes pt')->leftJoin('p.Users')->whereIn('p.id', explode(',', $request->getParameter('selected_items')));
         if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',p.team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
         $q = app::addListingOrder($q, 'projects', $this->getUser());
         $projects = $q->fetchArray();
         $totals = array();
         foreach ($projects as $p) {
             $ex_values = ExtraFieldsList::getValuesList($extra_fields, $p['id']);
             $content = '';
             foreach ($fields as $f) {
                 $v = '';
                 if (in_array($f, array('id', 'name', 'description'))) {
                     $v = $p[$f];
                 } elseif (strstr($f, 'extra_field_')) {
                     if ($ex = Doctrine_Core::getTable('ExtraFields')->find(str_replace('extra_field_', '', $f))) {
                         $v = ExtraFieldsList::renderFieldValueByType($ex, $ex_values, array(), true);
                         if (in_array($ex->getType(), array('number', 'formula'))) {
                             if (!isset($totals[$ex->getId()])) {
                                 $totals[$ex->getId()] = 0;
                             }
                             $totals[$ex->getId()] += $v;
                         }
                         $v = str_replace('<br>', ', ', $v);
                     }
                 } elseif ($f == 'team') {
                     $v = Users::getNameById($p[$f], ', ');
                 } elseif ($f == 'created_at') {
                     if (strlen($p[$f]) > 0) {
                         $v = date(app::getDateTimeFormat(), app::getDateTimestamp($p[$f]));
                     }
                 } elseif ($f == 'url') {
                     $v = app::public_url('projectsComments/index?projects_id=' . $p['id']);
                 } else {
                     $v = app::getArrayName($p, $f);
                 }
                 $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
             }
             $content .= "\n";
             if ($format == 'csv') {
                 echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
             } else {
                 echo $content;
             }
         }
         $content = '';
         foreach ($fields as $f) {
             $v = '';
             if (strstr($f, 'extra_field_')) {
                 if (isset($totals[str_replace('extra_field_', '', $f)])) {
                     $v = $totals[str_replace('extra_field_', '', $f)];
                 }
             }
             $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
         }
         $content .= "\n";
         if ($format == 'csv') {
             echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
         } else {
             echo $content;
         }
         exit;
     }
 }
Example #17
0
$is_filter = array();
$is_filter['TasksPriority'] = app::countItemsByTable('TasksPriority');
$is_filter['TasksLabels'] = app::countItemsByTable('TasksLabels');
$is_filter['TasksStatus'] = app::countItemsByTable('TasksStatus');
$is_filter['TasksTypes'] = app::countItemsByTable('TasksTypes');
$is_filter['TasksGroups'] = app::countItemsByTable('TasksGroups', $sf_request->getParameter('projects_id'));
$is_filter['Versions'] = app::countItemsByTable('Versions', $sf_request->getParameter('projects_id'));
$is_filter['ProjectsPhases'] = app::countItemsByTable('ProjectsPhases', $sf_request->getParameter('projects_id'));
$in_listing = explode(',', sfConfig::get('app_tasks_columns_list'));
foreach ($is_filter as $k => $v) {
    if ($v == 0 and array_search($k, $in_listing) > 0) {
        unset($in_listing[array_search($k, $in_listing)]);
    }
}
$cols = 1;
$has_comments_access = Users::hasAccess('view', 'tasksComments', $sf_user);
?>
   

<table width="100%">
  <tr>
    <td>
      <table>
        <tr>
          <?php 
if ($display_insert_button) {
    ?>
          <td style="padding-right: 15px;"><?php 
    echo $lc->insert_button(__('Add Task'));
    ?>
</td>
Example #18
0
echo app::getReportFormFilterByTable('Status', 'user_reports[tasks_status_id]', 'TasksStatus', $form['tasks_status_id']->getValue());
?>
                    <?php 
echo app::getReportFormFilterByTable('Type', 'user_reports[tasks_type_id]', 'TasksTypes', $form['tasks_type_id']->getValue());
?>
                    <?php 
echo app::getReportFormFilterByTable('Label', 'user_reports[tasks_label_id]', 'TasksLabels', $form['tasks_label_id']->getValue());
?>
        
                  </tr>  
                </table>

                </td>
                
                <?php 
if (count($choices = Users::getChoices(array(), 'tasks')) > 0 and (Users::hasAccess('insert', 'tasks', $sf_user) or Users::hasAccess('edit', 'tasks', $sf_user))) {
    if (!is_string($v = $form['assigned_to']->getValue())) {
        $v = '';
    }
    echo '<td style="padding-right: 10px;"><b>' . __('Assigned To') . '</b><br>' . select_tag('user_reports[assigned_to]', explode(',', $v), array('choices' => $choices, 'multiple' => true), array('style' => 'height: 400px; width: 250px;')) . '</td>';
}
?>
              </tr>
            </table>
          </div>
          
          <div>
            
            <?php 
echo __('Tasks Due Date');
?>
Example #19
0

<table>
  <?php 
if (Users::hasAccess('insert', 'discussionsComments', $sf_user, $projects->getId())) {
    ?>
    <td style="padding-right: 15px;"><?php 
    echo link_to_modalbox(image_tag('icons/comment_small.png') . ' ' . __('Add Comment'), 'discussionsComments/new?projects_id=' . $projects->getId() . '&discussions_id=' . $discussions->getId() . '&redirect_to=discussionsComments');
    ?>
</td>
  <?php 
}
?>
  
  <?php 
if (Users::hasAccess('edit', 'discussions', $sf_user, $projects->getId())) {
    ?>
    <td style="padding-right: 15px;"><?php 
    echo link_to_modalbox(image_tag('icons/edit_small.png') . ' ' . __('Edit Details'), 'discussions/edit?projects_id=' . $projects->getId() . '&id=' . $discussions->getId() . '&redirect_to=discussionsComments');
    ?>
</td>
  <?php 
}
?>
  
  <?php 
if (count($more_actions) > 0) {
    ?>
    <td>
      <?php 
    echo renderYuiMenu('more_actions', $more_actions);
Example #20
0

<table>
  <?php 
if (Users::hasAccess('insert', 'ticketsComments', $sf_user, isset($projects) ? $projects->getId() : false)) {
    ?>
    <td style="padding-right: 15px;"><?php 
    echo link_to_modalbox(image_tag('icons/comment_small.png') . ' ' . __('Add Comment'), 'ticketsComments/new?tickets_id=' . $tickets->getId() . '&redirect_to=ticketsComments' . (isset($projects) ? '&projects_id=' . $projects->getId() : ''));
    ?>
</td>
  <?php 
}
?>
  
  <?php 
if (Users::hasAccess('edit', 'tickets', $sf_user, isset($projects) ? $projects->getId() : false)) {
    ?>
    <td style="padding-right: 15px;"><?php 
    echo link_to_modalbox(image_tag('icons/edit_small.png') . ' ' . __('Edit Details'), 'tickets/edit?id=' . $tickets->getId() . '&redirect_to=ticketsComments' . (isset($projects) ? '&projects_id=' . $projects->getId() : ''));
    ?>
</td>
  <?php 
}
?>
  
  <?php 
if (count($more_actions) > 0) {
    ?>
    <td>
      <?php 
    echo renderYuiMenu('more_actions', $more_actions);
Example #21
0
echo app::getReportFormFilterByTable('Type', 'projects_reports[projects_type_id]', 'ProjectsTypes', $form['projects_type_id']->getValue());
?>
                        
              </tr>  
            </table>
            
            
          </td>
          <?php 
if (count($choices = app::getProjectChoicesByUser($sf_user, true)) > 0) {
    if (!is_string($v = $form['projects_id']->getValue())) {
        $v = '';
    }
    echo '<td style="padding-right: 10px;"><b>' . __('Projects') . '</b><br>' . select_tag('projects_reports[projects_id]', explode(',', $v), array('choices' => $choices, 'multiple' => true), array('style' => 'height: 400px; width: 250px;')) . '</td>';
}
if (count($choices = app::getItemsChoicesByTable('Users', true)) > 0 and (Users::hasAccess('insert', 'projects', $sf_user) or Users::hasAccess('edit', 'projects', $sf_user))) {
    if (!is_string($v = $form['in_team']->getValue())) {
        $v = '';
    }
    echo '<td style="padding-right: 10px;"><b>' . __('In Team') . '</b><br>' . select_tag('projects_reports[in_team]', explode(',', $v), array('choices' => $choices), array('style' => 'width: 250px;')) . '</td>';
}
?>
      
        </tr>
        </table>
      
      </div>
    </div>        
  <br>              
  <input type="submit" value="<?php 
echo __('Save');
Example #22
0
</td>
    <td style="text-align: right;"><?php 
        if (!$is_email) {
            echo image_tag('icons/remove_link.png', array('title' => __('Delete Related'), 'style' => 'cursor:pointer', 'onClick' => 'removeRelated("related_task_' . $tasks['id'] . '","' . url_for('app/removeRelatedTicketWithTask?tasks_id=' . $tasks['id'] . '&tickets_id=' . $sf_request->getParameter('tickets_id')) . '")'));
        }
        ?>
</td>
  </tr>  
      
<?php 
    }
    ?>
</table>

<?php 
    if (Users::hasAccess('insert', 'tasks', $sf_user, $sf_request->getParameter('projects_id')) and !$is_email) {
        ?>
  <div style="margin-bottom: 10px; margin-top: 5px; text-align: right;"><?php 
        echo link_to_modalbox('+ ' . __('Add'), 'tasks/new?related_tickets_id=' . $sf_request->getParameter('tickets_id') . '&projects_id=' . $sf_request->getParameter('projects_id'));
        ?>
</div>
<?php 
    }
    ?>



<?php 
}
?>
 
Example #23
0
 public function buildMenu($sf_context)
 {
     $m = array();
     if ($this->access['projects']['view'] or $this->access['projects']['view_own']) {
         $m[] = array('title' => __('Project Info'), 'url' => 'projectsComments/index?projects_id=' . $this->projects_id, 'is_selected' => $sf_context->getModuleName() == 'projectsComments');
     }
     if ($this->access['tasks']['view'] or $this->access['tasks']['view_own']) {
         $s = array();
         if ($this->access['tasks']['insert']) {
             $s[] = array('title' => __('Add Task'), 'url' => 'tasks/new?projects_id=' . $this->projects_id, 'modalbox' => true);
         }
         $s[] = array('title' => __('View All'), 'url' => 'tasks/index?projects_id=' . $this->projects_id);
         $m[] = array('title' => __('Tasks'), 'url' => 'tasks/index?projects_id=' . $this->projects_id, 'submenu' => $s, 'is_selected' => in_array($sf_context->getModuleName(), array('tasks', 'tasksComments')));
     }
     if ($this->access['tickets']['view'] or $this->access['tickets']['view_own']) {
         $s = array();
         if ($this->access['tickets']['insert']) {
             $s[] = array('title' => __('Add Ticket'), 'url' => 'tickets/new?projects_id=' . $this->projects_id, 'modalbox' => true);
         }
         $s[] = array('title' => __('View All'), 'url' => 'tickets/index?projects_id=' . $this->projects_id);
         $m[] = array('title' => __('Tickets'), 'url' => 'tickets/index?projects_id=' . $this->projects_id, 'submenu' => $s, 'is_selected' => in_array($sf_context->getModuleName(), array('tickets', 'ticketsComments')));
     }
     if ($this->access['discussions']['view'] or $this->access['discussions']['view_own']) {
         $s = array();
         if ($this->access['discussions']['insert']) {
             $s[] = array('title' => __('Add Discussion'), 'url' => 'discussions/new?projects_id=' . $this->projects_id, 'modalbox' => true);
         }
         $s[] = array('title' => __('View All'), 'url' => 'discussions/index?projects_id=' . $this->projects_id);
         $m[] = array('title' => __('Discussions'), 'url' => 'discussions/index?projects_id=' . $this->projects_id, 'submenu' => $s, 'is_selected' => in_array($sf_context->getModuleName(), array('discussions', 'discussionsComments')));
     }
     if (Users::hasAccess('view', 'projectsWiki', $this->sf_user, $this->projects_id)) {
         $m[] = array('title' => __('Wiki'), 'url' => 'wiki/view?projects_id=' . $this->projects_id, 'is_selected' => $sf_context->getModuleName() == 'wiki');
     }
     if ($this->access['tasks']['insert'] and $this->access['tasks']['edit']) {
         if (sfConfig::get('app_use_tasks_groups') == 'on') {
             $s = array();
             $s[] = array('title' => __('Add Group'), 'url' => 'tasksGroups/new?projects_id=' . $this->projects_id, 'modalbox' => true);
             $s[] = array('title' => __('View All'), 'url' => 'tasksGroups/index?projects_id=' . $this->projects_id);
             $m[] = array('title' => __('Tasks Groups'), 'url' => 'tasksGroups/index?projects_id=' . $this->projects_id, 'submenu' => $s, 'is_selected' => $sf_context->getModuleName() == 'tasksGroups');
         }
         if (sfConfig::get('app_use_project_versions') == 'on') {
             $s = array();
             $s[] = array('title' => __('Add Versions'), 'url' => 'versions/new?projects_id=' . $this->projects_id, 'modalbox' => true);
             $s[] = array('title' => __('View All'), 'url' => 'versions/index?projects_id=' . $this->projects_id);
             $m[] = array('title' => __('Versions'), 'url' => 'versions/index?projects_id=' . $this->projects_id, 'submenu' => $s, 'is_selected' => $sf_context->getModuleName() == 'versions');
         }
         if (sfConfig::get('app_use_project_phases') == 'on') {
             $s = array();
             $s[] = array('title' => __('Add Phase'), 'url' => 'projectsPhases/new?projects_id=' . $this->projects_id, 'modalbox' => true);
             $s[] = array('title' => __('View All'), 'url' => 'projectsPhases/index?projects_id=' . $this->projects_id);
             if (Doctrine_Core::getTable('ProjectsPhases')->createQuery()->addWhere('projects_id=?', $this->projects_id)->count() == 0) {
                 if (Doctrine_Core::getTable('Phases')->createQuery()->count() > 0) {
                     $ss = array();
                     $phases_list = Doctrine_Core::getTable('Phases')->createQuery()->orderBy('name')->fetchArray();
                     foreach ($phases_list as $v) {
                         $ss[] = array('title' => $v['name'], 'url' => 'projectsPhases/setDefaultPhases?projects_id=' . $this->projects_id . '&phase_id=' . $v['id']);
                     }
                     $s[] = array('title' => __('Default Phases'), 'is_hr' => true, 'submenu' => $ss);
                 }
             }
             $m[] = array('title' => __('Phases'), 'url' => 'projectsPhases/index?projects_id=' . $this->projects_id, 'submenu' => $s, 'is_selected' => $sf_context->getModuleName() == 'projectsPhases');
         }
     }
     $s = array();
     if ($this->sf_user->hasCredential('reports_access_time')) {
         $s[] = array('title' => __('Time Report'), 'url' => 'timeReport/index?projects_id=' . $this->projects_id);
     }
     if ($this->sf_user->hasCredential('reports_access_gantt')) {
         $s[] = array('title' => __('Gantt Chart'), 'url' => 'ganttChart/index?projects_id=' . $this->projects_id);
     }
     if (count($s) > 0) {
         $m[] = array('title' => __('Reports'), 'url' => 'projectsPhases/index?projects_id=' . $this->projects_id, 'submenu' => $s);
     }
     return $m;
 }
Example #24
0
<?php

if (Users::hasAccess('view', 'tickets', $sf_user, $sf_request->getParameter('projects_id'))) {
    include_component('tickets', 'relatedTicketsToTasks', array('tasks_id' => $tasks->getId(), 'is_email' => isset($is_email)));
}
if (Users::hasAccess('view', 'discussions', $sf_user, $sf_request->getParameter('projects_id'))) {
    include_component('discussions', 'relatedDiscussionsToTasks', array('tasks_id' => $tasks->getId(), 'is_email' => isset($is_email)));
}
?>

<h2><?php 
echo __('Details');
?>
</h2>
<table class="contentTable">
  <tr>
    <th><?php 
echo __('Id');
?>
:</th>
    <td><?php 
echo $tasks->getId();
?>
</td>
  </tr>
  <?php 
if ($tasks->getTasksLabelId() > 0) {
    echo '<tr><th>' . __('Label') . ':</th><td>' . $tasks->getTasksLabels()->getName() . '</td></tr>';
}
?>
  <?php 
Example #25
0
?>

<table>  
  <?php 
if (Users::hasAccess('insert', 'tasksComments', $sf_user, $projects->getId())) {
    ?>
    <td style="padding-right: 15px;"><?php 
    echo link_to_modalbox(image_tag('icons/comment_small.png') . ' ' . __('Add Comment'), 'tasksComments/new?projects_id=' . $projects->getId() . '&tasks_id=' . $tasks->getId() . '&redirect_to=tasksComments');
    ?>
</td>
  <?php 
}
?>
  
  <?php 
if (Users::hasAccess('edit', 'tasks', $sf_user, $projects->getId())) {
    ?>
    <td style="padding-right: 15px;"><?php 
    echo link_to_modalbox(image_tag('icons/edit_small.png') . ' ' . __('Edit Details'), 'tasks/edit?projects_id=' . $projects->getId() . '&id=' . $tasks->getId() . '&redirect_to=tasksComments');
    ?>
</td>
  <?php 
}
?>
  
  <?php 
if (count($more_actions) > 0) {
    ?>
    <td>
      <?php 
    echo renderYuiMenu('more_actions', $more_actions);
Example #26
0
<?php

$lc = new listingController('projects', $url_params, $sf_request, $sf_user);
$extra_fields = ExtraFieldsList::getFieldsByType('projects', $sf_user);
$totals = array();
$is_filter = array();
$is_filter['status'] = app::countItemsByTable('ProjectsStatus');
$is_filter['type'] = app::countItemsByTable('ProjectsTypes');
$has_comments_access = Users::hasAccess('view', 'projectsComments', $sf_user);
?>
   

<table width="100%">
  <tr>
    <td>
      <table>
        <tr>
          <?php 
if ($display_insert_button) {
    ?>
          <td style="padding-right: 15px;"><?php 
    echo $lc->insert_button(__('Add Project'));
    ?>
</td>
          <?php 
}
?>
          <td style="padding-right: 15px;"><div id="tableListingMultipleActionsMenu"><?php 
echo $lc->rednerWithSelectedAction($tlId);
?>
</div></td>
Example #27
0
 public function executeExport(sfWebRequest $request)
 {
     /*check access*/
     if ($request->hasParameter('projects_id')) {
         $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id')));
         $this->checkProjectsAccess($this->projects);
         $this->checkTicketsAccess('view', false, $this->projects);
     } else {
         $this->checkTicketsAccess('view');
     }
     $this->columns = array('Projects' => t::__('Project Name'), 'id' => t::__('Id'), 'TicketsStatus' => t::__('Status'), 'TicketsTypes' => t::__('Type'), 'name' => t::__('Name'), 'description' => t::__('Description'), 'Departments' => t::__('Department'), 'Users' => t::__('Created By'), 'created_at' => t::__('Created At'));
     $extra_fields = ExtraFieldsList::getFieldsByType('tickets', $this->getUser(), false, array('all' => true));
     foreach ($extra_fields as $v) {
         $this->columns['extra_field_' . $v['id']] = $v['name'];
     }
     if (!$request->hasParameter('projects_id')) {
         $this->columns['Projects'] = t::__('Project');
     }
     $this->columns['Projects'] = t::__('Project Name');
     $this->columns['url'] = t::__('Url');
     if ($fields = $request->getParameter('fields')) {
         $separator = "\t";
         $format = $request->getParameter('format', '.csv');
         $filename = $request->getParameter('filename', 'tasks');
         header("Content-type: Application/octet-stream");
         header("Content-disposition: attachment; filename=" . $filename . "." . $format);
         header("Pragma: no-cache");
         header("Expires: 0");
         $content = '';
         foreach ($fields as $f) {
             $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $this->columns[$f]) . $separator;
         }
         $content .= "\n";
         if ($format == 'csv') {
             echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
         } else {
             echo $content;
         }
         if (strlen($request->getParameter('selected_items') == 0)) {
             exit;
         }
         $q = Doctrine_Core::getTable('Tickets')->createQuery('t')->leftJoin('t.TicketsStatus ts')->leftJoin('t.TicketsTypes tt')->leftJoin('t.Departments td')->leftJoin('t.Projects p')->leftJoin('t.Users')->whereIn('t.id', explode(',', $request->getParameter('selected_items')));
         if ($request->hasParameter('projects_id')) {
             $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
             if (Users::hasAccess('view_own', 'tickets', $this->getUser(), $request->getParameter('projects_id'))) {
                 $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'");
             }
         } else {
             if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
                 $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.users_id='" . $this->getUser()->getAttribute('id') . "'");
             }
             if (Users::hasAccess('view_own', 'tickets', $this->getUser())) {
                 $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'");
             }
         }
         if ($request->hasParameter('projects_id')) {
             $q = app::addListingOrder($q, 'tickets', $this->getUser(), (int) $request->getParameter('projects_id'));
         } else {
             $q->orderBy('LTRIM(p.name), ts.sort_order, LTRIM(ts.name), LTRIM(t.name)');
         }
         $tickets = $q->fetchArray();
         $totals = array();
         $projects_totals = array();
         $current_project_id = 0;
         foreach ($tickets as $t) {
             $ex_values = ExtraFieldsList::getValuesList($extra_fields, $t['id']);
             $content = '';
             //
             if ($current_project_id == 0) {
                 $current_project_id = $t['projects_id'];
             }
             if ($current_project_id != $t['projects_id']) {
                 //adding totals
                 if (isset($projects_totals[$current_project_id])) {
                     foreach ($fields as $f) {
                         $v = '';
                         if (strstr($f, 'extra_field_')) {
                             if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) {
                                 $v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)];
                             }
                         }
                         $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
                     }
                     $content .= "\n\n";
                 }
                 $current_project_id = $t['projects_id'];
             }
             foreach ($fields as $f) {
                 $v = '';
                 if (in_array($f, array('id', 'name', 'description'))) {
                     $v = $t[$f];
                 } elseif (strstr($f, 'extra_field_')) {
                     if ($ex = Doctrine_Core::getTable('ExtraFields')->find(str_replace('extra_field_', '', $f))) {
                         $v = ExtraFieldsList::renderFieldValueByType($ex, $ex_values, array(), true);
                         if (in_array($ex->getType(), array('number', 'formula'))) {
                             if (!isset($totals[$ex->getId()])) {
                                 $totals[$ex->getId()] = 0;
                             }
                             if (!isset($projects_totals[$t['projects_id']][$ex->getId()])) {
                                 $projects_totals[$t['projects_id']][$ex->getId()] = 0;
                             }
                             $totals[$ex->getId()] += $v;
                             $projects_totals[$t['projects_id']][$ex->getId()] += $v;
                         }
                         $v = str_replace('<br>', ', ', $v);
                     }
                 } elseif ($f == 'created_at') {
                     if (strlen($t[$f]) > 0) {
                         $v = app::dateTimeFormat($t[$f]);
                     }
                 } elseif ($f == 'url') {
                     $v = app::public_url('ticketsComments/index?projects_id=' . $t['projects_id'] . '&tickets_id=' . $t['id']);
                 } else {
                     $v = app::getArrayName($t, $f);
                 }
                 $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
             }
             $content .= "\n";
             if ($format == 'csv') {
                 echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
             } else {
                 echo $content;
             }
         }
         $content = '';
         //adding totals
         if (isset($projects_totals[$current_project_id]) and !$request->hasParameter('projects_id')) {
             foreach ($fields as $f) {
                 $v = '';
                 if (strstr($f, 'extra_field_')) {
                     if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) {
                         $v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)];
                     }
                 }
                 $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
             }
             $content .= "\n\n";
         }
         foreach ($fields as $f) {
             $v = '';
             if (strstr($f, 'extra_field_')) {
                 if (isset($totals[str_replace('extra_field_', '', $f)])) {
                     $v = $totals[str_replace('extra_field_', '', $f)];
                 }
             }
             $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
         }
         $content .= "\n";
         if ($format == 'csv') {
             echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
         } else {
             echo $content;
         }
         exit;
     }
 }
Example #28
0
 public function executeExport(sfWebRequest $request)
 {
     /*check access*/
     if ($request->hasParameter('projects_id')) {
         $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id')));
         $this->checkProjectsAccess($this->projects);
         $this->checkTasksAccess('view', false, $this->projects);
     } else {
         $this->checkTasksAccess('view');
     }
     $this->columns = array('Projects' => t::__('Project Name'), 'id' => t::__('Id'), 'TasksGroups' => t::__('Group'), 'Versions' => t::__('Version'), 'ProjectsPhases' => t::__('Phase'), 'TasksPriority' => t::__('Priority'), 'TasksLabels' => t::__('Label'), 'name' => t::__('Name'), 'TasksStatus' => t::__('Status'), 'TasksTypes' => t::__('Type'), 'assigned_to' => t::__('Assigned To'), 'Users' => t::__('Created By'), 'estimated_time' => t::__('Est. Time'), 'work_hours' => t::__('Work Hours'), 'start_date' => t::__('Start Date'), 'due_date' => t::__('Due Date'), 'progress' => t::__('Progress'), 'created_at' => t::__('Created At'));
     $extra_fields = ExtraFieldsList::getFieldsByType('tasks', $this->getUser(), false, array('all' => true));
     foreach ($extra_fields as $v) {
         $this->columns['extra_field_' . $v['id']] = $v['name'];
     }
     $this->columns['url'] = t::__('Url');
     if ($fields = $request->getParameter('fields')) {
         $separator = "\t";
         $format = $request->getParameter('format', '.csv');
         $filename = $request->getParameter('filename', 'tasks');
         header("Content-type: Application/octet-stream");
         header("Content-disposition: attachment; filename=" . $filename . "." . $format);
         header("Pragma: no-cache");
         header("Expires: 0");
         $content = '';
         foreach ($fields as $f) {
             $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $this->columns[$f]) . $separator;
         }
         $content .= "\n";
         if ($format == 'csv') {
             echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
         } else {
             echo $content;
         }
         if (strlen($request->getParameter('selected_items') == 0)) {
             exit;
         }
         $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users')->whereIn('t.id', explode(',', $request->getParameter('selected_items')));
         if ($request->hasParameter('projects_id')) {
             $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
             if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
                 $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
             }
         } else {
             if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
                 $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
             }
             if (Users::hasAccess('view_own', 'tasks', $this->getUser())) {
                 $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
             }
         }
         $tree_order = false;
         if ($request->hasParameter('projects_id')) {
             $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id'));
         } else {
             $q->orderBy('LTRIM(p.name), ts.group desc, ts.sort_order, LTRIM(ts.name), LTRIM(t.name)');
         }
         $tasks = $q->fetchArray();
         $totals = array();
         $projects_totals = array();
         $current_project_id = 0;
         foreach ($tasks as $t) {
             $content = '';
             //
             if ($current_project_id == 0) {
                 $current_project_id = $t['projects_id'];
             }
             if ($current_project_id != $t['projects_id']) {
                 //adding totals
                 if (isset($projects_totals[$current_project_id])) {
                     foreach ($fields as $f) {
                         $v = '';
                         if (in_array($f, array('estimated_time', 'work_hours'))) {
                             $v = $projects_totals[$current_project_id][$f];
                         } elseif (strstr($f, 'extra_field_')) {
                             if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) {
                                 $v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)];
                             }
                         }
                         $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
                     }
                     $content .= "\n\n";
                 }
                 $current_project_id = $t['projects_id'];
             }
             //
             $name_adding = '';
             $ex_values = ExtraFieldsList::getValuesList($extra_fields, $t['id']);
             foreach ($fields as $f) {
                 $v = '';
                 if ($f == 'name') {
                     $v = $name_adding . $t[$f];
                 } elseif (in_array($f, array('id', 'description', 'estimated_time', 'work_hours'))) {
                     if ($f == 'work_hours') {
                         $v = TasksComments::getTotalWorkHours($t['id']);
                     } else {
                         $v = $t[$f];
                     }
                     if (in_array($f, array('estimated_time', 'work_hours'))) {
                         if (!isset($totals[$f])) {
                             $totals[$f] = 0;
                         }
                         if (!isset($projects_totals[$t['projects_id']][$f])) {
                             $projects_totals[$t['projects_id']][$f] = 0;
                         }
                         $totals[$f] += $v;
                         $projects_totals[$t['projects_id']][$f] += $v;
                     }
                 } elseif (in_array($f, array('start_date', 'due_date', 'created_at'))) {
                     $v = app::dateTimeFormat($t[$f]);
                 } elseif ($f == 'progress') {
                     $v = (int) $t['progress'] . '%';
                 } elseif (strstr($f, 'extra_field_')) {
                     if ($ex = Doctrine_Core::getTable('ExtraFields')->find(str_replace('extra_field_', '', $f))) {
                         $v = ExtraFieldsList::renderFieldValueByType($ex, $ex_values, array(), true);
                         if (in_array($ex->getType(), array('number', 'formula'))) {
                             if (!isset($totals[$ex->getId()])) {
                                 $totals[$ex->getId()] = 0;
                             }
                             if (!isset($projects_totals[$t['projects_id']][$ex->getId()])) {
                                 $projects_totals[$t['projects_id']][$ex->getId()] = 0;
                             }
                             $totals[$ex->getId()] += $v;
                             $projects_totals[$t['projects_id']][$ex->getId()] += $v;
                         }
                         $v = str_replace('<br>', ', ', $v);
                     }
                 } elseif ($f == 'assigned_to') {
                     $v = Users::getNameById($t[$f], ', ');
                 } elseif ($f == 'url') {
                     $v = app::public_url('tasksComments/index?projects_id=' . $t['projects_id'] . '&tasks_id=' . $t['id']);
                 } elseif ($f == 'actual_time') {
                     if ($t['work_hours'] > 0 and $t['togo_hours'] == 0) {
                         $v = $t['work_hours'];
                     } else {
                         $v = (double) $t['estimated_time'] - (double) $t['work_hours'] + (double) $t['togo_hours'];
                     }
                     if (!isset($totals[$f])) {
                         $totals[$f] = 0;
                     }
                     $totals[$f] += $v;
                     $projects_totals[$t['projects_id']][$f] += $v;
                 } else {
                     $v = app::getArrayName($t, $f);
                 }
                 $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
             }
             $content .= "\n";
             if ($format == 'csv') {
                 echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
             } else {
                 echo $content;
             }
         }
         $content = '';
         //adding totals
         if (isset($projects_totals[$current_project_id]) and !$request->hasParameter('projects_id')) {
             foreach ($fields as $f) {
                 $v = '';
                 if (in_array($f, array('estimated_time', 'work_hours'))) {
                     $v = $projects_totals[$current_project_id][$f];
                 } elseif (strstr($f, 'extra_field_')) {
                     if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) {
                         $v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)];
                     }
                 }
                 $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
             }
             $content .= "\n\n";
         }
         foreach ($fields as $f) {
             $v = '';
             if (in_array($f, array('estimated_time', 'work_hours'))) {
                 $v = $totals[$f];
             } elseif (strstr($f, 'extra_field_')) {
                 if (isset($totals[str_replace('extra_field_', '', $f)])) {
                     $v = $totals[str_replace('extra_field_', '', $f)];
                 }
             }
             $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
         }
         $content .= "\n";
         if ($format == 'csv') {
             echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
         } else {
             echo $content;
         }
         exit;
     }
 }
Example #29
0
 protected function getTasks($request, $tasks_tree)
 {
     $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users');
     if ($request->hasParameter('projects_id')) {
         $q->addWhere('projects_id=?', $request->getParameter('projects_id'));
         if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     } else {
         if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
         if (Users::hasAccess('view_own', 'tasks', $this->getUser())) {
             $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'");
         }
     }
     $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('gantt_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
     $q->addWhere('t.due_date is not null and t.start_date is not null');
     $q->orderBy('p.name, t.start_date');
     return $q->fetchArray();
 }
Example #30
0
                <?php 
echo $form['description'];
?>
              </td>
            </tr>
            
            <?php 
echo ExtraFieldsList::renderFormFiledsByType('tasks', $form->getObject(), $sf_user, 'text');
?>
            <?php 
echo ExtraFieldsList::renderFormFiledsByType('tasks', $form->getObject(), $sf_user, 'file');
?>
            
            
            <?php 
if (Users::hasAccess('edit', 'projects', $sf_user, $sf_request->getParameter('projects_id'))) {
    ?>
            <tr>
              <th><?php 
    echo $form['created_by']->renderLabel();
    ?>
</th>
              <td>
                <?php 
    echo $form['created_by']->renderError();
    ?>
                <?php 
    echo $form['created_by'];
    ?>
              </td>
            </tr>