]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ProjectTask/views/view.list.php
Release 6.5.8
[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-2012 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 populate 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                         if (!is_array($search_value)) {
99                             $_REQUEST[$search_key] = $GLOBALS['db']->quote($search_value);
100                         }
101                         else {
102                             foreach ($search_value as $key=>&$val) {
103                                 $val = $GLOBALS['db']->quote($val);
104                             }
105                             $_REQUEST[$search_key] = $search_value;
106                         }
107                     }
108                 }
109             }
110         }
111
112         if(!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select']!='_none') {
113             if(empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query']!='true')) {
114                 $this->saved_search = loadBean('SavedSearch');
115                 $this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
116                 $this->saved_search->populateRequest();
117             }
118             elseif(!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search
119                 $_SESSION['LastSavedView'][$_REQUEST['module']] = '';
120                 unset($_REQUEST['saved_search_select']);
121                 unset($_REQUEST['saved_search_select_name']);
122             }
123         }
124
125                 $lv = new ListViewSmarty();
126                 $displayColumns = array();
127                 if(!empty($_REQUEST['displayColumns'])) {
128                     foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
129                         if(!empty($listViewDefs[$module][$col]))
130                             $displayColumns[$col] = $listViewDefs[$module][$col];
131                     }
132                 }
133                 else {
134                     foreach($listViewDefs[$module] as $col => $params) {
135                         if(!empty($params['default']) && $params['default'])
136                             $displayColumns[$col] = $params;
137                     }
138                 }
139
140                 global $current_user;
141
142                 if (!is_admin($current_user)){
143                         $params = array( 'massupdate' => false );
144                         $lv->export = false;
145             $lv->multiSelect = false;
146                 }
147                 else{
148                         $params = array( 'massupdate' => true, 'export' => true);
149                 }
150
151                 if(!empty($_REQUEST['orderBy'])) {
152                     $params['orderBy'] = $_REQUEST['orderBy'];
153                     $params['overrideOrder'] = true;
154                     if(!empty($_REQUEST['sortOrder'])) $params['sortOrder'] = $_REQUEST['sortOrder'];
155                 }
156                 $lv->displayColumns = $displayColumns;
157
158                 $this->seed = $seed;
159                 $this->module = $module;
160
161                 $searchForm = null;
162                 $storeQuery = new StoreQuery();
163                 if(!isset($_REQUEST['query'])){
164                         $storeQuery->loadQuery($this->module);
165                         $storeQuery->populateRequest();
166                 }else{
167                         $storeQuery->saveFromRequest($this->module);
168                 }
169
170                 //search
171                 $view = 'basic_search';
172                 if(!empty($_REQUEST['search_form_view']))
173                         $view = $_REQUEST['search_form_view'];
174                 $headers = true;
175                 if(!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only'])
176                         $headers = false;
177                 elseif(!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
178                 if(isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
179                                 $view = 'advanced_search';
180                         }else {
181                                 $view = 'basic_search';
182                         }
183                 }
184
185                 $use_old_search = true;
186                 if(file_exists('modules/'.$this->module.'/SearchForm.html')){
187                         require_once('include/SearchForm/SearchForm.php');
188                         $searchForm = new SearchForm($this->module, $this->seed);
189                 }else{
190                         $use_old_search = false;
191                         require_once('include/SearchForm/SearchForm2.php');
192
193
194                         if (file_exists('custom/modules/'.$this->module.'/metadata/searchdefs.php'))
195                         {
196                             require_once('custom/modules/'.$this->module.'/metadata/searchdefs.php');
197                         }
198                         elseif (!empty($metafiles[$this->module]['searchdefs']))
199                         {
200                                 require_once($metafiles[$this->module]['searchdefs']);
201                         }
202                         elseif (file_exists('modules/'.$this->module.'/metadata/searchdefs.php'))
203                         {
204                             require_once('modules/'.$this->module.'/metadata/searchdefs.php');
205                         }
206
207
208                         if(!empty($metafiles[$this->module]['searchfields']))
209                                 require_once($metafiles[$this->module]['searchfields']);
210                         elseif(file_exists('modules/'.$this->module.'/metadata/SearchFields.php'))
211                                 require_once('modules/'.$this->module.'/metadata/SearchFields.php');
212
213
214                         $searchForm = new SearchForm($this->seed, $this->module, $this->action);
215                         $searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl', $view, $listViewDefs);
216                         $searchForm->lv = $lv;
217                 }
218
219                 if(isset($this->options['show_title']) && $this->options['show_title']) {
220                         $moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
221                         echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE);
222                 }
223
224                 $where = '';
225                 if(isset($_REQUEST['query']))
226                 {
227                         // we have a query
228                 if(!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) { // from EditView cancel
229                         $searchForm->populateFromArray($storeQuery->query);
230                 }
231                 else {
232                 $searchForm->populateFromRequest();
233                 }
234                         $where_clauses = $searchForm->generateSearchWhere(true, $this->seed->module_dir);
235                         if (count($where_clauses) > 0 )$where = '('. implode(' ) AND ( ', $where_clauses) . ')';
236                         $GLOBALS['log']->info("List View Where Clause: $where");
237                 }
238                 if($use_old_search){
239                         switch($view) {
240                                 case 'basic_search':
241                                 $searchForm->setup();
242                                 $searchForm->displayBasic($headers);
243                                 break;
244                              case 'advanced_search':
245                                 $searchForm->setup();
246                                 $searchForm->displayAdvanced($headers);
247                                 break;
248                              case 'saved_views':
249                                 echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
250                                break;
251                         }
252                 }else{
253                         echo $searchForm->display($headers);
254                 }
255                 if(!$headers)
256                         return;
257
258                 if(empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false){
259                         if (!is_admin($current_user)){
260                                 $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
261                         }
262                         else {
263                                 $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
264                         }
265                         $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' . $_REQUEST['saved_search_select_name']);
266                         echo $lv->display();
267                 }
268         }
269 }
270
271 ?>