2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
4 /*********************************************************************************
5 * SugarCRM Community Edition is a customer relationship management program developed by
6 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Affero General Public License version 3 as published by the
10 * Free Software Foundation with the addition of the following permission added
11 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
20 * You should have received a copy of the GNU Affero General Public License along with
21 * this program; if not, see http://www.gnu.org/licenses or write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28 * The interactive user interfaces in modified source and object code versions
29 * of this program must display Appropriate Legal Notices, as required under
30 * Section 5 of the GNU Affero General Public License version 3.
32 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33 * these Appropriate Legal Notices must retain the display of the "Powered by
34 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35 * technical reasons, the Appropriate Legal Notices must display the words
36 * "Powered by SugarCRM".
37 ********************************************************************************/
39 /*********************************************************************************
41 * Description: This file is used to override the default Meta-data EditView behavior
42 * to provide customization specific to the Calls module.
43 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
44 * All Rights Reserved.
45 * Contributor(s): ______________________________________..
46 ********************************************************************************/
48 require_once('include/MVC/View/views/view.list.php');
50 class ProjectTaskViewList extends ViewList{
51 function ProjectTaskViewList(){
57 if(!$this->bean->ACLAccess('list')){
58 ACLController::displayNoAccess();
61 $module = $GLOBALS['module'];
63 $foundViewDefs = false;
64 if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
65 $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
66 $foundViewDefs = true;
68 if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
69 require_once('custom/modules/'.$module.'/metadata/metafiles.php');
70 if(!empty($metafiles[$module]['listviewdefs'])){
71 $metadataFile = $metafiles[$module]['listviewdefs'];
72 $foundViewDefs = true;
74 }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
75 require_once('modules/'.$module.'/metadata/metafiles.php');
76 if(!empty($metafiles[$module]['listviewdefs'])){
77 $metadataFile = $metafiles[$module]['listviewdefs'];
78 $foundViewDefs = true;
82 if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
83 $metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
85 require_once($metadataFile);
88 if(!empty($this->bean->object_name) && isset($_REQUEST[$module.'2_'.strtoupper($this->bean->object_name).'_offset'])) {//if you click the pagination button, it will poplate the search criteria here
89 if(!empty($_REQUEST['current_query_by_page'])) {//The code support multi browser tabs pagination
90 $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'request_data', 'current_query_by_page', $module.'2_'.strtoupper($this->bean->object_name).'_ORDER_BY');
91 if(isset($_REQUEST['lvso'])){
92 $blockVariables[] = 'lvso';
95 $current_query_by_page = unserialize(base64_decode($_REQUEST['current_query_by_page']));
96 foreach($current_query_by_page as $search_key=>$search_value) {
97 if($search_key != $module.'2_'.strtoupper($this->bean->object_name).'_offset' && !in_array($search_key, $blockVariables)) {
98 $_REQUEST[$search_key] = $GLOBALS['db']->quote($search_value);
104 if(!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
105 if(empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query']!='true')) {
106 $this->saved_search = loadBean('SavedSearch');
107 $this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
108 $this->saved_search->populateRequest();
110 elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
111 $_SESSION['LastSavedView'][$_REQUEST['module']] = '';
112 unset($_REQUEST['saved_search_select']);
113 unset($_REQUEST['saved_search_select_name']);
117 $lv = new ListViewSmarty();
118 $displayColumns = array();
119 if(!empty($_REQUEST['displayColumns'])) {
120 foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
121 if(!empty($listViewDefs[$module][$col]))
122 $displayColumns[$col] = $listViewDefs[$module][$col];
126 foreach($listViewDefs[$module] as $col => $params) {
127 if(!empty($params['default']) && $params['default'])
128 $displayColumns[$col] = $params;
132 global $current_user;
134 if (!is_admin($current_user)){
135 $params = array( 'massupdate' => false );
137 $lv->multiSelect = false;
140 $params = array( 'massupdate' => true, 'export' => true);
143 if(!empty($_REQUEST['orderBy'])) {
144 $params['orderBy'] = $_REQUEST['orderBy'];
145 $params['overrideOrder'] = true;
146 if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
148 $lv->displayColumns = $displayColumns;
151 $this->module = $module;
154 $storeQuery = new StoreQuery();
155 if(!isset($_REQUEST['query'])){
156 $storeQuery->loadQuery($this->module);
157 $storeQuery->populateRequest();
159 $storeQuery->saveFromRequest($this->module);
163 $view = 'basic_search';
164 if(!empty($_REQUEST['search_form_view']))
165 $view = $_REQUEST['search_form_view'];
167 if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
169 elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
170 if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
171 $view = 'advanced_search';
173 $view = 'basic_search';
177 $use_old_search = true;
178 if(file_exists('modules/'.$this->module.'/SearchForm.html')){
179 require_once('include/SearchForm/SearchForm.php');
180 $searchForm = new SearchForm($this->module, $this->seed);
182 $use_old_search = false;
183 require_once('include/SearchForm/SearchForm2.php');
186 if (file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php'))
188 require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php');
190 elseif (!empty($metafiles[$this->module]['searchdefs']))
192 require_once($metafiles[$this->module]['searchdefs']);
194 elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
196 require_once('modules/'.$this->module.'/metadata/searchdefs.php');
200 if(!empty($metafiles[$this->module]['searchfields']))
201 require_once($metafiles[$this->module]['searchfields']);
202 elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
203 require_once('modules/'.$this->module.'/metadata/SearchFields.php');
206 $searchForm = new SearchForm($this->seed, $this->module, $this->action);
207 $searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl', $view, $listViewDefs);
208 $searchForm->lv = $lv;
211 if(isset($this->options['show_title']) && $this->options['show_title']) {
212 $moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
213 echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE);
217 if(isset($_REQUEST['query']))
220 if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
221 $searchForm->populateFromArray($storeQuery->query);
224 $searchForm->populateFromRequest();
226 $where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
227 if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
228 $GLOBALS['log']->info("List View Where Clause: $where");
233 $searchForm->setup();
234 $searchForm->displayBasic($headers);
236 case 'advanced_search':
237 $searchForm->setup();
238 $searchForm->displayAdvanced($headers);
241 echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
245 echo $searchForm->display($headers);
250 if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
251 if (!is_admin($current_user)){
252 $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
255 $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
257 $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);