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-2011 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
38 require_once('include/EditView/SugarVCR.php');
40 * ListView - list of many objects
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;
69 var $is_dynamic = false;
71 var $start_link_wrapper = '';
72 var $end_link_wrapper = '';
73 var $list_field_defs = array();
75 var $shouldProcess = false;
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;
85 var $force_mass_update=false;
86 var $keep_mass_update_form_open=false;
87 var $ignorePopulateOnly = false;
89 function setDataArray($value) {
90 $this->data_array = $value;
93 function processListViewMulti($seed, $xTemplateSection, $html_varName) {
95 $this->shouldProcess = true;
97 echo "<form name='MassUpdate' method='post' action='index.php'>";
98 $this->processListViewTwo($seed, $xTemplateSection, $html_varName);
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>";
105 function processListView($seed, $xTemplateSection, $html_varName)
107 global $sugar_config;
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'] ;
116 if(strcmp(strtolower($_REQUEST['action']), 'popup') != 0){
117 $_SESSION['last_search_mod'] = $_REQUEST['module'] ;
119 //following session variable will track the detail view nvigation history.
120 //needs to the reset after each search.
121 $this->setLocalSessionVariable($html_varName,"DETAIL_NAV_HISTORY",false);
123 require_once('include/MassUpdate.php');
124 $mass = new MassUpdate();
125 $add_acl_javascript = false;
126 if(!isset($_REQUEST['action'])) {
127 $this->shouldProcess=false;
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);
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();
146 if(!ACLController::checkAccess($seed->module_dir,'export',true)) {
147 $sugar_config['disable_export']= true;
153 //force mass update form if requested.
154 if($this->force_mass_update) {
155 $this->shouldProcess = true;
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);
163 //C.L. Fix for 10048, do not process handleMassUpdate for multi select popups
164 if(!$this->multi_select_popup) {
165 $mass->handleMassUpdate();
169 $this->processListViewTwo($seed,$xTemplateSection, $html_varName);
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();
177 if(!$this->keep_mass_update_form_open) {
178 echo $mass->endMassUpdateForm();
184 function process_dynamic_listview($source_module, $sugarbean,$subpanel_def)
186 $this->source_module = $source_module;
187 $this->subpanel_module = $subpanel_def->name;
188 if(!isset($this->xTemplate))
189 $this->createXTemplate();
191 $html_var = $this->subpanel_module . "_CELL";
193 $list_data = $this->processUnionBeans($sugarbean,$subpanel_def, $html_var);
195 $list = $list_data['list'];
196 $parent_data = $list_data['parent_data'];
198 if($subpanel_def->isCollection()) {
199 $thepanel=$subpanel_def->get_header_panel_def();
201 $thepanel=$subpanel_def;
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);
209 if($this->display_header_and_footer)
211 $this->getAdditionalHeader();
212 if(!empty($this->header_title))
214 echo get_form_header($this->header_title, $this->header_text, false);
218 $this->xTemplate->out('dyn_list_view');
220 if(isset($_SESSION['validation']))
222 print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg==');
224 if(isset($list_data['query'])) {
225 return ($list_data['query']);
231 * @param unknown $data
232 * @param unknown $xTemplateSection
233 * @param unknown $html_varName
234 * @desc INTERNAL FUNCTION handles the rows
236 function process_dynamic_listview_rows($data,$parent_data, $xtemplateSection, $html_varName, $subpanel_def)
243 $this->xTemplate->assign("BG_HILITE", $hilite_bg);
244 $this->xTemplate->assign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", ''));
245 //$this->xTemplate->assign("BG_CLICK", $click_bg);
251 $offset = $this->getOffset($html_varName);
253 $processed_ids = array();
255 $fill_additional_fields = array();
256 //Either retrieve the is_fill_in_additional_fields property from the lone
257 //subpanel or visit each subpanel's subpanels to retreive the is_fill_in_addition_fields
259 $subpanel_list=array();
260 if($subpanel_def->isCollection()) {
261 $subpanel_list=$subpanel_def->sub_subpanels;
263 $subpanel_list[]= $subpanel_def;
266 foreach($subpanel_list as $this_subpanel)
268 if($this_subpanel->is_fill_in_additional_fields())
270 $fill_additional_fields[] = $this_subpanel->bean_name;
271 $fill_additional_fields[$this_subpanel->bean_name] = true;
275 if ( empty($data) ) {
276 $this->xTemplate->assign("ROW_COLOR", 'oddListRow');
277 $thepanel=$subpanel_def;
278 if($subpanel_def->isCollection())
279 $thepanel=$subpanel_def->get_header_panel_def();
280 $this->xTemplate->assign("COL_COUNT", count($thepanel->get_list_fields()));
281 $this->xTemplate->parse($xtemplateSection.".nodata");
284 while(list($aVal, $aItem) = each($data))
286 $aItem->check_date_relationships_load();
287 // TODO: expensive and needs to be removed and done better elsewhere
289 if(!empty($fill_additional_fields[$aItem->object_name])
290 || ($aItem->object_name == 'Case' && !empty($fill_additional_fields['aCase']))
293 $aItem->fill_in_additional_list_fields();
294 //$aItem->fill_in_additional_detail_fields();
297 $aItem->call_custom_logic("process_record");
299 if(isset($parent_data[$aItem->id])) {
301 $aItem->parent_name = $parent_data[$aItem->id]['parent_name'];
302 if(!empty($parent_data[$aItem->id]['parent_name_owner'])) {
303 $aItem->parent_name_owner = $parent_data[$aItem->id]['parent_name_owner'];
304 $aItem->parent_name_mod = $parent_data[$aItem->id]['parent_name_mod'];
307 $fields = $aItem->get_list_view_data();
308 if(isset($processed_ids[$aItem->id])) {
312 $processed_ids[$aItem->id] = 1;
316 //ADD OFFSET TO ARRAY
317 $fields['OFFSET'] = ($offset + $count + 1);
319 if($this->shouldProcess) {
320 if($aItem->ACLAccess('EditView')) {
321 $this->xTemplate->assign('PREROW', "<input type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "' />");
323 $this->xTemplate->assign('PREROW', '');
326 if($aItem->ACLAccess('DetailView')) {
327 $this->xTemplate->assign('TAG_NAME','a');
329 $this->xTemplate->assign('TAG_NAME','span');
331 $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);' />");
336 $ROW_COLOR = 'oddListRow';
341 $ROW_COLOR = 'evenListRow';
342 $BG_COLOR = $even_bg;
346 $this->xTemplate->assign("ROW_COLOR", $ROW_COLOR);
347 $this->xTemplate->assign("BG_COLOR", $BG_COLOR);
348 $layout_manager = $this->getLayoutManager();
349 $layout_manager->setAttribute('context','List');
350 $layout_manager->setAttribute('image_path',$this->local_image_path);
351 $layout_manager->setAttribute('module_name', $subpanel_def->_instance_properties['module']);
352 if(!empty($this->child_focus))
353 $layout_manager->setAttribute('related_module_name',$this->child_focus->module_dir);
355 //AG$subpanel_data = $this->list_field_defs;
356 //$bla = array_pop($subpanel_data);
357 //select which sub-panel to display here, the decision will be made based on the type of
358 //the sub-panel and panel in the bean being processed.
359 if($subpanel_def->isCollection()) {
360 $thepanel=$subpanel_def->sub_subpanels[$aItem->panel_name];
362 $thepanel=$subpanel_def;
364 //get data source name
365 $linked_field=$thepanel->get_data_source_name();
366 $linked_field_set=$thepanel->get_data_source_name(true);
367 foreach($thepanel->get_list_fields() as $field_name=>$list_field)
369 //add linked field attribute to the array.
370 $list_field['linked_field']=$linked_field;
371 $list_field['linked_field_set']=$linked_field_set;
373 $usage = empty($list_field['usage']) ? '' : $list_field['usage'];
374 if($usage != 'query_only')
376 $list_field['name']=$field_name;
378 $module_field = $field_name.'_mod';
379 $owner_field = $field_name.'_owner';
380 if(!empty($aItem->$module_field)) {
382 $list_field['owner_id'] = $aItem->$owner_field;
383 $list_field['owner_module'] = $aItem->$module_field;
386 $list_field['owner_id'] = false;
387 $list_field['owner_module'] = false;
389 if(isset($list_field['alias'])) $list_field['name'] = $list_field['alias'];
390 else $list_field['name']=$field_name;
391 $list_field['fields'] = $fields;
392 $list_field['module'] = $aItem->module_dir;
393 $list_field['start_link_wrapper'] = $this->start_link_wrapper;
394 $list_field['end_link_wrapper'] = $this->end_link_wrapper;
395 $list_field['subpanel_id'] = $this->subpanel_id;
396 $list_field['DetailView'] = $aItem->ACLAccess('DetailView');
397 $list_field['ListView'] = $aItem->ACLAccess('ListView');
398 $list_field['EditView'] = $aItem->ACLAccess('EditView');
399 $list_field['Delete'] = $aItem->ACLAccess('Delete');
400 if ( isset($aItem->field_defs[strtolower($list_field['name'])])) {
401 require_once('include/SugarFields/SugarFieldHandler.php');
402 // We need to see if a sugar field exists for this field type first,
403 // if it doesn't, toss it at the old sugarWidgets. This is for
404 // backwards compatibilty and will be removed in a future release
405 $vardef = $aItem->field_defs[strtolower($list_field['name'])];
406 if ( isset($vardef['type']) ) {
407 $fieldType = isset($vardef['custom_type'])?$vardef['custom_type']:$vardef['type'];
408 $tmpField = SugarFieldHandler::getSugarField($fieldType,true);
413 if ( $tmpField != NULL ) {
414 $widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'],$vardef,'ListView',$list_field);
416 // No SugarField for this particular type
417 // Use the old, icky, SugarWidget for now
418 $widget_contents = $layout_manager->widgetDisplay($list_field);
421 if ( isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink' ) {
422 // 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
423 // So we'll populate the field data with the pre-rendered display for the field
424 $list_field['fields'][$field_name] = $widget_contents;
425 if('full_name' == $field_name){//bug #32465
426 $list_field['fields'][strtoupper($field_name)] = $widget_contents;
428 $widget_contents = $layout_manager->widgetDisplay($list_field);
429 } else if(isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink' ) {
430 $widget_contents = $layout_manager->widgetDisplay($list_field);
433 // This handles the edit and remove buttons
434 $widget_contents = $layout_manager->widgetDisplay($list_field);
437 if(!isset($count))$count = 0; else $count++;
438 $this->xTemplate->assign('CELL_COUNT', $count);
439 if ( empty($widget_contents) ) $widget_contents = ' ';
440 $this->xTemplate->assign('CELL', $widget_contents);
441 $this->xTemplate->parse($xtemplateSection.".row.cell");
445 $aItem->setupCustomFields($aItem->module_dir);
446 $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
450 $this->xTemplate->parse($xtemplateSection.".row");
453 $this->xTemplate->parse($xtemplateSection);
456 /**sets whether or not to display the xtemplate header and footer
457 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
458 * All Rights Reserved.
459 * Contributor(s): ______________________________________.
461 function setDisplayHeaderAndFooter($bool) {
462 $this->display_header_and_footer = $bool;
465 /**initializes ListView
466 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
467 * All Rights Reserved.
468 * Contributor(s): ______________________________________.
470 function ListView() {
473 if(!$this->initialized) {
474 global $sugar_config;
475 $this->records_per_page = $sugar_config['list_max_entries_per_page'] + 0;
476 $this->initialized = true;
477 global $app_strings, $currentModule;
478 $this->local_theme = SugarThemeRegistry::current()->__toString();
479 $this->local_app_strings =$app_strings;
480 $this->local_image_path = SugarThemeRegistry::current()->getImagePath();
481 $this->local_current_module = $currentModule;
484 /**sets how many records should be displayed per page in the list view
485 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
486 * All Rights Reserved.
487 * Contributor(s): ______________________________________.
489 function setRecordsPerPage($count) {
490 $this->records_per_page = $count;
492 /**sets the header title */
493 function setHeaderTitle($value) {
494 $this->header_title = $value;
496 /**sets the header text this is text thats appended to the header table and is usually used for the creation of buttons
497 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
498 * All Rights Reserved.
499 * Contributor(s): ______________________________________.
501 function setHeaderText($value) {
502 $this->header_text = $value;
504 /**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
505 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
506 * All Rights Reserved.
507 * Contributor(s): ______________________________________.
509 function setXTemplatePath($value) {
510 $this->xTemplatePath= $value;
513 /**this is a helper function for allowing ListView to create a new XTemplate it groups parameters that should be set into a single function
514 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
515 * All Rights Reserved.
516 * Contributor(s): ______________________________________.
518 function initNewXTemplate($XTemplatePath, $modString, $imagePath = null) {
519 $this->setXTemplatePath($XTemplatePath);
520 if(isset($modString))
521 $this->setModStrings($modString);
522 if(isset($imagePath))
523 $this->setImagePath($imagePath);
527 function getOrderBy($varName, $defaultOrderBy='', $force_sortorder='') {
528 $sortBy = $this->getSessionVariable($varName, "ORDER_BY") ;
531 $this->setUserVariable($varName, "ORDER_BY", $defaultOrderBy);
532 $sortBy = $defaultOrderBy;
534 $this->setUserVariable($varName, "ORDER_BY", $sortBy);
536 if($sortBy == 'amount') {
537 $sortBy = 'amount*1';
539 if($sortBy == 'amount_usdollar') {
540 $sortBy = 'amount_usdollar*1';
543 $desc = $this->getSessionVariable($varName, $sortBy."S");
547 if(isset($_REQUEST[$this->getSessionVariableName($varName, "ORDER_BY")]))
548 $last = $this->getSessionVariable($varName, "OBL");
549 if(!empty($last) && $last == $sortBy) {
552 $this->setSessionVariable($varName, "OBL", $sortBy);
554 $this->setSessionVariable($varName, $sortBy."S", $desc);
555 if(!empty($sortBy)) {
556 if(empty($force_sortorder)) {
557 if(substr_count(strtolower($sortBy), ' desc') == 0 && substr_count(strtolower($sortBy), ' asc') == 0) {
559 $this->query_orderby = $sortBy.' desc';
561 $this->query_orderby = $sortBy.' asc';
566 $this->query_orderby = $sortBy . ' ' . $force_sortorder;
569 $this->query_orderby = "";
571 $this->sortby = $sortBy;
572 return $this->query_orderby;
577 /**sets the parameters dealing with the db
578 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
579 * All Rights Reserved.
580 * Contributor(s): ______________________________________.
582 function setQuery($where, $limit, $orderBy, $varName, $allowOrderByOveride=true) {
583 $this->query_where = $where;
584 if($this->getSessionVariable("query", "where") != $where) {
585 $this->query_where_has_changed = true;
586 $this->setSessionVariable("query", "where", $where);
589 $this->query_limit = $limit;
590 if(!$allowOrderByOveride) {
591 $this->query_orderby = $orderBy;
594 $this->getOrderBy($varName, $orderBy);
596 $this->setLocalSessionVariable($varName, "QUERY_WHERE", $where);
598 //SETTING ORDER_BY FOR USE IN DETAILVIEW
599 $this->setLocalSessionVariable($varName, "ORDER_BY_DETAIL", $this->query_orderby);
602 function displayArrow() {
606 /**sets the theme used only use if it is different from the global
607 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
608 * All Rights Reserved.
609 * Contributor(s): ______________________________________.
611 function setTheme($theme) {
612 $this->local_theme = $theme;
613 if(isset($this->xTemplate))$this->xTemplate->assign("THEME", $this->local_theme);
616 /**sets the AppStrings used only use if it is different from the global
617 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
618 * All Rights Reserved.
619 * Contributor(s): ______________________________________.
621 function setAppStrings($app_strings) {
622 unset($this->local_app_strings);
623 $this->local_app_strings = $app_strings;
624 if(isset($this->xTemplate))$this->xTemplate->assign("APP", $this->local_app_strings);
627 /**sets the ModStrings used
628 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
629 * All Rights Reserved.
630 * Contributor(s): ______________________________________.
632 function setModStrings($mod_strings) {
633 unset($this->local_module_strings);
634 $this->local_mod_strings = $mod_strings;
635 if(isset($this->xTemplate))$this->xTemplate->assign("MOD", $this->local_mod_strings);
638 /**sets the ImagePath used
639 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
640 * All Rights Reserved.
641 * Contributor(s): ______________________________________.
643 function setImagePath($image_path) {
644 $this->local_image_path = $image_path;
645 if(empty($this->local_image_path)) {
646 $this->local_image_path = SugarThemeRegistry::get($this->local_theme)->getImagePath();
648 if(isset($this->xTemplate))$this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
651 /**sets the currentModule only use if this is different from the global
652 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
653 * All Rights Reserved.
654 * Contributor(s): ______________________________________.
656 function setCurrentModule($currentModule) {
657 unset($this->local_current_module);
658 $this->local_current_module = $currentModule;
659 if(isset($this->xTemplate))$this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
662 /**INTERNAL FUNCTION creates an XTemplate DO NOT CALL THIS THIS IS AN INTERNAL FUNCTION
663 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
664 * All Rights Reserved.
665 * Contributor(s): ______________________________________.
667 function createXTemplate() {
668 if(!isset($this->xTemplate)) {
669 if(isset($this->xTemplatePath)) {
671 $this->xTemplate = new XTemplate($this->xTemplatePath);
672 $this->xTemplate->assign("APP", $this->local_app_strings);
673 if(isset($this->local_mod_strings))$this->xTemplate->assign("MOD", $this->local_mod_strings);
674 $this->xTemplate->assign("THEME", $this->local_theme);
675 $this->xTemplate->assign("IMAGE_PATH", $this->local_image_path);
676 $this->xTemplate->assign("MODULE_NAME", $this->local_current_module);
678 $GLOBALS['log']->error("NO XTEMPLATEPATH DEFINED CANNOT CREATE XTEMPLATE");
683 /**sets the XTemplate telling ListView to use newXTemplate as its current XTemplate
684 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
685 * All Rights Reserved.
686 * Contributor(s): ______________________________________.
688 function setXTemplate($newXTemplate) {
689 $this->xTemplate = $newXTemplate;
692 /**returns the XTemplate
693 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
694 * All Rights Reserved.
695 * Contributor(s): ______________________________________.
697 function getXTemplate() {
698 return $this->xTemplate;
701 /**assigns a name value pair to the XTemplate
702 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
703 * All Rights Reserved.
704 * Contributor(s): ______________________________________.
706 function xTemplateAssign($name, $value) {
708 if(!isset($this->xTemplate)) {
709 $this->createXTemplate();
711 $this->xTemplate->assign($name, $value);
715 /**INTERNAL FUNCTION returns the offset first checking the querey then checking the session if the where clause has changed from the last time it returns 0
716 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
717 * All Rights Reserved.
718 * Contributor(s): ______________________________________.
720 function getOffset($localVarName) {
721 if($this->query_where_has_changed || isset($GLOBALS['record_has_changed'])) {
722 $this->setSessionVariable($localVarName,"offset", 0);
724 $offset = $this->getSessionVariable($localVarName,"offset");
731 /**INTERNAL FUNCTION sets the offset in the session
732 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
733 * All Rights Reserved.
734 * Contributor(s): ______________________________________.
736 function setOffset($localVarName, $value) {
737 $this->setSessionVariable($localVarName, "offset", $value);
740 /**INTERNAL FUNCTION sets a session variable
741 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
742 * All Rights Reserved.
743 * Contributor(s): ______________________________________.
745 function setSessionVariable($localVarName,$varName, $value) {
746 $_SESSION[$this->local_current_module."_".$localVarName."_".$varName] = $value;
749 function setUserVariable($localVarName,$varName, $value) {
750 if($this->is_dynamic || $localVarName == 'CELL')return;
751 global $current_user;
752 $current_user->setPreference($this->local_current_module."_".$localVarName."_".$varName, $value);
755 /**INTERNAL FUNCTION returns a session variable first checking the querey for it then checking the session
756 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
757 * All Rights Reserved.
758 * Contributor(s): ______________________________________.
760 function getSessionVariable($localVarName,$varName) {
761 //Set any variables pass in through request first
762 if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
763 $this->setSessionVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
766 if(isset($_SESSION[$this->getSessionVariableName($localVarName, $varName)])) {
767 return $_SESSION[$this->getSessionVariableName($localVarName, $varName)];
772 function getUserVariable($localVarName, $varName) {
773 global $current_user;
774 if($this->is_dynamic || $localVarName == 'CELL')return;
775 if(isset($_REQUEST[$this->getSessionVariableName($localVarName, $varName)])) {
777 $this->setUserVariable($localVarName,$varName,$_REQUEST[$this->getSessionVariableName($localVarName, $varName)]);
779 return $current_user->getPreference($this->getSessionVariableName($localVarName, $varName));
789 * @param unknown $localVarName
790 * @param unknown $varName
791 * @desc INTERNAL FUNCTION returns the session/query variable name
792 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
793 * All Rights Reserved.
794 * Contributor(s): ______________________________________..
796 function getSessionVariableName($localVarName,$varName) {
797 return $this->local_current_module."_".$localVarName."_".$varName;
803 * @param unknown $seed
804 * @param unknown $xTemplateSection
805 * @param unknown $html_varName
806 * @desc INTERNAL FUNCTION Handles List Views using seeds that extend SugarBean
807 $XTemplateSection is the section in the XTemplate file that should be parsed usually main
808 $html_VarName is the variable name used in the XTemplateFile e.g. TASK
809 $seed is a seed that extends SugarBean
810 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
811 * All Rights Reserved..
812 * Contributor(s): ______________________________________..
814 function processSugarBean($xtemplateSection, $html_varName, $seed) {
815 global $list_view_row_count;
817 $current_offset = $this->getOffset($html_varName);
821 SugarVCR::erase($seed->module_dir);
823 //$filter = array('id', 'full_name');
825 $ret_array = $seed->create_new_list_query($this->query_orderby, $this->query_where, $filter, $params, 0, '', true, $seed, true);
826 if(!is_array($params)) $params = array();
827 if(!isset($params['custom_select'])) $params['custom_select'] = '';
828 if(!isset($params['custom_from'])) $params['custom_from'] = '';
829 if(!isset($params['custom_where'])) $params['custom_where'] = '';
830 if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
831 $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'];
832 SugarVCR::store($seed->module_dir, $main_query);
835 if(empty($this->related_field_name)) {
836 $response = $seed->get_list($this->query_orderby, $this->query_where, $current_offset, $this->query_limit);
838 $related_field_name = $this->related_field_name;
839 $response = $seed->get_related_list($this->child_focus,$related_field_name, $this->query_orderby,
840 $this->query_where, $current_offset, $this->query_limit);
843 $list = $response['list'];
844 $row_count = $response['row_count'];
845 $next_offset = $response['next_offset'];
846 $previous_offset = $response['previous_offset'];
848 if(!empty($response['current_offset'])) {
849 $current_offset = $response['current_offset'];
852 $list_view_row_count = $row_count;
853 $this->processListNavigation($xtemplateSection,$html_varName, $current_offset, $next_offset, $previous_offset, $row_count, null, null, empty($seed->column_fields) ? null : count($seed->column_fields));
858 function processUnionBeans($sugarbean, $subpanel_def, $html_var = 'CELL') {
860 $last_detailview_record = $this->getSessionVariable("detailview", "record");
861 if(!empty($last_detailview_record) && $last_detailview_record != $sugarbean->id){
862 $GLOBALS['record_has_changed'] = true;
864 $this->setSessionVariable("detailview", "record", $sugarbean->id);
866 $current_offset = $this->getOffset($html_var);
867 $module = isset($_REQUEST['module']) ? $_REQUEST['module'] : '';
870 $this->sort_order = 'asc';
871 if(isset($_REQUEST['sort_order'])) {
872 $this->sort_order = $_REQUEST['sort_order'];
874 if(isset($subpanel_def->_instance_properties['sort_order'])) {
875 $sort_order = $subpanel_def->_instance_properties['sort_order'];
878 if(isset($_SESSION['last_sub' .$this->subpanel_module. '_order'])) {
879 // We swap the order when the request contains an offset (indicating a column sort issued);
880 // otherwise we do not sort. If we don't make this check, then the subpanel listview will
881 // swap ordering each time a new record is entered via quick create forms
883 if(isset($_REQUEST[$module. '_' . $html_var . '_offset'])) {
884 $this->sort_order = $_SESSION['last_sub' .$this->subpanel_module. '_order'] == 'asc' ? 'desc' : 'asc';
886 $this->sort_order = $_SESSION['last_sub' .$this->subpanel_module. '_order'];
889 elseif(isset($sort_order)) {
890 $this->sort_order = $sort_order;
894 if (isset($subpanel_def->_instance_properties['sort_by'])) {
895 $this->query_orderby = $subpanel_def->_instance_properties['sort_by'];
897 $this->query_orderby = 'id';
900 $this->getOrderBy($html_var,$this->query_orderby, $this->sort_order);
902 $_SESSION['last_sub' .$this->subpanel_module. '_order'] = $this->sort_order;
903 $_SESSION['last_sub' .$this->subpanel_module. '_url'] = $this->getBaseURL($html_var);
905 // Bug 8139 - Correct Subpanel sorting on 'name', when subpanel sorting default is 'last_name, first_name'
906 if (($this->sortby == 'name' || $this->sortby == 'last_name') &&
907 str_replace(' ', '', trim($subpanel_def->_instance_properties['sort_by'])) == 'last_name,first_name') {
908 $this->sortby = 'last_name '.$this->sort_order.', first_name ';
911 if(!empty($this->response)){
912 $response =& $this->response;
915 $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1,-1,$this->query_limit,$subpanel_def);
916 $this->response =& $response;
918 $list = $response['list'];
919 $row_count = $response['row_count'];
920 $next_offset = $response['next_offset'];
921 $previous_offset = $response['previous_offset'];
922 if(!empty($response['current_offset']))$current_offset = $response['current_offset'];
923 global $list_view_row_count;
924 $list_view_row_count = $row_count;
925 $this->processListNavigation('dyn_list_view', $html_var, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean,$subpanel_def);
927 return array('list'=>$list, 'parent_data'=>$response['parent_data'], 'query'=>$response['query']);
930 function getBaseURL($html_varName) {
931 static $cache = array();
933 if(!empty($cache[$html_varName]))return $cache[$html_varName];
934 $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount','current_query_by_page');
935 if(!empty($this->base_URL)) {
936 return $this->base_URL;
939 $baseurl = $_SERVER['PHP_SELF'];
940 if(empty($baseurl)) {
941 $baseurl = 'index.php';
944 /*fixes an issue with deletes when doing a search*/
945 foreach(array_merge($_GET, $_POST) as $name=>$value) {
946 //echo ("$name = $value <br/>");
947 if(!empty($value) && $name != 'sort_order' //&& $name != ListView::getSessionVariableName($html_varName,"ORDER_BY")
948 && $name != ListView::getSessionVariableName($html_varName,"offset")
949 /*&& substr_count($name, "ORDER_BY")==0*/ && !in_array($name, $blockVariables))
951 if(is_array($value)) {
952 foreach($value as $valuename=>$valuevalue) {
953 if(substr_count($baseurl, '?') > 0)
954 $baseurl .= "&{$name}[]=".$valuevalue;
956 $baseurl .= "?{$name}[]=".$valuevalue;
959 $value = urlencode($value);
960 if(substr_count($baseurl, '?') > 0) {
961 $baseurl .= "&$name=$value";
963 $baseurl .= "?$name=$value";
970 if($_SERVER['REQUEST_METHOD'] == 'POST') {
971 // at this point it is possible that the above foreach already executed resulting in double ?'s in the url
972 if(substr_count($baseurl, '?') == 0) {
975 if(isset($_REQUEST['action'])) $baseurl.= '&action='.$_REQUEST['action'];
976 if(isset($_REQUEST['record'])) $baseurl .= '&record='.$_REQUEST['record'];
977 if(isset($_REQUEST['module'])) $baseurl .= '&module='.$_REQUEST['module'];
980 $baseurl .= "&".ListView::getSessionVariableName($html_varName,"offset")."=";
981 $cache[$html_varName] = $baseurl;
986 * @param unknown $data
987 * @param unknown $xTemplateSection
988 * @param unknown $html_varName
989 * @desc INTERNAL FUNCTION process the List Navigation
990 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
991 * All Rights Reserved.
992 * Contributor(s): ______________________________________..
994 function processListNavigation($xtemplateSection, $html_varName, $current_offset, $next_offset, $previous_offset, $row_count, $sugarbean=null, $subpanel_def=null, $col_count = 20) {
996 global $export_module;
997 global $sugar_config;
998 global $current_user;
999 global $currentModule;
1000 global $app_strings;
1002 $start_record = $current_offset + 1;
1004 if(!is_numeric($col_count))
1010 $end_record = $start_record + $this->records_per_page;
1011 // back up the the last page.
1012 if($end_record > $row_count+1) {
1013 $end_record = $row_count+1;
1015 // Deterime the start location of the last page
1019 $number_pages = floor(($row_count - 1) / $this->records_per_page);
1021 $last_offset = $number_pages * $this->records_per_page;
1023 if(empty($this->query_limit) || $this->query_limit > $this->records_per_page) {
1024 $this->base_URL = $this->getBaseURL($html_varName);
1027 if($this->is_dynamic) {
1028 $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;
1031 $current_URL = $this->base_URL.$current_offset.$dynamic_url;
1032 $start_URL = $this->base_URL."0".$dynamic_url;
1033 $previous_URL = $this->base_URL.$previous_offset.$dynamic_url;
1034 $next_URL = $this->base_URL.$next_offset.$dynamic_url;
1035 $end_URL = $this->base_URL.'end'.$dynamic_url;
1037 if(!empty($this->start_link_wrapper)) {
1038 $current_URL = $this->start_link_wrapper.$current_URL.$this->end_link_wrapper;
1039 $start_URL = $this->start_link_wrapper.$start_URL.$this->end_link_wrapper;
1040 $previous_URL = $this->start_link_wrapper.$previous_URL.$this->end_link_wrapper;
1041 $next_URL = $this->start_link_wrapper.$next_URL.$this->end_link_wrapper;
1042 $end_URL = $this->start_link_wrapper.$end_URL.$this->end_link_wrapper;
1045 $moduleString = "{$currentModule}_{$html_varName}_offset";
1046 $moduleStringOrder = "{$currentModule}_{$html_varName}_ORDER_BY";
1047 if($this->shouldProcess && !$this->multi_select_popup) {
1048 // check the checkboxes onload
1049 echo "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n";
1051 $massUpdateRun = isset($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true';
1052 $uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid'];
1053 $select_entire_list = isset($_REQUEST['select_entire_list']) && !$massUpdateRun ? $_REQUEST['select_entire_list'] : 0;
1055 echo "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" .
1056 "<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n".
1057 "<input type='hidden' name='{$moduleString}' value='0'>\n".
1058 "<input type='hidden' name='{$moduleStringOrder}' value='0'>\n";
1063 $GLOBALS['log']->debug("Offsets: (start, previous, next, last)(0, $previous_offset, $next_offset, $last_offset)");
1065 if(0 == $current_offset) {
1066 $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>";
1067 $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>";
1069 if($this->multi_select_popup) {// nav links for multiselect popup, submit form to save checks.
1070 $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>";
1071 $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>";
1072 } elseif($this->shouldProcess) {
1073 $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>";
1074 $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>";
1077 if(0 != preg_match('/javascript.*/', $start_URL)){
1078 $onClick = "\"$start_URL;\"";
1080 $onClick ="'location.href=\"$start_URL\";'";
1082 $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>";
1085 if(0 != preg_match('/javascript.*/', $previous_URL)){
1086 $onClick = "\"$previous_URL;\"";
1088 $onClick = "'location.href=\"$previous_URL\";'";
1090 $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>";
1094 if($last_offset <= $current_offset) {
1095 $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>";
1096 $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>";
1098 if($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks.
1099 $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>";
1100 if(!empty($sugar_config['disable_count_query'])) {
1103 $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>";
1104 } elseif($this->shouldProcess) {
1105 $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>";
1106 $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>";
1109 if(0 != preg_match('/javascript.*/', $next_URL)){
1110 $onClick = "\"$next_URL;\"";
1112 $onClick ="'location.href=\"$next_URL\";'";
1114 $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>";
1117 if(0 != preg_match('/javascript.*/', $end_URL)){
1118 $onClick = "\"$end_URL;\"";
1120 $onClick = "'location.href=\"$end_URL\";'";
1122 $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>";
1127 $GLOBALS['log']->info("Offset (next, current, prev)($next_offset, $current_offset, $previous_offset)");
1128 $GLOBALS['log']->info("Start/end records ($start_record, $end_record)");
1130 $end_record = $end_record-1;
1132 $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']} ({$this->records_per_page})‎</a>"
1133 . "<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']} ({$row_count})‎</a>"
1134 . "<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>";
1136 $close_inline_img = SugarThemeRegistry::current()->getImage('close_inline', 'border=0', null, null, ".gif", $app_strings['LBL_CLOSEINLINE']);
1139 function select_overlib() {
1140 return overlib('<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']} ({$this->records_per_page})‎</a>"
1141 . "<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']} ({$row_count})‎</a>"
1142 . "<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>"
1144 . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '" . SugarThemeRegistry::current()->getImage('close_inline', 'border=0', null, null, ".gif", $this->local_app_strings['LBL_CLOSEINLINE']) . "'"
1145 . ", WIDTH, 150, CLOSETITLE, '" . $this->local_app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', "
1146 . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass');
1150 if($this->show_select_menu)
1152 $select_link = "<a id='select_link' onclick='return select_overlib();' href=\"javascript:void(0)\">".$this->local_app_strings['LBL_LINK_SELECT']." ".SugarThemeRegistry::current()->getImage('MoreDetail', 'border=0', 11, 7, '.png', $app_strings['LBL_MOREDETAIL'])."</a>";
1154 $select_link = " ";
1157 // put overlib strings into functions to avoid backslash plague!
1158 $export_link = '<input class="button" type="button" value="'.$this->local_app_strings['LBL_EXPORT'].'" ' .
1159 'onclick="return sListView.send_form(true, \''.$_REQUEST['module'].'\', \'index.php?entryPoint=export\',\''.$this->local_app_strings['LBL_LISTVIEW_NO_SELECTED'].'\')">';
1161 if($this->show_delete_button) {
1162 $delete_link = '<input class="button" type="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)">';
1164 $delete_link = ' ';
1167 $admin = new Administration();
1168 $admin->retrieveSettings('system');
1170 $user_merge = $current_user->getPreference('mailmerge_on');
1171 if($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on']) {
1173 function mailmerge_overlib() {
1174 return overlib('<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>"
1175 . "<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>"
1176 . "<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>"
1177 . "', CAPTION, '" . $this->local_app_strings['LBL_MAILMERGE']
1178 . "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<!--not_in_theme!--><img border=0 style=\'margin-left:2px; margin-right: 2px;\' src=" . $this->local_image_path
1179 . "close.gif>', WIDTH, 150, CLOSETITLE, '" . $this->local_app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', "
1180 . "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');
1183 $merge_link = " | <a id='mailmerge_link' onclick='return mailmerge_overlib()'; href=\"javascript:void(0)\">".$this->local_app_strings['LBL_MAILMERGE']."</a>";
1185 $merge_link = " ";
1188 $selected_objects_span = " | {$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='" . (!empty($select_entire_list) ? $row_count : 0) . "' />";
1190 if($_REQUEST['module'] == 'Home' || $this->local_current_module == 'Import'
1191 || $this->show_export_button == false
1192 || (!empty($sugar_config['disable_export']))
1193 || (!empty($sugar_config['admin_export_only'])
1195 is_admin($current_user)
1196 || (ACLController::moduleSupportsACL($_REQUEST['module'])
1197 && ACLAction::getUserAccessLevel($current_user->id,$_REQUEST['module'], 'access') == ACL_ALLOW_ENABLED
1198 && (ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN ||
1199 ACLAction::getUserAccessLevel($current_user->id, $_REQUEST['module'], 'admin') == ACL_ALLOW_ADMIN_DEV)))))
1201 if ($_REQUEST['module'] != 'InboundEmail' && $_REQUEST['module'] != 'EmailMan' && $_REQUEST['module'] != 'iFrames') {
1202 $selected_objects_span = '';
1204 $export_link = " ";
1205 $merge_link = " ";
1206 } elseif($_REQUEST['module'] != "Accounts" && $_REQUEST['module'] != "Cases" && $_REQUEST['module'] != "Contacts" && $_REQUEST['module'] != "Leads" && $_REQUEST['module'] != "Opportunities") {
1207 $merge_link = " ";
1210 if($this->show_paging == true) {
1211 if(!empty($sugar_config['disable_count_query'])) {
1212 if($row_count > $end_record) {
1218 $html_text .= "<tr class='pagination' role='presentation'>\n";
1219 $html_text .= "<td COLSPAN=\"$col_count\" align=\"right\">\n";
1220 //$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >$export_link$merge_link$selected_objects_span</td>\n";
1221 //$html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >";
1222 if ($subpanel_def != null) {
1223 include_once('include/SubPanel/SubPanelTiles.php');
1224 $subpanelTiles = new SubPanelTiles($sugarbean);
1225 $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" >";
1227 //attempt to get the query to recreate this subpanel
1228 if(!empty($this->response)){
1229 $response =& $this->response;
1231 $response = SugarBean::get_union_related_list($sugarbean,$this->sortby, $this->sort_order, $this->query_where, $current_offset, -1,-1,$this->query_limit,$subpanel_def);
1232 $this->response = $response;
1234 //if query is present, then pass it in as parameter
1235 if (isset($response['query']) && !empty($response['query'])){
1236 $html_text .= $subpanelTiles->get_buttons($subpanel_def, $response['query']);
1238 $html_text .= $subpanelTiles->get_buttons($subpanel_def);
1242 $html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\" nowrap>$select_link $export_link $delete_link $selected_objects_span";
1244 $html_text .= "</td>\n<td nowrap align=\"right\">".$start_link." ".$previous_link." <span class='pageNumbers'>(".$start_record." - ".$end_record." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.")</span> ".$next_link." ".$end_link."</td></tr></table>\n";
1245 $html_text .= "</td>\n";
1246 $html_text .= "</tr>\n";
1247 $this->xTemplate->assign("PAGINATION",$html_text);
1250 //C.L. - Fix for 23461
1251 if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1252 $_SESSION['export_where'] = $this->query_where;
1254 $this->xTemplate->parse($xtemplateSection.".list_nav_row");
1256 } // end processListNavigation
1258 function processOrderBy($html_varName) {
1260 if(!isset($this->base_URL)) {
1261 $this->base_URL = $_SERVER['PHP_SELF'];
1263 if(isset($_SERVER['QUERY_STRING'])) {
1264 $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=[0-9a-zA-Z\_\.]*/","",$this->base_URL .'?'.$_SERVER['QUERY_STRING']);
1265 $this->base_URL = preg_replace("/\&".$this->getSessionVariableName($html_varName,"offset")."=[0-9]*/","",$this->base_URL);
1267 if($_SERVER['REQUEST_METHOD'] == 'POST') {
1268 $this->base_URL .= '?';
1269 if(isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action'];
1270 if(isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record'];
1271 if(isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module'];
1273 $this->base_URL .= "&".$this->getSessionVariableName($html_varName,"offset")."=";
1276 if($this->is_dynamic) {
1277 $this->base_URL.='&to_pdf=true&action=SubPanelViewer&subpanel=' . $this->source_module;
1280 $sort_URL_base = $this->base_URL. "&".$this->getSessionVariableName($html_varName,"ORDER_BY")."=";
1282 if($sort_URL_base !== "")
1284 $this->xTemplate->assign("ORDER_BY", $sort_URL_base);
1285 return $sort_URL_base;
1292 function getAdditionalHeader() {
1299 * @param unknown $data
1300 * @param unknown $xTemplateSection
1301 * @param unknown $html_varName
1302 * @desc INTERNAL FUNCTION handles the rows
1303 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1304 * All Rights Reserved.
1305 * Contributor(s): ______________________________________..
1307 function processListRows($data, $xtemplateSection, $html_varName)
1312 global $app_strings, $sugar_version, $sugar_config;
1313 global $currentModule;
1315 static $overlib_included;
1316 if(!$overlib_included) {
1317 echo getVersionedScript('cache/include/javascript/sugar_grp_overlib.js').
1318 '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
1319 $overlib_included = true;
1323 $this->xTemplate->assign('BG_HILITE', $hilite_bg);
1324 $this->xTemplate->assign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", ''));
1325 //$this->xTemplate->assign("BG_CLICK", $click_bg);
1331 $offset = $this->getOffset($html_varName);
1332 $timeStamp = $this->unique_id();
1333 $_SESSION[$html_varName."_FROM_LIST_VIEW"] = $timeStamp;
1335 $associated_row_data = array();
1338 $mergeList = array();
1340 //todo what is this? It is using an array as a boolean
1341 while(list($aVal, $aItem) = each($data))
1343 if(isset($this->data_array)) {
1344 $fields = $this->data_array;
1346 $aItem->check_date_relationships_load();
1347 $fields = $aItem->get_list_view_data();
1350 if(is_object($aItem)) { // cn: bug 5349
1351 //add item id to merge list, if the button is clicked
1352 $mergeList[] = $aItem->id;
1353 if(empty($module)) {
1354 $module = $aItem->module_dir;
1357 //ADD OFFSET TO ARRAY
1359 $fields['OFFSET'] = ($offset + $count + 1);
1361 $fields['STAMP'] = $timeStamp;
1362 if($this->shouldProcess) {
1365 if(!isset($this->data_array)) {
1366 $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='". $fields['ID']. "'>";
1368 $this->xTemplate->assign('PREROW', $prerow);
1370 $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)'>");
1372 if(!isset($this->data_array)) {
1373 $tag = $aItem->listviewACLHelper();
1374 $this->xTemplate->assign('TAG',$tag) ;
1379 $ROW_COLOR = 'oddListRow';
1380 $BG_COLOR = $odd_bg;
1384 $ROW_COLOR = 'evenListRow';
1385 $BG_COLOR = $even_bg;
1389 $this->xTemplate->assign('ROW_COLOR', $ROW_COLOR);
1390 $this->xTemplate->assign('BG_COLOR', $BG_COLOR);
1392 if(isset($this->data_array))
1394 $this->xTemplate->assign('KEY', $aVal);
1395 $this->xTemplate->assign('VALUE', $aItem);
1396 $this->xTemplate->assign('INDEX', $count);
1401 //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
1403 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'))) {
1405 $additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
1406 if(file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')){
1407 $additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
1410 require_once($additionalDetailsFile);
1411 $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name;
1412 $results = $ad_function($fields);
1413 $results['string'] = str_replace(array("'", "'"), '\'', $results['string']); // no xss!
1415 if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
1416 $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']].'</a>';
1418 //fixes bug for IE where empty list view rows causes IE to not display bottom border
1419 if(isset($fields['DESCRIPTION']) && empty($fields['DESCRIPTION']))
1420 $fields['DESCRIPTION'] = " ";
1421 if(isset($fields['LIST_ORDER']) && empty($fields['LIST_ORDER']))
1422 $fields['LIST_ORDER'] = " ";
1424 $this->xTemplate->assign($html_varName, $fields);
1425 $aItem->setupCustomFields($aItem->module_dir);
1426 $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
1428 if(!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
1431 if(isset($this->data_array)) {
1434 if(!isset($this->data_array)) {
1435 $aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection);
1437 if($this->xTemplate->exists($xtemplateSection.'.row.pro')) {
1438 $this->xTemplate->parse($xtemplateSection.'.row.pro');
1441 $this->xTemplate->parse($xtemplateSection . '.row');
1443 if(isset($fields['ID'])) {
1444 $associated_row_data[$fields['ID']] = $fields;
1445 // Bug 38908: cleanup data for JS to avoid having shuffled around
1446 foreach($fields as $key => $value) {
1447 if($value == ' ') {
1448 $associated_row_data[$fields['ID']][$key] = '';
1454 $_SESSION['MAILMERGE_RECORDS'] = $mergeList;
1455 $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module;
1456 if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
1457 $_SESSION['MAILMERGE_MODULE'] = $module;
1460 if($this->process_for_popups)
1462 $json = getJSONobj();
1463 $is_show_fullname = showFullName() ? 1 : 0;
1464 $associated_javascript_data = '<script type="text/javascript">' . "\n"
1465 //. '<!-- // associated javascript data generated by ListView' . "\n"
1466 . 'var associated_javascript_data = '
1467 . $json->encode($associated_row_data) . ";\n"
1469 . 'var is_show_fullname = '
1470 . $is_show_fullname . ";\n"
1472 $this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data);
1475 $this->xTemplate->parse($xtemplateSection);
1479 function getLayoutManager()
1481 require_once('include/generic/LayoutManager.php');
1482 if($this->layout_manager == null)
1484 $this->layout_manager = new LayoutManager();
1486 return $this->layout_manager;
1490 function process_dynamic_listview_header($source_module, $subpanel_def, $html_var = 'CELL')
1494 $layout_manager = $this->getLayoutManager();
1495 $layout_manager->setAttribute('order_by_link',$this->processOrderBy($html_var));
1496 $layout_manager->setAttribute('context','HeaderCell');
1497 $layout_manager->setAttribute('image_path',$this->local_image_path);
1498 $layout_manager->setAttribute('html_varName',$html_var);
1499 $layout_manager->setAttribute('module_name', $source_module);
1500 list($orderBy,$desc) = $this->getOrderByInfo($html_var);
1502 if($orderBy == 'amount*1')
1507 foreach($subpanel_def->get_list_fields() as $column_name=>$widget_args)
1509 $usage = empty($widget_args['usage']) ? '' : $widget_args['usage'];
1510 if($usage != 'query_only')
1514 if($orderBy == $column_name || (isset($widget_args['sort_by']) && str_replace('.','_',$widget_args['sort_by']) == $orderBy))
1516 $imgArrow = "_down";
1517 if($this->sort_order == 'asc') {
1521 $widget_args['name']=$column_name;
1522 $widget_args['sort'] = $imgArrow;
1523 $widget_args['start_link_wrapper'] = $this->start_link_wrapper;
1524 $widget_args['end_link_wrapper'] = $this->end_link_wrapper;
1525 $widget_args['subpanel_module'] = $this->subpanel_module;
1527 $widget_contents = $layout_manager->widgetDisplay($widget_args);
1528 $cell_width = empty($widget_args['width']) ? '' : $widget_args['width'];
1529 $this->xTemplate->assign('HEADER_CELL', $widget_contents);
1531 if(!isset($count))$count = 0; else $count++;
1532 $this->xTemplate->assign('CELL_COUNT', $count);
1533 $this->xTemplate->assign('CELL_WIDTH', $cell_width);
1534 $this->xTemplate->parse('dyn_list_view.header_cell');
1543 * @param unknown $seed
1544 * @param unknown $xTemplateSection
1545 * @param unknown $html_varName
1546 * @desc PUBLIC FUNCTION Handles List Views using seeds that extend SugarBean
1547 $XTemplateSection is the section in the XTemplate file that should be parsed usually main
1548 $html_VarName is the variable name used in the XTemplateFile e.g. TASK
1549 $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
1550 if no XTemplate is set it will create a new XTemplate
1551 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc..
1552 * All Rights Reserved..
1553 * Contributor(s): ______________________________________..
1556 function processListViewTwo($seed, $xTemplateSection, $html_varName) {
1557 global $current_user;
1558 if(!isset($this->xTemplate)) {
1559 $this->createXTemplate();
1562 $isSugarBean = is_subclass_of($seed, "SugarBean");
1566 $list = $this->processSugarBean($xTemplateSection, $html_varName, $seed);
1571 if (is_object($seed) && isset($seed->object_name) && $seed->object_name == 'WorkFlow') {
1573 $access = get_workflow_admin_modules_for_user($current_user);
1574 for ($i = 0; $i < count($list); $i++) {
1575 if(!empty($access[$list[$i]->base_module])){
1582 if($this->is_dynamic) {
1583 $this->processHeaderDynamic($xTemplateSection,$html_varName);
1584 $this->processListRows($list,$xTemplateSection, $html_varName);
1586 $this->processSortArrows($html_varName);
1589 $seed->parse_additional_headers($this->xTemplate, $xTemplateSection);
1591 $this->xTemplateAssign('CHECKALL', SugarThemeRegistry::current()->getImage('blank', '', 1, 1, ".gif", ''));
1593 // Process the order by before processing the pro_nav. The pro_nav requires the order by values to be set
1594 $this->processOrderBy($html_varName);
1597 $this->processListRows($list,$xTemplateSection, $html_varName);
1600 if($this->display_header_and_footer) {
1601 $this->getAdditionalHeader();
1602 if(!empty($this->header_title)) {
1603 echo get_form_header($this->header_title, $this->header_text, false);
1607 $this->xTemplate->out($xTemplateSection);
1609 if(isset($_SESSION['validation'])) {
1610 print base64_decode('PGEgaHJlZj0naHR0cDovL3d3dy5zdWdhcmNybS5jb20nPlBPV0VSRUQmbmJzcDtCWSZuYnNwO1NVR0FSQ1JNPC9hPg==');
1614 function getArrowStart() {
1615 $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif"));
1617 return " <!--not_in_theme!--><img border='0' src='".$imgFileParts['dirname']."/".$imgFileParts['filename']."";
1620 function getArrowUpDownStart($upDown) {
1621 $ext = ( SugarThemeRegistry::current()->pngSupport ? "png" : "gif" );
1623 if (!isset($upDown) || empty($upDown)) {
1626 return " <img border='0' src='".SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.{$ext}")."' ";
1629 function getArrowEnd() {
1630 $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow.gif"));
1632 list($width,$height) = ListView::getArrowImageSize();
1634 return '.'.$imgFileParts['extension']."' width='$width' height='$height' align='absmiddle' alt=".translate('LBL_SORT').">";
1637 function getArrowUpDownEnd($upDown) {
1638 if (!isset($upDown) || empty($upDown)) {
1641 $imgFileParts = pathinfo(SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif"));
1643 list($width,$height) = ListView::getArrowUpDownImageSize($upDown);
1645 //get the right alt tag for the sort
1646 $sortStr = translate('LBL_ALT_SORT');
1647 if($upDown == '_down'){
1648 $sortStr = translate('LBL_ALT_SORT_DESC');
1649 }elseif($upDown == '_up'){
1650 $sortStr = translate('LBL_ALT_SORT_ASC');
1652 return " width='$width' height='$height' align='absmiddle' alt='$sortStr'>";
1655 function getArrowImageSize() {
1656 // jbasicChartDashletsExpColust get the non-sort image's size.. the up and down have be the same.
1657 $image = SugarThemeRegistry::current()->getImageURL("arrow.gif",false);
1659 $cache_key = 'arrow_size.'.$image;
1662 $result = sugar_cache_retrieve($cache_key);
1666 // No cache hit. Calculate the value and return.
1667 $result = getimagesize($image);
1668 sugar_cache_put($cache_key, $result);
1672 function getArrowUpDownImageSize($upDown) {
1673 // just get the non-sort image's size.. the up and down have be the same.
1674 $image = SugarThemeRegistry::current()->getImageURL("arrow{$upDown}.gif",false);
1676 $cache_key = 'arrowupdown_size.'.$image;
1679 $result = sugar_cache_retrieve($cache_key);
1683 // No cache hit. Calculate the value and return.
1684 $result = getimagesize($image);
1685 sugar_cache_put($cache_key, $result);
1689 function getOrderByInfo($html_varName)
1691 $orderBy = $this->getSessionVariable($html_varName, "OBL");
1692 $desc = $this->getSessionVariable($html_varName, $orderBy.'S');
1693 $orderBy = str_replace('.', '_', $orderBy);
1694 return array($orderBy,$desc);
1697 function processSortArrows($html_varName)
1700 $this->xTemplateAssign("arrow_start", $this->getArrowStart());
1702 list($orderBy,$desc) = $this->getOrderByInfo($html_varName);
1704 $imgArrow = "_down";
1709 * @deprecated only used by legacy opportunites listview, nothing current. Leaving for BC
1711 if($orderBy == 'amount*1')
1713 $this->xTemplateAssign('amount_arrow', $imgArrow);
1715 else if($orderBy == 'amount_usdollar*1')
1717 $this->xTemplateAssign('amount_usdollar_arrow', $imgArrow);
1721 $this->xTemplateAssign($orderBy.'_arrow', $imgArrow);
1724 $this->xTemplateAssign('arrow_end', $this->getArrowEnd());
1727 // this is where translation happens for dynamic list views
1728 function loadListFieldDefs(&$subpanel_fields,&$child_focus)
1730 $this->list_field_defs = $subpanel_fields;
1732 for($i=0;$i < count($this->list_field_defs);$i++)
1734 $list_field = $this->list_field_defs[$i];
1737 if(!empty($list_field['vname']))
1739 $key = $list_field['vname'];
1740 } else if(isset($list_field['name']) && isset($child_focus->field_defs[$list_field['name']]))
1742 $field_def = $child_focus->field_defs[$list_field['name']];
1743 $key = $field_def['vname'];
1747 $list_field['label'] = translate($key,$child_focus->module_dir);
1748 $this->list_field_defs[$i]['label'] = preg_replace('/:$/','',$list_field['label']);
1752 $this->list_field_defs[$i]['label'] =' ';
1757 function unique_id() {
1758 return sugar_microtime();
1761 /**INTERNAL FUNCTION sets a session variable keeping it local to the listview
1762 not the current_module
1763 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1764 * All Rights Reserved.
1765 * Contributor(s): ______________________________________.
1767 function setLocalSessionVariable($localVarName,$varName, $value) {
1768 $_SESSION[$localVarName."_".$varName] = $value;
1771 /**INTERNAL FUNCTION returns a session variable that is local to the listview,
1772 not the current_module
1773 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
1774 * All Rights Reserved.
1775 * Contributor(s): ______________________________________.
1777 function getLocalSessionVariable($localVarName,$varName) {
1778 if(isset($_SESSION[$localVarName."_".$varName])) {
1779 return $_SESSION[$localVarName."_".$varName];
1786 /* Set to true if you want Additional Details to appear in the listview
1788 function setAdditionalDetails($value = true, $function = '') {
1789 if(!empty($function)) $this->additionalDetailsFunction = $function;
1790 $this->_additionalDetails = $value;