Esempio n. 1
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);
 }
Esempio n. 2
0
 public static function getFilterProjects($m, $path, $params = false, $selected = array(), $sf_user)
 {
     if (!is_array($selected)) {
         $selected = explode(',', $selected);
     }
     if (count($selected) > 0) {
         $ft = 'Preview';
     } else {
         $ft = '';
     }
     $q = Doctrine_Core::getTable('Projects')->createQuery('p')->leftJoin('p.ProjectsStatus ps')->leftJoin('p.ProjectsTypes pt')->leftJoin('p.Users');
     if (Users::hasAccess('view_own', 'projects', $sf_user)) {
         $q->addWhere("find_in_set('" . $sf_user->getAttribute('id') . "',p.team) or p.created_by='" . $sf_user->getAttribute('id') . "'");
     }
     $projects_filter = array();
     $tasks_filter = $sf_user->getAttribute('tasks_filter');
     if (isset($tasks_filter['ProjectsStatus'])) {
         $projects_filter['ProjectsStatus'] = $tasks_filter['ProjectsStatus'];
     }
     if (isset($tasks_filter['ProjectsTypes'])) {
         $projects_filter['ProjectsTypes'] = $tasks_filter['ProjectsTypes'];
     }
     $q = Projects::addFiltersToQuery($q, $projects_filter);
     $projects_list = $q->orderBy('p.name')->fetchArray();
     $s = array();
     $t = 'Projects';
     foreach ($projects_list as $v) {
         $k = $v['id'];
         $s[] = array('title' => '<table><tr><td style="padding-right: 10px;"><input class="' . $t . 'Filters' . $ft . '" name="' . $t . $k . '" id="' . $t . $k . '" value="' . $k . '" ' . (in_array($k, $selected) ? 'checked="checked"' : '') . ' type="checkbox"></td><td>' . link_to(app::truncate_text($v['name']), $path, array('query_string' => 'filter_by[' . $t . ']=' . $k . ($params ? '&' . $params : ''))) . '</td></table>');
     }
     $s[] = array('title' => '<form id="filter_by_' . $t . '_form" action="' . url_for($path . ($params ? '?' . $params : '')) . '" method="post">' . input_hidden_tag('filter_by[' . $t . ']', '') . '<table onClick="filter_by_selected(\'' . $t . '\',\'' . $ft . '\')"><tr><td style="padding-right: 10px;">' . image_tag('icons/arrow_up.png') . '</td><td>' . __('Filter by selected') . '</td></table></form>', 'is_hr' => true);
     $m[] = array('title' => __('Projects'), 'submenu' => $s, 'is_hr' => true);
     return $m;
 }