]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ProjectTask/views/view.list.php
Release 6.4.0
[Github/sugarcrm.git] / modules / ProjectTask / views / view.list.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
4 /*********************************************************************************
5  * SugarCRM Community Edition is a customer relationship management program developed by
6  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7  * 
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.
14  * 
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
18  * details.
19  * 
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
23  * 02110-1301 USA.
24  * 
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.
27  * 
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.
31  * 
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  ********************************************************************************/
38
39 /*********************************************************************************
40
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  ********************************************************************************/
47
48 require_once('include/MVC/View/views/view.list.php');
49
50 class ProjectTaskViewList extends ViewList{
51         function ProjectTaskViewList(){
52                 parent::ViewList();
53                 
54         }
55
56         function display(){
57                 if(!$this->bean->ACLAccess('list')){
58                         ACLController::displayNoAccess();
59                         return;
60                 }
61         $module = $GLOBALS['module'];
62             $metadataFile = null;
63         $foundViewDefs = false;
64         if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
65             $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
66             $foundViewDefs = true;
67         }else{
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;
73                 }
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;
79                 }
80             }
81         }
82         if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
83                 $metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
84         }
85         require_once($metadataFile);
86
87                 $seed = $this->bean;
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';
93                         }
94                         
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);
99                                         }
100                 }
101             }
102         }
103         
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();
109             }
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']);
114             }
115         }
116         
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];
123                     }    
124                 }
125                 else {
126                     foreach($listViewDefs[$module] as $col => $params) {
127                         if(!empty($params['default']) && $params['default'])
128                             $displayColumns[$col] = $params;
129                     }
130                 }
131                 
132                 global $current_user;
133                 
134                 if (!is_admin($current_user)){
135                         $params = array( 'massupdate' => false );
136                         $lv->export = false;
137                 }
138                 else{
139                         $params = array( 'massupdate' => true, 'export' => true);
140                 }
141                  
142                 if(!empty($_REQUEST['orderBy'])) {
143                     $params['orderBy'] = $_REQUEST['orderBy'];
144                     $params['overrideOrder'] = true;
145                     if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
146                 }
147                 $lv->displayColumns = $displayColumns;
148
149                 $this->seed = $seed;
150                 $this->module = $module;
151                 
152                 $searchForm = null;
153                 $storeQuery = new StoreQuery();
154                 if(!isset($_REQUEST['query'])){
155                         $storeQuery->loadQuery($this->module);
156                         $storeQuery->populateRequest();
157                 }else{
158                         $storeQuery->saveFromRequest($this->module);    
159                 }
160         
161                 //search
162                 $view = 'basic_search';
163                 if(!empty($_REQUEST['search_form_view']))
164                         $view = $_REQUEST['search_form_view'];
165                 $headers = true;
166                 if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
167                         $headers = false;
168                 elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
169                 if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
170                                 $view = 'advanced_search';
171                         }else {
172                                 $view = 'basic_search';
173                         }
174                 }
175                 
176                 $use_old_search = true;
177                 if(file_exists('modules/'.$this->module.'/SearchForm.html')){
178                         require_once('include/SearchForm/SearchForm.php');
179                         $searchForm = new SearchForm($this->module, $this->seed);
180                 }else{
181                         $use_old_search = false;
182                         require_once('include/SearchForm/SearchForm2.php');
183                         
184                                         
185                         if (file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php'))
186                         {
187                             require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php');
188                         }
189                         elseif (!empty($metafiles[$this->module]['searchdefs']))
190                         {
191                                 require_once($metafiles[$this->module]['searchdefs']);
192                         }
193                         elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
194                         {
195                             require_once('modules/'.$this->module.'/metadata/searchdefs.php');
196                         }
197                                 
198                                 
199                         if(!empty($metafiles[$this->module]['searchfields']))
200                                 require_once($metafiles[$this->module]['searchfields']);
201                         elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
202                                 require_once('modules/'.$this->module.'/metadata/SearchFields.php');
203                                 
204                 
205                         $searchForm = new SearchForm($this->seed, $this->module, $this->action);
206                         $searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', $view, $listViewDefs);
207                         $searchForm->lv = $lv;
208                 }
209                 
210                 if(isset($this->options['show_title']) && $this->options['show_title']) {
211                         $moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
212                         echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE); 
213                 }
214
215                 $where = '';
216                 if(isset($_REQUEST['query']))
217                 {
218                         // we have a query
219                 if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
220                         $searchForm->populateFromArray($storeQuery->query);
221                 }
222                 else {
223                 $searchForm->populateFromRequest();
224                 }       
225                         $where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
226                         if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
227                         $GLOBALS['log']->info("List View Where Clause: $where");   
228                 }
229                 if($use_old_search){
230                         switch($view) {
231                                 case 'basic_search':
232                                 $searchForm->setup();
233                                 $searchForm->displayBasic($headers);
234                                 break;
235                              case 'advanced_search':
236                                 $searchForm->setup();
237                                 $searchForm->displayAdvanced($headers);
238                                 break;
239                              case 'saved_views':
240                                 echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
241                                break;
242                         }
243                 }else{
244                         echo $searchForm->display($headers);
245                 }
246                 if(!$headers)
247                         return;
248             
249                 if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
250                         if (!is_admin($current_user)){
251                                 $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
252                         }
253                         else {
254                                 $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
255                         }
256                         $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
257                         echo $lv->display();
258                 }
259         }
260 }
261
262 ?>