]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/ListView/ListView.php
Release 6.5.12
[Github/sugarcrm.git] / include / ListView / ListView.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 require_once('include/EditView/SugarVCR.php');
39 /**
40  * ListView - list of many objects
41  * @api
42  */
43 class ListView
44 {
45     var $local_theme= null;
46     var $local_app_strings= null;
47     var $local_image_path = null;
48     var $local_current_module = null;
49     var $local_mod_strings = null;
50     var $records_per_page = 20;
51     var $xTemplate = null;
52     var $xTemplatePath = null;
53     var $seed_data = null;
54     var $query_where = null;
55     var $query_limit = -1;
56     var $query_orderby = null;
57     var $header_title = '';
58     var $header_text = '';
59     var $initialized = false;
60     var $show_export_button = true;
61     var $show_delete_button = true;
62     var $show_select_menu = true;
63     var $show_paging = true;
64     var $show_mass_update = true;
65     var $show_mass_update_form = true;
66     var $query_where_has_changed = false;
67     var $display_header_and_footer = true;
68     var $baseURL = '';
69     var $is_dynamic = false;
70     var $inline = false;
71     var $start_link_wrapper = '';
72     var $end_link_wrapper = '';
73     var $list_field_defs = array();
74
75     var $shouldProcess = false;
76     var $data_array;
77     var $related_field_name = '';
78     var $child_focus = '';
79     var $layout_manager = null;
80     var $process_for_popups = false;
81     var $multi_select_popup=false;
82     var $_additionalDetails = false;
83     var $additionalDetailsFunction = null;
84     var $sort_order = '';
85     var $force_mass_update=false;
86     var $keep_mass_update_form_open=false;
87     var $ignorePopulateOnly = false;
88
89 function setDataArray($value) {
90     $this->data_array = $value;
91 }
92
93 function processListViewMulti($seed, $xTemplateSection, $html_varName) {
94
95     $this->shouldProcess = true;
96
97     echo "<form name='MassUpdate' method='post' action='index.php'>";
98     $this->processListViewTwo($seed, $xTemplateSection, $html_varName);
99
100     echo "<a href='javascript:" . ((!$this->multi_select_popup) ? 'sListView.' : ''). "check_all(document.MassUpdate, \"mass[]\", true)'>".translate('LBL_CHECKALL')."</a> - <a href='javascript:sListView.check_all(document.MassUpdate, \"mass[]\", false);'>".translate('LBL_CLEARALL')."</a>";
101     echo '<br><br>';
102 }
103
104
105 function processListView($seed, $xTemplateSection, $html_varName)
106 {
107     global $sugar_config;
108
109     $populateOnly = $this->ignorePopulateOnly ? FALSE : (!empty($sugar_config['save_query']) && $sugar_config['save_query'] == 'populate_only');
110     if(isset($seed->module_dir) && $populateOnly) {
111         if(empty($GLOBALS['displayListView']) && strcmp(strtolower($_REQUEST['action']), 'popup') != 0 && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $seed->module_dir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI')&& (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $seed->module_dir)))) {
112             $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
113             return;
114         }
115     }
116     if(strcmp(strtolower($_REQUEST['action']), 'popup') != 0){
117         $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
118     }
119     //following session variable will track the detail view navigation history.
120     //needs to the reset after each search.
121     $this->setLocalSessionVariable($html_varName,"DETAIL_NAV_HISTORY",false);
122
123     require_once('include/MassUpdate.php');
124     $mass = new MassUpdate();
125     $add_acl_javascript = false;
126     if(!isset($_REQUEST['action'])) {
127         $this->shouldProcess=false;
128     } else {
129     $this->shouldProcess = is_subclass_of($seed, "SugarBean")
130         && (($_REQUEST['action'] == 'index') || ('ListView' == substr($_REQUEST['action'],0,8)) /* cn: to include all ListViewXXX.php type views */)
131         && ($_REQUEST['module'] == $seed->module_dir);
132     }
133
134     //when processing a multi-select popup.
135     if($this->process_for_popups && $this->multi_select_popup)  $this->shouldProcess =true;
136     //mass update turned off?
137     if(!$this->show_mass_update) $this->shouldProcess = false;
138     if(is_subclass_of($seed, "SugarBean")) {
139         if($seed->bean_implements('ACL')) {
140             if(!ACLController::checkAccess($seed->module_dir,'list',true)) {
141                 if($_REQUEST['module'] != 'Home') {
142                     ACLController::displayNoAccess();
143                 }
144                 return;
145             }
146             if(!ACLController::checkAccess($seed->module_dir,'export',true)) {
147                 $sugar_config['disable_export']= true;
148             }
149
150         }
151     }
152
153     //force mass update form if requested.
154     if($this->force_mass_update) {
155         $this->shouldProcess = true;
156     }
157
158     if($this->shouldProcess) {
159         echo $mass->getDisplayMassUpdateForm(true, $this->multi_select_popup);
160         echo $mass->getMassUpdateFormHeader($this->multi_select_popup);
161         $mass->setSugarBean($seed);
162
163         //C.L. Fix for 10048, do not process handleMassUpdate for multi select popups
164         if(!$this->multi_select_popup) {
165             $mass->handleMassUpdate();
166         }
167     }
168
169     $this->processListViewTwo($seed,$xTemplateSection, $html_varName);
170
171     if($this->shouldProcess && empty($this->process_for_popups)) {
172         //echo "<a href='javascript:sListView.clear_all(document.MassUpdate, \"mass[]\");'>".translate('LBL_CLEARALL')."</a>";
173         // cn: preserves current functionality, exception is InboundEmail
174         if($this->show_mass_update_form) {
175             echo $mass->getMassUpdateForm();
176         }
177         if(!$this->keep_mass_update_form_open) {
178             echo $mass->endMassUpdateForm();
179         }
180     }
181 }
182
183
184 function process_dynamic_listview($source_module, $sugarbean,$subpanel_def)
185 {
186         $this->source_module = $source_module;
187         $this->subpanel_module = $subpanel_def->name;
188         if(!isset($this->xTemplate))
189             $this->createXTemplate();
190
191         $html_var = $this->subpanel_module . "_CELL";
192
193         $list_data = $this->processUnionBeans($sugarbean,$subpanel_def, $html_var);
194
195         $list = $list_data['list'];
196         $parent_data = $list_data['parent_data'];
197
198         if($subpanel_def->isCollection()) {
199             $thepanel=$subpanel_def->get_header_panel_def();
200         } else {
201             $thepanel=$subpanel_def;
202         }
203
204
205
206         $this->process_dynamic_listview_header($thepanel->get_module_name(), $thepanel, $html_var);
207         $this->process_dynamic_listview_rows($list,$parent_data, 'dyn_list_view', $html_var,$subpanel_def);
208
209         if($this->display_header_and_footer)
210         {
211             $this->getAdditionalHeader();
212             if(!empty($this->header_title))
213             {
214                 echo get_form_header($this->header_title, $this->header_text, false);
215             }
216         }
217
218         $this->xTemplate->out('dyn_list_view');
219
220         if(isset($_SESSION['validation']))
221         {
222             print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg==');
223         }
224         if(isset($list_data['query'])) {
225             return ($list_data['query']);
226         }
227     }
228
229 /**
230  * @return void
231  * @param unknown $data
232  * @param unknown $xTemplateSection
233  * @param unknown $html_varName
234  * @desc INTERNAL FUNCTION handles the rows
235  */
236  function process_dynamic_listview_rows($data,$parent_data, $xtemplateSection, $html_varName, $subpanel_def)
237  {
238     global $subpanel_item_count;
239     global $odd_bg;
240     global $even_bg;
241     global $hilite_bg;
242     global $click_bg;
243
244     $this->xTemplate->assign("BG_HILITE", $hilite_bg);
245     $this->xTemplate->assign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", ''));
246     //$this->xTemplate->assign("BG_CLICK", $click_bg);
247     $subpanel_item_count = 0;
248     $oddRow = true;
249     $count = 0;
250     reset($data);
251
252     //GETTING OFFSET
253     $offset = $this->getOffset($html_varName);
254     //$totaltime = 0;
255     $processed_ids = array();
256
257     $fill_additional_fields = array();
258     //Either retrieve the is_fill_in_additional_fields property from the lone
259     //subpanel or visit each subpanel's subpanels to retrieve the is_fill_in_addition_fields
260     //property
261     $subpanel_list=array();
262     if($subpanel_def->isCollection()) {
263         $subpanel_list=$subpanel_def->sub_subpanels;
264     } else {
265         $subpanel_list[]= $subpanel_def;
266     }
267
268     foreach($subpanel_list as $this_subpanel)
269     {
270         if($this_subpanel->is_fill_in_additional_fields())
271         {
272             $fill_additional_fields[] = $this_subpanel->bean_name;
273             $fill_additional_fields[$this_subpanel->bean_name] = true;
274         }
275     }
276
277     if ( empty($data) ) {
278         $this->xTemplate->assign("ROW_COLOR", 'oddListRow');
279         $thepanel=$subpanel_def;
280         if($subpanel_def->isCollection())
281             $thepanel=$subpanel_def->get_header_panel_def();
282         $this->xTemplate->assign("COL_COUNT", count($thepanel->get_list_fields()));
283         $this->xTemplate->parse($xtemplateSection.".nodata");
284     }
285     while(list($aVal, $aItem) = each($data))
286     {
287         $subpanel_item_count++;
288         $aItem->check_date_relationships_load();
289         // TODO: expensive and needs to be removed and done better elsewhere
290
291         if(!empty($fill_additional_fields[$aItem->object_name])
292         || ($aItem->object_name == 'Case' && !empty($fill_additional_fields['aCase']))
293         )
294         {
295             $aItem->fill_in_additional_list_fields();
296             //$aItem->fill_in_additional_detail_fields();
297         }
298         //rrs bug: 25343
299         $aItem->call_custom_logic("process_record");
300
301         if(isset($parent_data[$aItem->id])) {
302
303             $aItem->parent_name = $parent_data[$aItem->id]['parent_name'];
304             if(!empty($parent_data[$aItem->id]['parent_name_owner'])) {
305             $aItem->parent_name_owner =  $parent_data[$aItem->id]['parent_name_owner'];
306             $aItem->parent_name_mod =  $parent_data[$aItem->id]['parent_name_mod'];
307         }}
308         $fields = $aItem->get_list_view_data();
309         if(isset($processed_ids[$aItem->id])) {
310             continue;
311
312         } else {
313             $processed_ids[$aItem->id] = 1;
314         }
315
316
317         //ADD OFFSET TO ARRAY
318         $fields['OFFSET'] = ($offset + $count + 1);
319
320         if($this->shouldProcess) {
321             if($aItem->ACLAccess('EditView')) {
322             $this->xTemplate->assign('PREROW', "<input type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "' />");
323             } else {
324                 $this->xTemplate->assign('PREROW', '');
325
326             }
327             if($aItem->ACLAccess('DetailView')) {
328                 $this->xTemplate->assign('TAG_NAME','a');
329             } else {
330                 $this->xTemplate->assign('TAG_NAME','span');
331             }
332             $this->xTemplate->assign('CHECKALL', "<input type='checkbox'  title='".$GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE']."' class='checkbox' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' />");
333         }
334
335         if($oddRow)
336         {
337             $ROW_COLOR = 'oddListRow';
338             $BG_COLOR =  $odd_bg;
339         }
340         else
341         {
342             $ROW_COLOR = 'evenListRow';
343             $BG_COLOR =  $even_bg;
344         }
345         $oddRow = !$oddRow;
346                 $button_contents = array();
347         $this->xTemplate->assign("ROW_COLOR", $ROW_COLOR);
348         $this->xTemplate->assign("BG_COLOR", $BG_COLOR);
349         $layout_manager = $this->getLayoutManager();
350         $layout_manager->setAttribute('context','List');
351         $layout_manager->setAttribute('image_path',$this->local_image_path);
352         $layout_manager->setAttribute('module_name', $subpanel_def->_instance_properties['module']);
353         if(!empty($this->child_focus))
354             $layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir);
355
356         //AG$subpanel_data = $this->list_field_defs;
357         //$bla = array_pop($subpanel_data);
358         //select which sub-panel to display here, the decision will be made based on the type of
359         //the sub-panel and panel in the bean being processed.
360         if($subpanel_def->isCollection()) {
361             $thepanel=$subpanel_def->sub_subpanels[$aItem->panel_name];
362         } else {
363             $thepanel=$subpanel_def;
364         }
365         //get data source name
366         $linked_field=$thepanel->get_data_source_name();
367         $linked_field_set=$thepanel->get_data_source_name(true);
368         static $count;
369         if(!isset($count))$count = 0;
370
371         $field_acl['DetailView'] = $aItem->ACLAccess('DetailView');
372         $field_acl['ListView'] = $aItem->ACLAccess('ListView');
373         $field_acl['EditView'] = $aItem->ACLAccess('EditView');
374         $field_acl['Delete'] = $aItem->ACLAccess('Delete');
375         foreach($thepanel->get_list_fields() as $field_name=>$list_field)
376         {
377             //add linked field attribute to the array.
378             $list_field['linked_field']=$linked_field;
379             $list_field['linked_field_set']=$linked_field_set;
380
381             $usage = empty($list_field['usage']) ? '' : $list_field['usage'];
382             if($usage == 'query_only' && !empty($list_field['force_query_only_display'])){
383                 //if you are here you have column that is query only but needs to be displayed as blank.  This is helpful
384                 //for collections such as Activities where you have a field in only one object and wish to show it in the subpanel list
385                 $count++;
386                 $widget_contents = '&nbsp;';
387                 $this->xTemplate->assign('CLASS', "");
388                 $this->xTemplate->assign('CELL_COUNT', $count);
389                 $this->xTemplate->assign('CELL', $widget_contents);
390                 $this->xTemplate->parse($xtemplateSection.".row.cell");
391
392             }else if($usage != 'query_only')
393             {
394                 $list_field['name']=$field_name;
395
396                 $module_field = $field_name.'_mod';
397                 $owner_field = $field_name.'_owner';
398                 if(!empty($aItem->$module_field)) {
399
400                     $list_field['owner_id'] = $aItem->$owner_field;
401                     $list_field['owner_module'] = $aItem->$module_field;
402
403                 } else {
404                     $list_field['owner_id'] = false;
405                     $list_field['owner_module'] = false;
406                 }
407                 if(isset($list_field['alias'])) $list_field['name'] = $list_field['alias'];
408                 else $list_field['name']=$field_name;
409                 $list_field['fields'] = $fields;
410                 $list_field['module'] = $aItem->module_dir;
411                 $list_field['start_link_wrapper'] = $this->start_link_wrapper;
412                 $list_field['end_link_wrapper'] = $this->end_link_wrapper;
413                 $list_field['subpanel_id'] = $this->subpanel_id;
414                 $list_field += $field_acl;
415                 if ( isset($aItem->field_defs[strtolower($list_field['name'])])) {
416                     require_once('include/SugarFields/SugarFieldHandler.php');
417                     // We need to see if a sugar field exists for this field type first,
418                     // if it doesn't, toss it at the old sugarWidgets. This is for
419                     // backwards compatibility and will be removed in a future release
420                     $vardef = $aItem->field_defs[strtolower($list_field['name'])];
421                     if ( isset($vardef['type']) ) {
422                         $fieldType = isset($vardef['custom_type'])?$vardef['custom_type']:$vardef['type'];
423                         $tmpField = SugarFieldHandler::getSugarField($fieldType,true);
424                     } else {
425                         $tmpField = NULL;
426                     }
427
428                     if ( $tmpField != NULL ) {
429                         $widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'],$vardef,'ListView',$list_field);
430                     } else {
431                         // No SugarField for this particular type
432                         // Use the old, icky, SugarWidget for now
433                         $widget_contents = $layout_manager->widgetDisplay($list_field);
434                     }
435
436                     if ( isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink' ) {
437                         // We need to call into the old SugarWidgets for the time being, so it can generate a proper link with all the various corner-cases handled
438                         // So we'll populate the field data with the pre-rendered display for the field
439                         $list_field['fields'][$field_name] = $widget_contents;
440                         if('full_name' == $field_name){//bug #32465
441                            $list_field['fields'][strtoupper($field_name)] = $widget_contents;
442                         }
443
444                         //vardef source is non db, assign the field name to varname for processing of column.
445                         if(!empty($vardef['source']) && $vardef['source']=='non-db'){
446                             $list_field['varname'] = $field_name;
447
448                         }
449                         $widget_contents = $layout_manager->widgetDisplay($list_field);
450                     } else if(isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink' ) {
451                         $widget_contents = $layout_manager->widgetDisplay($list_field);
452                     }
453
454                  $count++;
455                 $this->xTemplate->assign('CELL_COUNT', $count);
456                 $this->xTemplate->assign('CLASS', "");
457                 if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
458                 $this->xTemplate->assign('CELL', $widget_contents);
459                 $this->xTemplate->parse($xtemplateSection.".row.cell");
460                 } else {
461                     // This handles the edit and remove buttons and icon widget
462                         if( isset($list_field['widget_class']) && $list_field['widget_class'] == "SubPanelIcon") {
463                                 $count++;
464                                 $widget_contents = $layout_manager->widgetDisplay($list_field);
465                                 $this->xTemplate->assign('CELL_COUNT', $count);
466                                 $this->xTemplate->assign('CLASS', "");
467                                 if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
468                                 $this->xTemplate->assign('CELL', $widget_contents);
469                                 $this->xTemplate->parse($xtemplateSection.".row.cell");
470                         } elseif (preg_match("/button/i", $list_field['name'])) {
471                         if ((($list_field['name'] === 'edit_button' && $field_acl['EditView']) || ($list_field['name'] === 'close_button' && $field_acl['EditView']) || ($list_field['name'] === 'remove_button' && $field_acl['Delete'])) && '' != ($_content = $layout_manager->widgetDisplay($list_field)) )
472                         {
473                             $button_contents[] = $_content;
474                             unset($_content);
475                         }
476                         } else {
477                                 $count++;
478                                 $this->xTemplate->assign('CLASS', "");
479                                 $widget_contents = $layout_manager->widgetDisplay($list_field);
480                                 $this->xTemplate->assign('CELL_COUNT', $count);
481                                 if ( empty($widget_contents) ) $widget_contents = '&nbsp;';
482                                 $this->xTemplate->assign('CELL', $widget_contents);
483                                 $this->xTemplate->parse($xtemplateSection.".row.cell");
484                         }
485                 }
486
487             }
488         }
489
490
491         // Make sure we have at least one button before rendering a column for
492         // the action buttons in a list view. Relevant bugs: #51647 and #51640.
493         if(isset($button_contents[0])) {
494             // this is for inline buttons on listviews
495             // bug#51275: smarty widget to help provide the action menu functionality as it is currently sprinkled throughout the app with html
496             require_once('include/Smarty/plugins/function.sugar_action_menu.php');
497             $tempid = create_guid();
498             $button_contents[0] = "<div style='display: inline' id='$tempid'>".$button_contents[0]."</div>";
499             $action_button = smarty_function_sugar_action_menu(array(
500                 'id' => $tempid,
501                 'buttons' => $button_contents,
502                 'class' => 'clickMenu subpanel records fancymenu button',
503                 'flat' => false //assign flat value as false to display dropdown menu at any other preferences.
504             ), $this->xTemplate);
505             $this->xTemplate->assign('CLASS', "inlineButtons");
506             $this->xTemplate->assign('CELL_COUNT', ++$count);
507             //Bug#51275 for beta3 pre_script is not required any more
508             $this->xTemplate->assign('CELL', $action_button);
509             $this->xTemplate->parse($xtemplateSection.".row.cell");
510         }
511
512
513         $aItem->setupCustomFields($aItem->module_dir);
514         $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
515
516         $count++;
517
518         $this->xTemplate->parse($xtemplateSection.".row");
519     }
520
521     $this->xTemplate->parse($xtemplateSection);
522 }
523
524 /**sets whether or not to display the xtemplate header and footer
525  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
526  * All Rights Reserved.
527  * Contributor(s): ______________________________________.
528 */
529 function setDisplayHeaderAndFooter($bool) {
530         $this->display_header_and_footer = $bool;
531 }
532
533 /**initializes ListView
534  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
535  * All Rights Reserved.
536  * Contributor(s): ______________________________________.
537 */
538  function ListView() {
539
540
541     if(!$this->initialized) {
542         global $sugar_config;
543         $this->records_per_page = $sugar_config['list_max_entries_per_page'] + 0;
544         $this->initialized = true;
545         global $app_strings, $currentModule;
546         $this->local_theme = SugarThemeRegistry::current()->__toString();
547         $this->local_app_strings =$app_strings;
548         $this->local_image_path = SugarThemeRegistry::current()->getImagePath();
549         $this->local_current_module = $currentModule;
550     }
551 }
552 /**sets how many records should be displayed per page in the list view
553  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
554  * All Rights Reserved.
555  * Contributor(s): ______________________________________.
556 */
557  function setRecordsPerPage($count) {
558     $this->records_per_page = $count;
559 }
560 /**sets the header title */
561  function setHeaderTitle($value) {
562     $this->header_title = $value;
563 }
564 /**sets the header text this is text that's appended to the header table and is usually used for the creation of buttons
565  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
566  * All Rights Reserved.
567  * Contributor(s): ______________________________________.
568 */
569  function setHeaderText($value) {
570     $this->header_text = $value;
571 }
572 /**sets the path for the XTemplate HTML file to be used this is only needed to be set if you are allowing ListView to create the XTemplate
573  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
574  * All Rights Reserved.
575  * Contributor(s): ______________________________________.
576 */
577  function setXTemplatePath($value) {
578     $this->xTemplatePath= $value;
579 }
580
581 /**this is a helper function for allowing ListView to create a new XTemplate it groups parameters that should be set into a single function
582  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
583  * All Rights Reserved.
584  * Contributor(s): ______________________________________.
585 */
586  function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) {
587     $this->setXTemplatePath($XTemplatePath);
588     if(isset($modString))
589         $this->setModStrings($modString);
590     if(isset($imagePath))
591         $this->setImagePath($imagePath);
592 }
593
594
595 function getOrderBy($varName, $defaultOrderBy='', $force_sortorder='') {
596     $sortBy = $this->getSessionVariable($varName, "ORDER_BY") ;
597
598     $orderByDirection = $this->getSessionVariableName($varName, "order_by_direction");
599     $orderByColumn = $this->getSessionVariableName($varName, "ORDER_BY");
600     $lastEqualsSortBy = false;
601     $defaultOrder = false; //ascending
602
603     if(empty($sortBy)) {
604         $this->setUserVariable($varName, "ORDER_BY", $defaultOrderBy);
605         $sortBy = $defaultOrderBy;
606     } else {
607         $this->setUserVariable($varName, "ORDER_BY", $sortBy);
608     }
609
610     $desc = $this->getSessionVariable($varName, $sortBy."S");
611
612     if (empty($desc))
613         {
614             $desc = $defaultOrder;
615         }
616         $defaultOrder = $desc ? 'desc' : 'asc';
617         $orderByValue = $defaultOrder;
618         if (isset($_REQUEST[$orderByDirection]))
619         {
620             $possibleRequestOrderBy = $_REQUEST[$orderByDirection];
621             if ($possibleRequestOrderBy == 'asc' || $possibleRequestOrderBy == 'desc')
622             {
623                 $orderByValue = $possibleRequestOrderBy;
624             }
625         }
626
627         if (isset($_REQUEST[$orderByColumn]))
628         {
629             $last = $this->getSessionVariable($varName, "OBL");
630         }
631         if (!empty($last) && $last == $sortBy)
632         {
633             $lastEqualsSortBy = true;
634         } else
635         {
636             $orderByValue = $defaultOrder;
637             $this->setSessionVariable($varName, "OBL", $sortBy);
638         }
639         $desc = $orderByValue == 'desc';
640         $orderByDirectionValue = false;
641         $this->setSessionVariable($varName, $sortBy . "S", $desc);
642         if (!empty($sortBy))
643         {
644             if (empty($force_sortorder))
645             {
646                 if (substr_count(strtolower($sortBy), ' desc') == 0 && substr_count(strtolower($sortBy), ' asc') == 0)
647                 {
648                     if ($sortBy)
649                     {
650                         $orderByDirectionValue = $desc ? 'asc' : 'desc';
651                     }
652                     $this->query_orderby = $sortBy . ' ' . $orderByValue;
653                 }
654             } else
655             {
656                 $this->query_orderby = $sortBy . ' ' . $force_sortorder;
657             }
658             if (!isset($this->appendToBaseUrl))
659             {
660                 $this->appendToBaseUrl = array();
661             }
662             if ($orderByDirectionValue)
663             {
664                 $this->appendToBaseUrl[$orderByDirection] = $orderByDirectionValue;
665             }
666             $offsetVar = $this->getSessionVariableName($varName, "offset");
667             if (isset($_REQUEST[$offsetVar]))
668             {
669                 $this->appendToBaseUrl[$offsetVar] = $_REQUEST[$offsetVar];
670             }
671             //Just clear from url...
672             $this->appendToBaseUrl[$orderByColumn] = false;
673     }else {
674         $this->query_orderby = "";
675     }
676     $this->sortby = $sortBy;
677     return $this->query_orderby;
678
679 }
680
681
682 /**sets the parameters dealing with the db
683  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
684  * All Rights Reserved.
685  * Contributor(s): ______________________________________.
686 */
687  function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride=true) {
688     $this->query_where = $where;
689     if($this->getSessionVariable("query", "where") != $where) {
690         $this->query_where_has_changed = true;
691         $this->setSessionVariable("query", "where", $where);
692     }
693
694     $this->query_limit = $limit;
695     if(!$allowOrderByOveride) {
696         $this->query_orderby = $orderBy;
697         return;
698     }
699     $this->getOrderBy($varName, $orderBy);
700
701     $this->setLocalSessionVariable($varName, "QUERY_WHERE", $where);
702
703     //SETTING ORDER_BY FOR USE IN DETAILVIEW
704     $this->setLocalSessionVariable($varName, "ORDER_BY_DETAIL", $this->query_orderby);
705 }
706
707 function displayArrow() {
708
709 }
710
711 /**sets the theme used only use if it is different from the global
712  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
713  * All Rights Reserved.
714  * Contributor(s): ______________________________________.
715 */
716  function setTheme($theme) {
717     $this->local_theme = $theme;
718     if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme);
719 }
720
721 /**sets the AppStrings used only use if it is different from the global
722  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
723  * All Rights Reserved.
724  * Contributor(s): ______________________________________.
725 */
726  function setAppStrings($app_strings) {
727     unset($this->local_app_strings);
728     $this->local_app_strings = $app_strings;
729     if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings);
730 }
731
732 /**sets the ModStrings used
733  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
734  * All Rights Reserved.
735  * Contributor(s): ______________________________________.
736 */
737  function setModStrings($mod_strings) {
738     unset($this->local_module_strings);
739     $this->local_mod_strings = $mod_strings;
740     if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings);
741 }
742
743 /**sets the ImagePath used
744  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
745  * All Rights Reserved.
746  * Contributor(s): ______________________________________.
747 */
748  function setImagePath($image_path) {
749     $this->local_image_path = $image_path;
750     if(empty($this->local_image_path)) {
751         $this->local_image_path = SugarThemeRegistry::get($this->local_theme)->getImagePath();
752     }
753     if(isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
754 }
755
756 /**sets the currentModule only use if this is different from the global
757  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
758  * All Rights Reserved.
759  * Contributor(s): ______________________________________.
760 */
761  function setCurrentModule($currentModule) {
762     unset($this->local_current_module);
763     $this->local_current_module = $currentModule;
764     if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
765 }
766
767 /**INTERNAL FUNCTION creates an XTemplate DO NOT CALL THIS THIS IS AN INTERNAL FUNCTION
768  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
769  * All Rights Reserved.
770  * Contributor(s): ______________________________________.
771 */
772  function createXTemplate() {
773     if(!isset($this->xTemplate)) {
774         if(isset($this->xTemplatePath)) {
775
776             $this->xTemplate = new XTemplate($this->xTemplatePath);
777             $this->xTemplate->assign("APP", $this->local_app_strings);
778             if(isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings);
779             $this->xTemplate->assign("THEME", $this->local_theme);
780             $this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
781             $this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
782         } else {
783             $GLOBALS['log']->error("NO XTEMPLATEPATH DEFINED CANNOT CREATE XTEMPLATE");
784         }
785     }
786 }
787
788 /**sets the XTemplate telling ListView to use newXTemplate as its current XTemplate
789  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
790  * All Rights Reserved.
791  * Contributor(s): ______________________________________.
792 */
793  function setXTemplate($newXTemplate) {
794     $this->xTemplate = $newXTemplate;
795 }
796
797 /**returns the XTemplate
798  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
799  * All Rights Reserved.
800  * Contributor(s): ______________________________________.
801 */
802  function getXTemplate() {
803     return $this->xTemplate;
804 }
805
806 /**assigns a name value pair to the XTemplate
807  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
808  * All Rights Reserved.
809  * Contributor(s): ______________________________________.
810 */
811  function xTemplateAssign($name, $value) {
812
813         if(!isset($this->xTemplate)) {
814             $this->createXTemplate();
815         }
816         $this->xTemplate->assign($name, $value);
817
818 }
819
820 /**INTERNAL FUNCTION returns the offset first checking the query then checking the session if the where clause has changed from the last time it returns 0
821  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
822  * All Rights Reserved.
823  * Contributor(s): ______________________________________.
824 */
825  function getOffset($localVarName) {
826         if($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) {
827                 $this->setSessionVariable($localVarName,"offset", 0);
828         }
829         $offset = $this->getSessionVariable($localVarName,"offset");
830         if(isset($offset)) {
831                 return $offset;
832         }
833         return 0;
834 }
835
836 /**INTERNAL FUNCTION sets the offset in the session
837  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
838  * All Rights Reserved.
839  * Contributor(s): ______________________________________.
840 */
841  function setOffset($localVarName, $value) {
842         $this->setSessionVariable($localVarName, "offset", $value);
843 }
844
845 /**INTERNAL FUNCTION sets a session variable
846  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
847  * All Rights Reserved.
848  * Contributor(s): ______________________________________.
849 */
850  function setSessionVariable($localVarName,$varName, $value) {
851     $_SESSION[$this->local_current_module."_".$localVarName."_".$varName] = $value;
852 }
853
854 function setUserVariable($localVarName,$varName, $value) {
855         if($this->is_dynamic ||  $localVarName == 'CELL')return;
856         global $current_user;
857         $current_user->setPreference($this->local_current_module."_".$localVarName."_".$varName, $value);
858 }
859
860 /**INTERNAL FUNCTION returns a session variable first checking the query for it then checking the session
861  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
862  * All Rights Reserved.
863  * Contributor(s): ______________________________________.
864 */
865  function getSessionVariable($localVarName,$varName) {
866     //Set any variables pass in through request first
867     if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
868         $this->setSessionVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
869     }
870
871     if(isset($_SESSION[$this->getSessionVariableName($localVarName, $varName)])) {
872         return $_SESSION[$this->getSessionVariableName($localVarName, $varName)];
873     }
874     return "";
875 }
876
877 function getUserVariable($localVarName, $varName) {
878     global $current_user;
879     if($this->is_dynamic ||  $localVarName == 'CELL')return;
880     if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
881
882             $this->setUserVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
883     }
884     return $current_user->getPreference($this->getSessionVariableName($localVarName, $varName));
885 }
886
887
888     /**
889      * helper method to determine sort order by priority of source
890      * 1. explicit in request object
891      * 2. in session variable
892      * 3. subpaneldefs metadata
893      * 4. default 'asc'
894      * @param array $sortOrderList - contains options
895      * @return string 'asc' | 'desc'
896      */
897     function calculateSortOrder($sortOrderList)
898     {
899         $priority_map = array(
900           'request',
901           'session',
902           'subpaneldefs',
903           'default',
904         );
905
906         foreach($priority_map as $p) {
907             if (key_exists($p, $sortOrderList)) {
908                 $order = strtolower($sortOrderList[$p]);
909                 if (in_array($order, array('asc', 'desc'))) {
910                     return $order;
911                 }
912             }
913         }
914         return 'asc';
915     }
916
917
918     /**
919
920     * @return void
921     * @param unknown $localVarName
922     * @param unknown $varName
923     * @desc INTERNAL FUNCTION returns the session/query variable name
924     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
925     * All Rights Reserved.
926     * Contributor(s): ______________________________________..
927     */
928     function getSessionVariableName($localVarName,$varName) {
929         return $this->local_current_module."_".$localVarName."_".$varName;
930     }
931
932     /**
933
934     * @return void
935     * @param unknown $seed
936     * @param unknown $xTemplateSection
937     * @param unknown $html_varName
938     * @desc INTERNAL FUNCTION Handles List Views using seeds that extend SugarBean
939         $XTemplateSection is the section in the XTemplate file that should be parsed usually main
940         $html_VarName is the variable name used in the XTemplateFile e.g. TASK
941         $seed is a seed that extends SugarBean
942         * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
943         * All Rights Reserved..
944         * Contributor(s): ______________________________________..
945     */
946     function processSugarBean($xtemplateSection, $html_varName, $seed) {
947         global $list_view_row_count;
948
949         $current_offset = $this->getOffset($html_varName);
950         $response = array();
951
952         //ADDING VCR CONTROL
953         SugarVCR::erase($seed->module_dir);
954         $params = array();
955         //$filter = array('id', 'full_name');
956         $filter=array();
957         $ret_array = $seed->create_new_list_query($this->query_orderby, $this->query_where, $filter, $params, 0, '', true, $seed, true);
958         if(!is_array($params)) $params = array();
959         if(!isset($params['custom_select'])) $params['custom_select'] = '';
960         if(!isset($params['custom_from'])) $params['custom_from'] = '';
961         if(!isset($params['custom_where'])) $params['custom_where'] = '';
962         if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
963         $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
964         SugarVCR::store($seed->module_dir,  $main_query);
965         //ADDING VCR CONTROL
966
967         if(empty($this->related_field_name)) {
968             $response = $seed->get_list($this->query_orderby, $this->query_where, $current_offset, $this->query_limit);
969         } else {
970             $related_field_name = $this->related_field_name;
971             $response = $seed->get_related_list($this->child_focus,$related_field_name, $this->query_orderby,
972             $this->query_where, $current_offset, $this->query_limit);
973         }
974
975         $list = $response['list'];
976         $row_count = $response['row_count'];
977         $next_offset = $response['next_offset'];
978         $previous_offset = $response['previous_offset'];
979
980         if(!empty($response['current_offset'])) {
981             $current_offset = $response['current_offset'];
982         }
983
984         $list_view_row_count = $row_count;
985         $this->processListNavigation($xtemplateSection,$html_varName, $current_offset, $next_offset, $previous_offset, $row_count, null, null, empty($seed->column_fields) ? null : count($seed->column_fields));
986
987         return $list;
988     }
989
990
991
992     function processUnionBeans($sugarbean, $subpanel_def, $html_var = 'CELL') {
993
994                 $last_detailview_record = $this->getSessionVariable("detailview", "record");
995                 if(!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id){
996                         $GLOBALS['record_has_changed'] = true;
997                 }
998                 $this->setSessionVariable("detailview", "record", $sugarbean->id);
999
1000                 $current_offset = $this->getOffset($html_var);
1001                 $module = isset($_REQUEST['module']) ? $_REQUEST['module'] : '';
1002                 $response = array();
1003
1004         // choose sort order
1005         $sort_order = array();
1006         $sort_order['default'] = 'asc';
1007
1008         // explicit request parameter gets priority over all
1009         $sort_order['request'] = isset($_REQUEST['sort_order']) ? $_REQUEST['sort_order'] : null;
1010
1011         // see if the session data has a sort order
1012         if (isset($_SESSION['last_sub' . $this->subpanel_module . '_order']))
1013         {
1014             $sort_order['session'] = $_SESSION['last_sub' . $this->subpanel_module . '_order'];
1015
1016             // We swap the order when the request contains an offset (indicating a column sort issued);
1017             // otherwise we do not sort.  If we don't make this check, then the subpanel listview will
1018             // swap ordering each time a new record is entered via quick create forms
1019             if (isset($_REQUEST[$module . '_' . $html_var . '_offset']))
1020             {
1021                 $sort_order['session'] = $sort_order['session'] == 'asc' ? 'desc' : 'asc';
1022             }
1023         }
1024         else
1025         {
1026             $sort_order['session'] = null;
1027         }
1028
1029         // does the metadata have a default sort order?
1030         $sort_order['subpaneldefs'] = isset($subpanel_def->_instance_properties['sort_order']) ?
1031             $subpanel_def->_instance_properties['sort_order'] : null;
1032
1033         $this->sort_order = $this->calculateSortOrder($sort_order);
1034
1035
1036         if (isset($subpanel_def->_instance_properties['sort_by'])) {
1037             $this->query_orderby = $subpanel_def->_instance_properties['sort_by'];
1038         } else {
1039             $this->query_orderby = 'id';
1040         }
1041
1042         $this->getOrderBy($html_var,$this->query_orderby, $this->sort_order);
1043
1044         $_SESSION['last_sub' .$this->subpanel_module. '_order'] = $this->sort_order;
1045         $_SESSION['last_sub' .$this->subpanel_module. '_url'] = $this->getBaseURL($html_var);
1046
1047                 // Bug 8139 - Correct Subpanel sorting on 'name', when subpanel sorting default is 'last_name, first_name'
1048                 if (($this->sortby == 'name' || $this->sortby == 'last_name') &&
1049                         str_replace(' ', '', trim($subpanel_def->_instance_properties['sort_by'])) == 'last_name,first_name') {
1050                         $this->sortby = 'last_name '.$this->sort_order.', first_name ';
1051                 }
1052
1053         if(!empty($this->response)){
1054             $response =& $this->response;
1055             echo 'cached';
1056         }else{
1057             $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def);
1058             $this->response =& $response;
1059         }
1060         $list = $response['list'];
1061         $row_count = $response['row_count'];
1062         $next_offset = $response['next_offset'];
1063         $previous_offset = $response['previous_offset'];
1064         if(!empty($response['current_offset']))$current_offset = $response['current_offset'];
1065         global $list_view_row_count;
1066         $list_view_row_count = $row_count;
1067         $this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean,$subpanel_def);
1068
1069         return array('list'=>$list, 'parent_data'=>$response['parent_data'], 'query'=>$response['query']);
1070     }
1071
1072     function getBaseURL($html_varName) {
1073         static $cache = array();
1074
1075         if(!empty($cache[$html_varName]))return $cache[$html_varName];
1076         $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount','current_query_by_page');
1077         if(!empty($this->base_URL)) {
1078             return $this->base_URL;
1079         }
1080
1081             $baseurl = $_SERVER['PHP_SELF'];
1082             if(empty($baseurl)) {
1083                 $baseurl = 'index.php';
1084             }
1085
1086             /*fixes an issue with deletes when doing a search*/
1087             foreach(array_merge($_GET, $_POST) as $name=>$value) {
1088                 //echo ("$name = $value <br/>");
1089                 if(!empty($value) && $name != 'sort_order' //&& $name != ListView::getSessionVariableName($html_varName,"ORDER_BY")
1090                         && $name != ListView::getSessionVariableName($html_varName,"offset")
1091                         /*&& substr_count($name, "ORDER_BY")==0*/ && !in_array($name, $blockVariables))
1092                 {
1093                     if(is_array($value)) {
1094                         foreach($value as $valuename=>$valuevalue) {
1095                             if(substr_count($baseurl, '?') > 0)
1096                                 $baseurl        .= "&{$name}[]=".$valuevalue;
1097                             else
1098                                 $baseurl        .= "?{$name}[]=".$valuevalue;
1099                         }
1100                     } else {
1101                         $value = urlencode($value);
1102                         if(substr_count($baseurl, '?') > 0) {
1103                             $baseurl    .= "&$name=$value";
1104                         } else {
1105                             $baseurl    .= "?$name=$value";
1106                         }
1107                     }
1108                 }
1109             }
1110
1111
1112             if($_SERVER['REQUEST_METHOD'] == 'POST') {
1113                 // at this point it is possible that the above foreach already executed resulting in double ?'s in the url
1114                 if(substr_count($baseurl, '?') == 0) {
1115                     $baseurl .= '?';
1116                 }
1117                 if(isset($_REQUEST['action'])) $baseurl.= '&action='.$_REQUEST['action'];
1118                 if(isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record'];
1119                 if(isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module'];
1120             }
1121
1122             $baseurl .= "&".ListView::getSessionVariableName($html_varName,"offset")."=";
1123             $cache[$html_varName] = $baseurl;
1124             return $baseurl;
1125     }
1126     /**
1127     * @return void
1128     * @param unknown $data
1129     * @param unknown $xTemplateSection
1130     * @param unknown $html_varName
1131     * @desc INTERNAL FUNCTION process the List Navigation
1132     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1133     * All Rights Reserved.
1134     * Contributor(s): ______________________________________..
1135     */
1136     function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean=null, $subpanel_def=null, $col_count = 20) {
1137
1138         global $export_module;
1139         global $sugar_config;
1140         global $current_user;
1141         global $currentModule;
1142         global $app_strings;
1143
1144         $start_record = $current_offset + 1;
1145
1146         if(!is_numeric($col_count))
1147             $col_count = 20;
1148
1149         if($row_count == 0)
1150             $start_record = 0;
1151
1152         $end_record = $start_record + $this->records_per_page;
1153         // back up the the last page.
1154         if($end_record > $row_count+1) {
1155             $end_record = $row_count+1;
1156         }
1157         // Determine the start location of the last page
1158         if($row_count == 0)
1159             $number_pages = 0;
1160         else
1161             $number_pages = floor(($row_count - 1) / $this->records_per_page);
1162
1163         $last_offset = $number_pages * $this->records_per_page;
1164
1165         if(empty($this->query_limit)  || $this->query_limit > $this->records_per_page) {
1166             $this->base_URL = $this->getBaseURL($html_varName);
1167             $dynamic_url = '';
1168
1169             if($this->is_dynamic) {
1170                 $dynamic_url .='&'. $this->getSessionVariableName($html_varName,'ORDER_BY') . '='. $this->getSessionVariable($html_varName,'ORDER_BY').'&sort_order='.$this->sort_order.'&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->subpanel_module;
1171             }
1172
1173             $current_URL = htmlentities($this->base_URL.$current_offset.$dynamic_url);
1174             $start_URL = htmlentities($this->base_URL."0".$dynamic_url);
1175             $previous_URL  = htmlentities($this->base_URL.$previous_offset.$dynamic_url);
1176             $next_URL  = htmlentities($this->base_URL.$next_offset.$dynamic_url);
1177             $end_URL  = htmlentities($this->base_URL.'end'.$dynamic_url);
1178
1179             if(!empty($this->start_link_wrapper)) {
1180                 $current_URL = $this->start_link_wrapper.$current_URL.$this->end_link_wrapper;
1181                 $start_URL = $this->start_link_wrapper.$start_URL.$this->end_link_wrapper;
1182                 $previous_URL = $this->start_link_wrapper.$previous_URL.$this->end_link_wrapper;
1183                 $next_URL = $this->start_link_wrapper.$next_URL.$this->end_link_wrapper;
1184                 $end_URL = $this->start_link_wrapper.$end_URL.$this->end_link_wrapper;
1185             }
1186
1187             $moduleString = "{$currentModule}_{$html_varName}_offset";
1188             $moduleStringOrder = "{$currentModule}_{$html_varName}_ORDER_BY";
1189             if($this->shouldProcess && !$this->multi_select_popup) {
1190                 // check the checkboxes onload
1191                 echo "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n";
1192
1193                 $massUpdateRun = isset($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true';
1194                 $uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid'];
1195                 $select_entire_list = ($massUpdateRun) ? 0 : (isset($_POST['select_entire_list']) ? $_POST['select_entire_list'] : (isset($_REQUEST['select_entire_list']) ? $_REQUEST['select_entire_list'] : 0));
1196
1197                 echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" .
1198                     "<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n".
1199                     "<input type='hidden' name='{$moduleString}' value='0'>\n".
1200                     "<input type='hidden' name='{$moduleStringOrder}' value='0'>\n";
1201
1202             }
1203
1204
1205             $GLOBALS['log']->debug("Offsets: (start, previous, next, last)(0, $previous_offset, $next_offset, $last_offset)");
1206
1207             if(0 == $current_offset) {
1208                 $start_link = "<button type='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("start_off","aborder='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1209                 $previous_link = "<button type='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1210             } else {
1211                 if($this->multi_select_popup) {// nav links for multiselect popup, submit form to save checks.
1212                     $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='javascript:save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1213                     $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='javascript:save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1214                 } elseif($this->shouldProcess) {
1215                     $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"$start_URL\"; sListView.save_checks(0, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1216                     $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"$previous_URL\"; sListView.save_checks($previous_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1217                 } else {
1218                     $onClick = '';
1219                     if(0 != preg_match('/javascript.*/', $start_URL)){
1220                         $onClick = "\"$start_URL;\"";
1221                     }else{
1222                         $onClick ="'location.href=\"$start_URL\";'";
1223                     }
1224                     $start_link = "<button type='button' class='button' name='listViewStartButton' title='{$this->local_app_strings['LNK_LIST_START']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("start","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_START'])."</button>";
1225
1226                     $onClick = '';
1227                     if(0 != preg_match('/javascript.*/', $previous_URL)){
1228                         $onClick = "\"$previous_URL;\"";
1229                     }else{
1230                         $onClick = "'location.href=\"$previous_URL\";'";
1231                     }
1232                     $previous_link = "<button type='button' class='button' name='listViewPrevButton' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("previous","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_PREVIOUS'])."</button>";
1233                 }
1234             }
1235
1236             if($last_offset <= $current_offset) {
1237                 $end_link = "<button type='button' name='listViewEndButton' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("end_off","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1238                 $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("next_off","aborder='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1239             } else {
1240                 if($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks.
1241                     $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='javascript:save_checks($last_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1242                     if(!empty($sugar_config['disable_count_query'])) {
1243                         $end_link = '';
1244                     }
1245                     $next_link = "<button type='button' name='listViewNextButton' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' onClick='javascript:save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1246                 } elseif($this->shouldProcess) {
1247                     $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"$end_URL\"; sListView.save_checks(\"end\", \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1248                     $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"$next_URL\"; sListView.save_checks($next_offset, \"{$moduleString}\");'>".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1249                 } else {
1250                     $onClick = '';
1251                     if(0 != preg_match('/javascript.*/', $next_URL)){
1252                         $onClick = "\"$next_URL;\"";
1253                     }else{
1254                         $onClick ="'location.href=\"$next_URL\";'";
1255                     }
1256                     $next_link = "<button type='button' name='listViewNextButton' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("next","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_NEXT'])."</button>";
1257
1258                     $onClick = '';
1259                     if(0 != preg_match('/javascript.*/', $end_URL)){
1260                         $onClick = "\"$end_URL;\"";
1261                     }else{
1262                         $onClick = "'location.href=\"$end_URL\";'";
1263                     }
1264                     $end_link = "<button type='button' name='listViewEndButton' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick=".$onClick.">".SugarThemeRegistry::current()->getImage("end","border='0' align='absmiddle'",null,null,'.gif',$this->local_app_strings['LNK_LIST_END'])."</button>";
1265
1266                 }
1267             }
1268
1269             $GLOBALS['log']->info("Offset (next, current, prev)($next_offset, $current_offset, $previous_offset)");
1270             $GLOBALS['log']->info("Start/end records ($start_record, $end_record)");
1271
1272             $end_record = $end_record-1;
1273
1274 $script_href = "<a style=\'width: 150px\' name=\"thispage\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $this->records_per_page)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}&nbsp;&#x28;{$this->records_per_page}&#x29;&#x200E;</a>"
1275  . "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;&#x28;{$row_count}&#x29;&#x200E;</a>"
1276  . "<a style=\'width: 150px\' name=\"deselect\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'#\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>";
1277
1278 $close_inline_img = SugarThemeRegistry::current()->getImage('close_inline', 'border=0', null, null, ".gif", $app_strings['LBL_CLOSEINLINE']);
1279
1280             echo "<script>
1281                 function select_dialog() {
1282                         var \$dialog = \$('<div></div>')
1283                                         .html('<a style=\'width: 150px\' name=\"thispage\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $this->records_per_page)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'javascript:void(0)\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}&nbsp;&#x28;{$this->records_per_page}&#x29;&#x200E;</a>"
1284                 . "<a style=\'width: 150px\' name=\"selectall\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$row_count});\' href=\'javascript:void(0)\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;&#x28;{$row_count}&#x29;&#x200E;</a>"
1285                 . "<a style=\'width: 150px\' name=\"deselect\" class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'javascript:void(0)\'>{$this->local_app_strings['LBL_LISTVIEW_NONE']}</a>')
1286                                         .dialog({
1287                                                 autoOpen: false,
1288                                                 width: 150
1289                                         });
1290                                         \$dialog.dialog('open');
1291
1292                 }
1293                 </script>";
1294
1295             if($this->show_select_menu)
1296             {
1297                 $total_label = "";
1298                 $total = $row_count;
1299                 $pageTotal = ($row_count > 0) ? $end_record - $start_record + 1 : 0;
1300                 if (!empty($GLOBALS['sugar_config']['disable_count_query']) && $GLOBALS['sugar_config']['disable_count_query'] === true && $total > $pageTotal) {
1301                     $this->show_plus = true;
1302                     $total =  $pageTotal;
1303                     $total_label = $total.'+';
1304                 } else {
1305                     $this->show_plus = false;
1306                     $total_label = $total;
1307                 }
1308                 echo "<input type='hidden' name='show_plus' value='{$this->show_plus}'>\n";
1309
1310                 //Bug#52931: Replace with actionMenu
1311                 //$select_link = "<a id='select_link' onclick='return select_dialog();' href=\"javascript:void(0)\">".$this->local_app_strings['LBL_LINK_SELECT']."&nbsp;".SugarThemeRegistry::current()->getImage('MoreDetail', 'border=0', 11, 7, '.png', $app_strings['LBL_MOREDETAIL'])."</a>";
1312                 $menuItems = array(
1313                     "<input title=\"".$app_strings['LBL_SELECT_ALL_TITLE']."\" type='checkbox' class='checkbox massall' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' /><a href='javascript: void(0);'></a>",
1314                     "<a  name='thispage' id='button_select_this_page' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $pageTotal)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};' href='#'>{$app_strings['LBL_LISTVIEW_OPTION_CURRENT']}&nbsp;&#x28;{$pageTotal}&#x29;&#x200E;</a>",
1315                     "<a  name='selectall' id='button_select_all' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$total});' href='#'>{$app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;&#x28;{$total_label}&#x29;&#x200E;</a>",
1316                     "<a name='deselect' id='button_deselect' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick='sListView.clear_all(document.MassUpdate, \"mass[]\", false);' href='#'>{$app_strings['LBL_LISTVIEW_NONE']}</a>",
1317                 );
1318                 require_once('include/Smarty/plugins/function.sugar_action_menu.php');
1319                 $select_link = smarty_function_sugar_action_menu(array(
1320                     'class' => 'clickMenu selectmenu',
1321                     'id' => 'selectLink',
1322                     'buttons' => $menuItems,
1323                     'flat' => false,
1324                 ),$this->xTemplate);
1325
1326             } else {
1327                 $select_link = "&nbsp;";
1328             }
1329
1330             $export_link = '<input class="button" type="button" value="'.$this->local_app_strings['LBL_EXPORT'].'" ' .
1331                     'onclick="return sListView.send_form(true, \''.$_REQUEST['module'].'\', \'index.php?entryPoint=export\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\')">';
1332
1333             if($this->show_delete_button) {
1334                 $delete_link = '<input class="button" type="button" id="delete_button" name="Delete" value="'.$this->local_app_strings['LBL_DELETE_BUTTON_LABEL'].'" onclick="return sListView.send_mass_update(\'selected\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\', 1)">';
1335             } else {
1336                 $delete_link = '&nbsp;';
1337             }
1338
1339             $admin = new Administration();
1340             $admin->retrieveSettings('system');
1341
1342             $user_merge = $current_user->getPreference('mailmerge_on');
1343             if($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) {
1344                 echo "<script>
1345                 function mailmerge_dialog(el) {
1346                         var \$dialog = \$('<div></div>')
1347                                         .html('<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'return sListView.send_form(true, \"MailMerge\", \"index.php\", \"{$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED']}\")\' href=\'javascript:void(0)\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_SELECTED']}</a>"
1348                         . "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' href=\'index.php?action=index&module=MailMerge\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_CURRENT']}</a>"
1349                         . "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' href=\'index.php?action=index&module=MailMerge&entire=true\'>{$this->local_app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}</a>')
1350                                         .dialog({
1351                                                 autoOpen: false,
1352                                                 title: '". $this->local_app_strings['LBL_MAILMERGE']."',
1353                                                 width: 150,
1354                                                 position: {
1355                                                     my: myPos,
1356                                                     at: atPos,
1357                                                     of: \$(el)
1358                                                 }
1359                                         });
1360
1361                 }
1362             </script>";
1363                 $merge_link = "&nbsp;|&nbsp;<a id='mailmerge_link' onclick='return mailmerge_dialog(this)'; href=\"javascript:void(0)\">".$this->local_app_strings['LBL_MAILMERGE']."</a>";
1364             } else {
1365                 $merge_link = "&nbsp;";
1366             }
1367
1368             $selected_objects_span = "&nbsp;|&nbsp;{$this->local_app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input  style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' readonly name='selectCount[]' value='" . ((isset($_POST['mass'])) ? count($_POST['mass']): 0) . "' />";
1369
1370             if($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import'
1371                 || $this->show_export_button == false
1372                 || (!empty($sugar_config['disable_export']))
1373                 || (!empty($sugar_config['admin_export_only'])
1374                 && !(
1375                         is_admin($current_user)
1376                         || (ACLController::moduleSupportsACL($_REQUEST['module'])
1377                             && ACLAction::getUserAccessLevel($current_user->id,$_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED
1378                             && (ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN ||
1379                                 ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN_DEV)))))
1380             {
1381                 if ($_REQUEST['module'] != 'InboundEmail' && $_REQUEST['module'] != 'EmailMan' && $_REQUEST['module'] != 'iFrames') {
1382                     $selected_objects_span = '';
1383                 }
1384                 $export_link = "&nbsp;";
1385                 $merge_link = "&nbsp;";
1386             } elseif($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") {
1387                 $merge_link = "&nbsp;";
1388             }
1389
1390             if($this->show_paging == true) {
1391                 if(!empty($sugar_config['disable_count_query'])) {
1392                     if($row_count > $end_record) {
1393                         $row_count .= '+';
1394                     }
1395                 }
1396
1397                 $html_text = '';
1398                 $html_text .= "<tr class='pagination' role='presentation'>\n";
1399                 $html_text .= "<td COLSPAN=\"$col_count\" align=\"right\">\n";
1400                 //$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"  >$export_link$merge_link$selected_objects_span</td>\n";
1401                 //$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"  >";
1402                 if ($subpanel_def != null) {
1403                     include_once('include/SubPanel/SubPanelTiles.php');
1404                     $subpanelTiles = new SubPanelTiles($sugarbean);
1405                     $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"  >";
1406
1407                     //attempt to get the query to recreate this subpanel
1408                     if(!empty($this->response)){
1409                         $response =& $this->response;
1410                     }else{
1411                         $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1, $this->records_per_page,$this->query_limit,$subpanel_def);
1412                         $this->response = $response;
1413                     }
1414                     //if query is present, then pass it in as parameter
1415                     if (isset($response['query']) && !empty($response['query'])){
1416                         $html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']);
1417                     }else{
1418                         $html_text .= $subpanelTiles->get_buttons($subpanel_def);
1419                     }
1420                 }
1421                 else {
1422                     $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\"  nowrap>$select_link&nbsp;$export_link&nbsp;$delete_link&nbsp;$selected_objects_span";
1423                 }
1424                 $html_text .= "</td>\n<td nowrap align=\"right\">".$start_link."&nbsp;&nbsp;".$previous_link."&nbsp;&nbsp;<span class='pageNumbers'>(".$start_record." - ".$end_record." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.")</span>&nbsp;&nbsp;".$next_link."&nbsp;&nbsp;".$end_link."</td></tr></table>\n";
1425                 $html_text .= "</td>\n";
1426                 $html_text .= "</tr>\n";
1427                 $this->xTemplate->assign("PAGINATION",$html_text);
1428             }
1429
1430             //C.L. - Fix for 23461
1431             if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1432                 $_SESSION['export_where'] = $this->query_where;
1433             }
1434             $this->xTemplate->parse($xtemplateSection.".list_nav_row");
1435         }
1436     } // end processListNavigation
1437
1438     function processOrderBy($html_varName) {
1439
1440         if(!isset($this->base_URL)) {
1441             $this->base_URL = $_SERVER['PHP_SELF'];
1442
1443             if(isset($_SERVER['QUERY_STRING'])) {
1444                 $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=[0-9a-zA-Z\_\.]*/","",$this->base_URL .'?'.$_SERVER['QUERY_STRING']);
1445                 $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"offset")."=[0-9]*/","",$this->base_URL);
1446             }
1447             if($_SERVER['REQUEST_METHOD'] == 'POST') {
1448                 $this->base_URL .= '?';
1449                 if(isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action'];
1450                 if(isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record'];
1451                 if(isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module'];
1452             }
1453             $this->base_URL .= "&".$this->getSessionVariableName($html_varName,"offset")."=";
1454         }
1455
1456         if($this->is_dynamic) {
1457             $this->base_URL.='&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->source_module;
1458         }
1459
1460         //bug43465 start
1461         if (isset($this->appendToBaseUrl) && is_array($this->appendToBaseUrl))
1462         {
1463             foreach ($this->appendToBaseUrl as $key => $value)
1464             {
1465                 $fullRequestString = $key . '=' . $value;
1466
1467                 if ($this->base_URL == "/index.php")
1468                 {
1469                     $this->base_URL .= "?";
1470                 } else
1471                 {
1472                     if ($fullRequestString == substr($this->baseURL, '-' . strlen($fullRequestString)))
1473                     {
1474                         $this->base_URL = preg_replace("/&" . $key . "\=.*/", "", $this->base_URL);
1475                     } else
1476                     {
1477                         $this->base_URL = preg_replace("/&" . $key . "\=.*?&/", "&", $this->base_URL);
1478                     }
1479                     $this->base_URL .= "&";
1480                 }
1481                 if (!empty($value))
1482                 {
1483                     $this->base_URL .= "{$key}={$value}";
1484                 }
1485             }
1486         }
1487         //bug43465 end
1488
1489         $sort_URL_base = $this->base_URL. "&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=";
1490
1491         if($sort_URL_base !== "")
1492         {
1493             $this->xTemplate->assign("ORDER_BY", $sort_URL_base);
1494             return $sort_URL_base;
1495         } else {
1496             return '';
1497         }
1498     }
1499
1500
1501     function getAdditionalHeader() {
1502
1503     }
1504
1505
1506     /**
1507     * @return void
1508     * @param unknown $data
1509     * @param unknown $xTemplateSection
1510     * @param unknown $html_varName
1511     * @desc INTERNAL FUNCTION handles the rows
1512     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1513     * All Rights Reserved.
1514     * Contributor(s): ______________________________________..
1515     */
1516     function processListRows($data, $xtemplateSection, $html_varName)
1517     {
1518         global $odd_bg;
1519         global $even_bg;
1520         global $hilite_bg;
1521         global $app_strings, $sugar_version, $sugar_config;
1522         global $currentModule;
1523
1524         $this->xTemplate->assign('BG_HILITE', $hilite_bg);
1525         $this->xTemplate->assign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", ''));
1526     //$this->xTemplate->assign("BG_CLICK", $click_bg);
1527         $oddRow = true;
1528         $count = 0;
1529         reset($data);
1530
1531         //GETTING OFFSET
1532         $offset = $this->getOffset($html_varName);
1533         $timeStamp = $this->unique_id();
1534         $_SESSION[$html_varName."_FROM_LIST_VIEW"] = $timeStamp;
1535
1536         $associated_row_data = array();
1537
1538         //mail merge list
1539         $mergeList = array();
1540         $module = '';
1541         //todo what is this?  It is using an array as a boolean
1542         while(list($aVal, $aItem) = each($data))
1543         {
1544             if(isset($this->data_array)) {
1545                 $fields = $this->data_array;
1546             } else {
1547                 $aItem->check_date_relationships_load();
1548                 $fields = $aItem->get_list_view_data();
1549             }
1550
1551             if(is_object($aItem)) { // cn: bug 5349
1552                 //add item id to merge list, if the button is clicked
1553                 $mergeList[] = $aItem->id;
1554                 if(empty($module)) {
1555                     $module = $aItem->module_dir;
1556                 }
1557             }
1558             //ADD OFFSET TO ARRAY
1559
1560                 $fields['OFFSET'] = ($offset + $count + 1);
1561
1562             $fields['STAMP'] = $timeStamp;
1563             if($this->shouldProcess) {
1564
1565             $prerow = '';
1566             if(!isset($this->data_array)) {
1567                 $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "'>";
1568             }
1569             $this->xTemplate->assign('PREROW', $prerow);
1570
1571             $this->xTemplate->assign('CHECKALL', "<input type='checkbox' class='checkbox'  title='".$GLOBALS['app_strings']['LBL_SELECT_ALL_TITLE']."'  name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked)'>");
1572             }
1573             if(!isset($this->data_array)) {
1574                 $tag = $aItem->listviewACLHelper();
1575                 $this->xTemplate->assign('TAG',$tag) ;
1576             }
1577
1578             if($oddRow)
1579             {
1580                 $ROW_COLOR = 'oddListRow';
1581                 $BG_COLOR =  $odd_bg;
1582             }
1583             else
1584             {
1585                 $ROW_COLOR = 'evenListRow';
1586                 $BG_COLOR =  $even_bg;
1587             }
1588             $oddRow = !$oddRow;
1589
1590             $this->xTemplate->assign('ROW_COLOR', $ROW_COLOR);
1591             $this->xTemplate->assign('BG_COLOR', $BG_COLOR);
1592
1593             if(isset($this->data_array))
1594             {
1595                 $this->xTemplate->assign('KEY', $aVal);
1596                 $this->xTemplate->assign('VALUE', $aItem);
1597                 $this->xTemplate->assign('INDEX', $count);
1598
1599             }
1600             else
1601             {
1602     //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
1603     // Bug #2786
1604                 if($this->_additionalDetails && $aItem->ACLAccess('DetailView') && (file_exists('modules/' . $aItem->module_dir . '/metadata/additionalDetails.php') || file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php'))) {
1605
1606                     $additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
1607                     if(file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')){
1608                         $additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
1609                     }
1610
1611                     require_once($additionalDetailsFile);
1612                     $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name;
1613                     $results = $ad_function($fields);
1614                     $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
1615
1616                     if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
1617                     $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']].'</a>';
1618                 }
1619
1620                 if($aItem->ACLAccess('Delete')) {
1621                     $delete = '<a class="listViewTdToolsS1" onclick="return confirm(\''.$this->local_app_strings['NTC_DELETE_CONFIRMATION'].'\')" href="'.'index.php?action=Delete&module='.$aItem->module_dir.'&record='.$fields['ID'].'&return_module='.$aItem->module_dir.'&return_action=index&return_id=">'.$this->local_app_strings['LBL_DELETE_INLINE'].'</a>';
1622                     require_once('include/Smarty/plugins/function.sugar_action_menu.php');
1623                     $fields['DELETE_BUTTON'] = smarty_function_sugar_action_menu(array(
1624                         'id' => $aItem->module_dir.'_'.$fields['ID'].'_create_button',
1625                         'buttons' => array($delete),
1626                     ), $this);
1627
1628                 }
1629
1630                 $this->xTemplate->assign($html_varName, $fields);
1631                 $aItem->setupCustomFields($aItem->module_dir);
1632                 $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
1633             }
1634             if(!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
1635                 $count++;
1636             }
1637             if(isset($this->data_array)) {
1638                 $count++;
1639             }
1640             if(!isset($this->data_array)) {
1641                 $aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection);
1642
1643                 if($this->xTemplate->exists($xtemplateSection.'.row.pro')) {
1644                     $this->xTemplate->parse($xtemplateSection.'.row.pro');
1645                 }
1646             }
1647             $this->xTemplate->parse($xtemplateSection . '.row');
1648
1649             if(isset($fields['ID'])) {
1650                 $associated_row_data[$fields['ID']] = $fields;
1651                 // Bug 38908: cleanup data for JS to avoid having &nbsp; shuffled around
1652                 foreach($fields as $key => $value) {
1653                     if($value == '&nbsp;') {
1654                         $associated_row_data[$fields['ID']][$key] = '';
1655                     }
1656                 }
1657             }
1658         }
1659
1660         $_SESSION['MAILMERGE_RECORDS'] = $mergeList;
1661         $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module;
1662         if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1663             $_SESSION['MAILMERGE_MODULE'] = $module;
1664         }
1665
1666         if($this->process_for_popups)
1667         {
1668             $json = getJSONobj();
1669             $is_show_fullname = showFullName() ? 1 : 0;
1670             $associated_javascript_data = '<script type="text/javascript">' . "\n"
1671                 //. '<!-- // associated javascript data generated by ListView' . "\n"
1672                 . 'var associated_javascript_data = '
1673                 . $json->encode($associated_row_data) . ";\n"
1674                 //. '-->' . "\n"
1675                 . 'var is_show_fullname = '
1676                 . $is_show_fullname . ";\n"
1677                 . '</script>';
1678             $this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data);
1679         }
1680
1681         $this->xTemplate->parse($xtemplateSection);
1682     }
1683
1684
1685     function getLayoutManager()
1686     {
1687         require_once('include/generic/LayoutManager.php');
1688         if($this->layout_manager == null)
1689         {
1690             $this->layout_manager = new LayoutManager();
1691         }
1692         return $this->layout_manager;
1693     }
1694
1695
1696     function process_dynamic_listview_header($source_module, $subpanel_def, $html_var = 'CELL')
1697     {
1698
1699
1700         $layout_manager = $this->getLayoutManager();
1701         $layout_manager->setAttribute('order_by_link',$this->processOrderBy($html_var));
1702         $layout_manager->setAttribute('context','HeaderCell');
1703         $layout_manager->setAttribute('image_path',$this->local_image_path);
1704         $layout_manager->setAttribute('html_varName',$html_var);
1705         $layout_manager->setAttribute('module_name', $source_module);
1706         list($orderBy,$desc) = $this->getOrderByInfo($html_var);
1707
1708         if($orderBy == 'amount*1')
1709         {
1710             $orderBy=  'amount';
1711         }
1712                 $buttons = false;
1713         foreach($subpanel_def->get_list_fields() as $column_name=>$widget_args)
1714         {
1715             $usage = empty($widget_args['usage']) ? '' : $widget_args['usage'];
1716             if($usage != 'query_only' || !empty($widget_args['force_query_only_display']))
1717             {
1718                 $imgArrow = '';
1719
1720                 if($orderBy == $column_name || (isset($widget_args['sort_by']) && str_replace('.','_',$widget_args['sort_by']) == $orderBy))
1721                 {
1722                     $imgArrow = "_down";
1723                     if($this->sort_order == 'asc') {
1724                         $imgArrow = "_up";
1725                     }
1726                 }
1727
1728                 if (!preg_match("/_button/i", $column_name)) {
1729                         $widget_args['name']=$column_name;
1730                         $widget_args['sort'] = $imgArrow;
1731                         $widget_args['start_link_wrapper'] = $this->start_link_wrapper;
1732                         $widget_args['end_link_wrapper'] = $this->end_link_wrapper;
1733                         $widget_args['subpanel_module'] = $this->subpanel_module;
1734
1735                         $widget_contents = $layout_manager->widgetDisplay($widget_args);
1736                         $cell_width = empty($widget_args['width']) ? '' : $widget_args['width'];
1737                         $this->xTemplate->assign('HEADER_CELL', $widget_contents);
1738                         static $count;
1739                     if(!isset($count))$count = 0; else $count++;
1740                         $this->xTemplate->assign('CELL_COUNT', $count);
1741                         $this->xTemplate->assign('CELL_WIDTH', $cell_width);
1742                         $this->xTemplate->parse('dyn_list_view.header_cell');
1743                 } else {
1744                         $buttons = true;
1745                 }
1746             }
1747         }
1748
1749         if($buttons) {
1750                                 $this->xTemplate->assign('HEADER_CELL', "&nbsp;");
1751                                 $this->xTemplate->assign('CELL_COUNT', $count);
1752                         $this->xTemplate->assign('CELL_WIDTH', $cell_width);
1753                         $this->xTemplate->parse('dyn_list_view.header_cell');
1754         }
1755
1756     }
1757
1758
1759     /**
1760     * @return void
1761     * @param unknown $seed
1762     * @param unknown $xTemplateSection
1763     * @param unknown $html_varName
1764     * @desc PUBLIC FUNCTION Handles List Views using seeds that extend SugarBean
1765         $XTemplateSection is the section in the XTemplate file that should be parsed usually main
1766         $html_VarName is the variable name used in the XTemplateFile e.g. TASK
1767         $seed is a seed there are two types of seeds one is a subclass of SugarBean, the other is a list usually created from a sugar bean using get_list
1768         if no XTemplate is set it will create  a new XTemplate
1769         * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
1770         * All Rights Reserved..
1771         * Contributor(s): ______________________________________..
1772     */
1773
1774     function processListViewTwo($seed, $xTemplateSection, $html_varName) {
1775         global $current_user;
1776         if(!isset($this->xTemplate)) {
1777             $this->createXTemplate();
1778         }
1779
1780         $isSugarBean = is_subclass_of($seed, "SugarBean");
1781         $list = null;
1782
1783         if($isSugarBean) {
1784             $list = $this->processSugarBean($xTemplateSection, $html_varName, $seed);
1785         } else {
1786             $list = $seed;
1787         }
1788
1789         if (is_object($seed) && isset($seed->object_name) && $seed->object_name == 'WorkFlow') {
1790             $tab=array();
1791             $access = get_workflow_admin_modules_for_user($current_user);
1792             for ($i = 0; $i < count($list); $i++) {
1793                 if(!empty($access[$list[$i]->base_module])){
1794                     $tab[]=$list[$i];
1795                 }
1796             }
1797             $list = $tab;
1798         }
1799
1800         if($this->is_dynamic) {
1801             $this->processHeaderDynamic($xTemplateSection,$html_varName);
1802             $this->processListRows($list,$xTemplateSection, $html_varName);
1803         } else {
1804             $this->processSortArrows($html_varName);
1805
1806             if($isSugarBean) {
1807                 $seed->parse_additional_headers($this->xTemplate, $xTemplateSection);
1808             }
1809             $this->xTemplateAssign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", ''));
1810
1811             // Process the  order by before processing the pro_nav.  The pro_nav requires the order by values to be set
1812             $this->processOrderBy($html_varName);
1813
1814
1815             $this->processListRows($list,$xTemplateSection, $html_varName);
1816         }
1817
1818         if($this->display_header_and_footer) {
1819             $this->getAdditionalHeader();
1820             if(!empty($this->header_title)) {
1821                 echo get_form_header($this->header_title, $this->header_text, false);
1822             }
1823         }
1824
1825         $this->xTemplate->out($xTemplateSection);
1826
1827         if(isset($_SESSION['validation'])) {
1828             print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg==');
1829         }
1830     }
1831
1832     function getArrowStart() {
1833         $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif"));
1834
1835         return "&nbsp;<!--not_in_theme!--><img border='0' src='".$imgFileParts['dirname']."/".$imgFileParts['filename']."";
1836     }
1837
1838     function getArrowUpDownStart($upDown) {
1839         $ext = ( SugarThemeRegistry::current()->pngSupport ? "png" : "gif" );
1840
1841         if (!isset($upDown) || empty($upDown)) {
1842             $upDown = "";
1843         }
1844         return "&nbsp;<img border='0' src='".SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.{$ext}")."' ";
1845     }
1846
1847         function getArrowEnd() {
1848                 $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif"));
1849
1850         list($width,$height) = ListView::getArrowImageSize();
1851
1852                 return '.'.$imgFileParts['extension']."' width='$width' height='$height' align='absmiddle' alt=".translate('LBL_SORT').">";
1853     }
1854
1855     function getArrowUpDownEnd($upDown) {
1856         if (!isset($upDown) || empty($upDown)) {
1857             $upDown = "";
1858         }
1859         $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif"));
1860
1861         list($width,$height) = ListView::getArrowUpDownImageSize($upDown);
1862
1863         //get the right alt tag for the sort
1864         $sortStr = translate('LBL_ALT_SORT');
1865         if($upDown == '_down'){
1866             $sortStr = translate('LBL_ALT_SORT_DESC');
1867         }elseif($upDown == '_up'){
1868             $sortStr = translate('LBL_ALT_SORT_ASC');
1869         }
1870         return " width='$width' height='$height' align='absmiddle' alt='$sortStr'>";
1871     }
1872
1873         function getArrowImageSize() {
1874             // jbasicChartDashletsExpColust get the non-sort image's size.. the up and down have be the same.
1875                 $image = SugarThemeRegistry::current()->getImageURL("arrow.gif",false);
1876
1877         $cache_key = 'arrow_size.'.$image;
1878
1879         // Check the cache
1880         $result = sugar_cache_retrieve($cache_key);
1881         if(!empty($result))
1882         return $result;
1883
1884         // No cache hit.  Calculate the value and return.
1885         $result = getimagesize($image);
1886         sugar_cache_put($cache_key, $result);
1887         return $result;
1888     }
1889
1890     function getArrowUpDownImageSize($upDown) {
1891         // just get the non-sort image's size.. the up and down have be the same.
1892         $image = SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif",false);
1893
1894         $cache_key = 'arrowupdown_size.'.$image;
1895
1896         // Check the cache
1897         $result = sugar_cache_retrieve($cache_key);
1898         if(!empty($result))
1899         return $result;
1900
1901         // No cache hit.  Calculate the value and return.
1902         $result = getimagesize($image);
1903         sugar_cache_put($cache_key, $result);
1904         return $result;
1905     }
1906
1907         function getOrderByInfo($html_varName)
1908         {
1909                 $orderBy = $this->getSessionVariable($html_varName, "OBL");
1910                 $desc = $this->getSessionVariable($html_varName, $orderBy.'S');
1911                 $orderBy = str_replace('.', '_', $orderBy);
1912                 return array($orderBy,$desc);
1913         }
1914
1915     function processSortArrows($html_varName)
1916     {
1917
1918         $this->xTemplateAssign("arrow_start", $this->getArrowStart());
1919
1920         list($orderBy,$desc) = $this->getOrderByInfo($html_varName);
1921
1922                 $imgArrow = "_up";
1923                 if($desc) {
1924                         $imgArrow = "_down";
1925                 }
1926                 /**
1927                  * @deprecated only used by legacy opportunites listview, nothing current. Leaving for BC
1928                  */
1929                 if($orderBy == 'amount')
1930                 {
1931                         $this->xTemplateAssign('amount_arrow', $imgArrow);
1932                 }
1933                 else if($orderBy == 'amount_usdollar')
1934                 {
1935                         $this->xTemplateAssign('amount_usdollar_arrow', $imgArrow);
1936                 }
1937                 else
1938                 {
1939                         $this->xTemplateAssign($orderBy.'_arrow', $imgArrow);
1940                 }
1941
1942         $this->xTemplateAssign('arrow_end', $this->getArrowEnd());
1943     }
1944
1945     // this is where translation happens for dynamic list views
1946     function loadListFieldDefs(&$subpanel_fields,&$child_focus)
1947     {
1948         $this->list_field_defs = $subpanel_fields;
1949
1950         for($i=0;$i < count($this->list_field_defs);$i++)
1951         {
1952             $list_field = $this->list_field_defs[$i];
1953             $field_def = null;
1954             $key = '';
1955             if(!empty($list_field['vname']))
1956             {
1957                 $key = $list_field['vname'];
1958             } else if(isset($list_field['name']) &&  isset($child_focus->field_defs[$list_field['name']]))
1959             {
1960                     $field_def = $child_focus->field_defs[$list_field['name']];
1961                     $key = $field_def['vname'];
1962             }
1963             if(!empty($key))
1964             {
1965                 $list_field['label'] = translate($key,$child_focus->module_dir);
1966                 $this->list_field_defs[$i]['label'] = preg_replace('/:$/','',$list_field['label']);
1967             }
1968             else
1969             {
1970                 $this->list_field_defs[$i]['label'] ='&nbsp;';
1971             }
1972         }
1973     }
1974
1975     function unique_id() {
1976         return sugar_microtime();
1977     }
1978
1979      /**INTERNAL FUNCTION sets a session variable keeping it local to the listview
1980      not the current_module
1981      * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1982      * All Rights Reserved.
1983      * Contributor(s): ______________________________________.
1984      */
1985      function setLocalSessionVariable($localVarName,$varName, $value) {
1986         $_SESSION[$localVarName."_".$varName] = $value;
1987      }
1988
1989      /**INTERNAL FUNCTION returns a session variable that is local to the listview,
1990      not the current_module
1991      * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1992      * All Rights Reserved.
1993      * Contributor(s): ______________________________________.
1994      */
1995  function getLocalSessionVariable($localVarName,$varName) {
1996     if(isset($_SESSION[$localVarName."_".$varName])) {
1997         return $_SESSION[$localVarName."_".$varName];
1998     }
1999     else{
2000         return "";
2001     }
2002  }
2003
2004  /* Set to true if you want Additional Details to appear in the listview
2005   */
2006  function setAdditionalDetails($value = true, $function = '') {
2007     if(!empty($function)) $this->additionalDetailsFunction = $function;
2008     $this->_additionalDetails = $value;
2009  }
2010
2011 }
2012 ?>