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