]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/ListView/ListViewData.php
Release 6.2.0
[Github/sugarcrm.git] / include / ListView / ListViewData.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-2011 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
39 require_once('include/EditView/SugarVCR.php');
40 class ListViewData {
41         var $additionalDetails = true;
42     var $listviewName = null;
43         var $additionalDetailsAllow = null;
44     var $additionalDetailsAjax = true; // leave this true when using filter fields
45     var $additionalDetailsFieldToAdd = 'NAME'; // where the span will be attached to
46     var $base_url = null;
47     /*
48      * If you want overwrite the query for the count of the listview set this to your query
49      * otherwise leave it empty and it will use SugarBean::create_list_count_query
50      */
51     var $count_query = '';
52
53         /**
54          * Constructor sets the limitName to look up the limit in $sugar_config
55          *
56          * @return ListViewData
57          */
58         function ListViewData() {
59                 $this->limitName = 'list_max_entries_per_page';
60                 $this->db = &DBManagerFactory::getInstance('listviews');
61         }
62
63         /**
64          * checks the request for the order by and if that is not set then it checks the session for it
65          *
66          * @return array containing the keys orderBy => field being ordered off of and sortOrder => the sort order of that field
67          */
68         function getOrderBy($orderBy = '', $direction = '') {
69                 if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
70             if(!empty($_REQUEST[$this->var_order_by])) {
71                         $direction = 'ASC';
72                         $orderBy = $_REQUEST[$this->var_order_by];
73                         if(!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0) ){
74                                 $direction = $_REQUEST['lvso'];
75
76                                     $trackerManager = TrackerManager::getInstance();
77                                         if($monitor = $trackerManager->getMonitor('tracker')){
78                                         $monitor->setValue('module_name', $GLOBALS['module']);
79                                         $monitor->setValue('item_summary', "lvso=".$direction."&".$this->var_order_by."=".$_REQUEST[$this->var_order_by]);
80                                         $monitor->setValue('action', 'listview');
81                                                 $monitor->setValue('user_id', $GLOBALS['current_user']->id);
82                                                 $monitor->setValue('date_modified', TimeDate::getInstance()->nowDb());
83                                         $monitor->save();
84                                         }
85                         }
86             }
87             $_SESSION[$this->var_order_by] = array('orderBy'=>$orderBy, 'direction'=> $direction);
88             $_SESSION['lvd']['last_ob'] = $orderBy;
89         }
90                 else {
91                         if(!empty($_SESSION[$this->var_order_by])) {
92                                 $orderBy = $_SESSION[$this->var_order_by]['orderBy'];
93                                 $direction = $_SESSION[$this->var_order_by]['direction'];
94                         }
95                         else{
96                                 $orderBy = 'date_entered';
97                                 $direction = 'DESC';
98                         }
99                 }
100                 return array('orderBy' => $orderBy, 'sortOrder' => $direction);
101         }
102
103         /**
104          * gets the reverse of the sort order for use on links to reverse a sort order from what is currently used
105          *
106          * @param STRING (ASC or DESC) $current_order
107          * @return  STRING (ASC or DESC)
108          */
109         function getReverseSortOrder($current_order){
110                 return (strcmp(strtolower($current_order), 'asc') == 0)?'DESC':'ASC';
111         }
112         /**
113          * gets the limit of how many rows to show per page
114          *
115          * @return INT (the limit)
116          */
117         function getLimit() {
118                 return $GLOBALS['sugar_config'][$this->limitName];
119         }
120
121         /**
122          * returns the current offset
123          *
124          * @return INT (current offset)
125          */
126         function getOffset() {
127                 return (!empty($_REQUEST[$this->var_offset])) ? $_REQUEST[$this->var_offset] : 0;
128         }
129
130         /**
131          * generates the base url without
132          * any files in the block variables will not be part of the url
133          *
134          *
135          * @return STRING (the base url)
136          */
137         function getBaseURL() {
138         global $beanList;
139                 if(empty($this->base_url)) {
140             $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount',$this->var_order_by, $this->var_offset, 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
141             $base_url = 'index.php?';
142             foreach($beanList as $bean) {
143                 $blockVariables[] = 'Home2_'.strtoupper($bean).'_ORDER_BY';
144             }
145             $blockVariables[] = 'Home2_CASE_ORDER_BY';
146             // Added mostly for the unit test runners, which may not have these superglobals defined
147             $params = array();
148             if ( isset($_POST) && is_array($_POST) ) {
149                 $params = array_merge($params,$_POST);
150             }
151             if ( isset($_GET) && is_array($_GET) ) {
152                 $params = array_merge($params,$_GET);
153             }
154             foreach($params as $name=>$value) {
155                 if(!in_array($name, $blockVariables)){
156                                         if(is_array($value)) {
157                                                 foreach($value as $v) {
158                             $base_url .= $name.urlencode('[]').'='.urlencode($v) . '&';
159                         }
160                     }
161                     else {
162                                                 $base_url .= $name.'='.urlencode($value) . '&';
163                     }
164                 }
165             }
166             $this->base_url = $base_url;
167         }
168                 return $this->base_url;
169         }
170         /**
171          * based off of a base name it sets base, offset, and order by variable names to retrieve them from requests and sessions
172          *
173          * @param unknown_type $baseName
174          */
175         function setVariableName($baseName, $where, $listviewName = null){
176         global $timedate;
177         $module = (!empty($listviewName)) ? $listviewName: $_REQUEST['module'];
178         $this->var_name = $module .'2_'. strtoupper($baseName);
179
180                 $this->var_order_by = $this->var_name .'_ORDER_BY';
181                 $this->var_offset = $this->var_name . '_offset';
182         $timestamp = sugar_microtime();
183         $this->stamp = $timestamp;
184
185         $_SESSION[$module .'2_QUERY_QUERY'] = $where;
186
187         $_SESSION[strtoupper($baseName) . "_FROM_LIST_VIEW"] = $timestamp;
188         $_SESSION[strtoupper($baseName) . "_DETAIL_NAV_HISTORY"] = false;
189         }
190
191         function getTotalCount($main_query){
192                 if(!empty($this->count_query)){
193                     $count_query = $this->count_query;
194                 }else{
195                 $count_query = SugarBean::create_list_count_query($main_query);
196             }
197                 $result = $this->db->query($count_query);
198                 if($row = $this->db->fetchByAssoc($result)){
199                         return $row['c'];
200                 }
201                 return 0;
202         }
203
204         /**
205          * takes in a seed and creates the list view query based off of that seed
206          * if the $limit value is set to -1 then it will use the default limit and offset values
207          *
208          * it will return an array with two key values
209          *      1. 'data'=> this is an array of row data
210          *  2. 'pageData'=> this is an array containg three values
211          *                      a.'ordering'=> array('orderBy'=> the field being ordered by , 'sortOrder'=> 'ASC' or 'DESC')
212          *                      b.'urls'=>array('baseURL'=>url used to generate other urls ,
213          *                                                      'orderBy'=> the base url for order by
214          *                                                      //the following may not be set (so check empty to see if they are set)
215          *                                                      'nextPage'=> the url for the next group of results,
216          *                                                      'prevPage'=> the url for the prev group of results,
217          *                                                      'startPage'=> the url for the start of the group,
218          *                                                      'endPage'=> the url for the last set of results in the group
219          *                      c.'offsets'=>array(
220          *                                                              'current'=>current offset
221          *                                                              'next'=> next group offset
222          *                                                              'prev'=> prev group offset
223          *                                                              'end'=> the offset of the last group
224          *                                                              'total'=> the total count (only accurate if totalCounted = true otherwise it is either the total count if less than the limit or the total count + 1 )
225          *                                                              'totalCounted'=> if a count query was used to get the total count
226          *
227          * @param SugarBean $seed
228          * @param string $where
229          * @param int:0 $offset
230          * @param int:-1 $limit
231          * @param string[]:array() $filter_fields
232          * @param array:array() $params
233          *      Potential $params are
234                 $params['distinct'] = use distinct key word
235                 $params['include_custom_fields'] = (on by default)
236         $params['custom_XXXX'] = append custom statements to query
237          * @param string:'id' $id_field
238          * @return array('data'=> row data 'pageData' => page data information
239          */
240         function getListViewData($seed, $where, $offset=-1, $limit = -1, $filter_fields=array(),$params=array(),$id_field = 'id') {
241         global $current_user;
242         SugarVCR::erase($seed->module_dir);
243         $this->seed =& $seed;
244         $totalCounted = empty($GLOBALS['sugar_config']['disable_count_query']);
245         $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $seed->module_dir;
246         if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup'){
247             $_SESSION['MAILMERGE_MODULE'] = $seed->module_dir;
248         }
249
250         $this->setVariableName($seed->object_name, $where, $this->listviewName);
251
252                 $this->seed->id = '[SELECT_ID_LIST]';
253
254         // if $params tell us to override all ordering
255         if(!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
256             $order = $this->getOrderBy(strtolower($params['orderBy']), (empty($params['sortOrder']) ? '' : $params['sortOrder'])); // retreive from $_REQUEST
257         }
258         else {
259             $order = $this->getOrderBy(); // retreive from $_REQUEST
260         }
261
262         // else use stored preference
263         $userPreferenceOrder = $current_user->getPreference('listviewOrder', $this->var_name);
264
265         if(empty($order['orderBy']) && !empty($userPreferenceOrder)) {
266             $order = $userPreferenceOrder;
267         }
268         // still empty? try to use settings passed in $param
269         if(empty($order['orderBy']) && !empty($params['orderBy'])) {
270             $order['orderBy'] = $params['orderBy'];
271             $order['sortOrder'] =  (empty($params['sortOrder']) ? '' : $params['sortOrder']);
272         }
273
274         //rrs - bug: 21788. Do not use Order by stmts with fields that are not in the query.
275         // Bug 22740 - Tweak this check to strip off the table name off the order by parameter.
276         // Samir Gandhi : Do not remove the report_cache.date_modified condition as the report list view is broken
277         $orderby = $order['orderBy'];
278         if (strpos($order['orderBy'],'.') && ($order['orderBy'] != "report_cache.date_modified")) {
279             $orderby = substr($order['orderBy'],strpos($order['orderBy'],'.')+1);
280         }
281         if ($orderby != 'date_entered' && !in_array($orderby, array_keys($filter_fields))) {
282                 $order['orderBy'] = '';
283                 $order['sortOrder'] = '';
284         }
285
286                 if (empty($order['orderBy'])) {
287             $orderBy = '';
288         } else {
289             $orderBy = $order['orderBy'] . ' ' . $order['sortOrder'];
290             //wdong, Bug 25476, fix the sorting problem of Oracle.
291             if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code'])
292                 $orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder'];
293         }
294         
295         if (empty($params['skipOrderSave'])) { // don't save preferences if told so
296             $current_user->setPreference('listviewOrder', $order, 0, $this->var_name); // save preference
297         }
298                 
299                 // If $params tells us to override for the special last_name, first_name sorting
300                 if (!empty($params['overrideLastNameOrder']) && $order['orderBy'] == 'last_name') {
301                         $orderBy = 'last_name '.$order['sortOrder'].', first_name '.$order['sortOrder'];
302                 }
303
304                 $ret_array = $seed->create_new_list_query($orderBy, $where, $filter_fields, $params, 0, '', true, $seed, true);
305         $ret_array['inner_join'] = '';
306         if (!empty($this->seed->listview_inner_join)) {
307             $ret_array['inner_join'] = ' ' . implode(' ', $this->seed->listview_inner_join) . ' ';
308         }
309
310                 if(!is_array($params)) $params = array();
311         if(!isset($params['custom_select'])) $params['custom_select'] = '';
312         if(!isset($params['custom_from'])) $params['custom_from'] = '';
313         if(!isset($params['custom_where'])) $params['custom_where'] = '';
314         if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
315                 $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
316                 //C.L. - Fix for 23461
317                 if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
318                    $_SESSION['export_where'] = $ret_array['where'];
319                 }
320                 if($limit < -1) {
321                         $result = $this->db->query($main_query);
322                 }
323                 else {
324                         if($limit == -1) {
325                                 $limit = $this->getLimit();
326             }
327                         $dyn_offset = $this->getOffset();
328                         if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
329
330             if(strcmp($offset, 'end') == 0){
331                 $totalCount = $this->getTotalCount($main_query);
332                 $offset = (floor(($totalCount -1) / $limit)) * $limit;
333             }
334             if($this->seed->ACLAccess('ListView')) {
335                 $result = $this->db->limitQuery($main_query, $offset, $limit + 1);
336             }
337             else {
338                 $result = array();
339             }
340
341                 }
342
343                 $data = array();
344
345                 $temp = clone $seed;
346
347                 $rows = array();
348                 $count = 0;
349         $idIndex = array();
350         $id_list = '';
351                 while($row = $this->db->fetchByAssoc($result)) {
352                         if($count < $limit) {
353                                 if(!empty($id_list)) {
354                                         $id_list = '(';
355                                 }else{
356                                         $id_list .= ',';
357                                 }
358                                 $id_list .= '\''.$row[$id_field].'\'';
359                                 //handles date formating and such
360                                 $idIndex[$row[$id_field]][] = count($rows);
361                                 $rows[] = $row;
362                         }
363                         $count++;
364                 }
365                 if (!empty($id_list)) $id_list .= ')';
366
367         SugarVCR::store($this->seed->module_dir,  $main_query);
368                 if($count != 0) {
369                         //NOW HANDLE SECONDARY QUERIES
370                         if(!empty($ret_array['secondary_select'])) {
371                                 $secondary_query = $ret_array['secondary_select'] . $ret_array['secondary_from'] . ' WHERE '.$this->seed->table_name.'.id IN ' .$id_list;
372                                 $secondary_result = $this->db->query($secondary_query);
373                                 while($row = $this->db->fetchByAssoc($secondary_result)) {
374                                         foreach($row as $name=>$value) {
375                                                 //add it to every row with the given id
376                                                 foreach($idIndex[$row['ref_id']] as $index){
377                                                     $rows[$index][$name]=$value;
378                                                 }
379
380                                         }
381                                 }
382                         }
383
384             // retrieve parent names
385             if(!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
386                 foreach($idIndex as $id => $rowIndex) {
387                     if(!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
388                         $post_retrieve[$rows[$rowIndex[0]]['parent_type']] = array();
389                     }
390                     if(!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
391                 }
392                 if(isset($post_retrieve)) {
393                     $parent_fields = $seed->retrieve_parent_fields($post_retrieve);
394                     foreach($parent_fields as $child_id => $parent_data) {
395                         //add it to every row with the given id
396                                                 foreach($idIndex[$child_id] as $index){
397                                                     $rows[$index]['parent_name']= $parent_data['parent_name'];
398                                                 }
399                     }
400                 }
401             }
402
403                         $pageData = array();
404
405                         reset($rows);
406                         while($row = current($rows)){
407                 $temp = clone $seed;
408                             $dataIndex = count($data);
409
410                             $temp->setupCustomFields($temp->module_dir);
411                                 $temp->loadFromRow($row);
412                                 if($idIndex[$row[$id_field]][0] == $dataIndex){
413                                     $pageData['tag'][$dataIndex] = $temp->listviewACLHelper();
414                                 }else{
415                                     $pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]];
416                                 }
417                                 $data[$dataIndex] = $temp->get_list_view_data($filter_fields);
418                             $pageData['rowAccess'][$dataIndex] = array('view' => $temp->ACLAccess('DetailView'), 'edit' => $temp->ACLAccess('EditView'));
419                             $additionalDetailsAllow = $this->additionalDetails && $temp->ACLAccess('DetailView') && (file_exists('modules/' . $temp->module_dir . '/metadata/additionalDetails.php') || file_exists('custom/modules/' . $temp->module_dir . '/metadata/additionalDetails.php'));
420                             //if($additionalDetailsAllow) $pageData['additionalDetails'] = array();
421                             $additionalDetailsEdit = $temp->ACLAccess('EditView');
422                                 if($additionalDetailsAllow) {
423                     if($this->additionalDetailsAjax) {
424                                            $ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']);
425                     }
426                     else {
427                         $additionalDetailsFile = 'modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
428                         if(file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php')){
429                                 $additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
430                         }
431                         require_once($additionalDetailsFile);
432                         $ar = $this->getAdditionalDetails($data[$dataIndex],
433                                     (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $this->seed->object_name,
434                                     $additionalDetailsEdit);
435                     }
436                     $pageData['additionalDetails'][$dataIndex] = $ar['string'];
437                     $pageData['additionalDetails']['fieldToAddTo'] = $ar['fieldToAddTo'];
438                                 }
439                                 next($rows);
440                         }
441                 }
442                 $nextOffset = -1;
443                 $prevOffset = -1;
444                 $endOffset = -1;
445                 if($count > $limit) {
446                         $nextOffset = $offset + $limit;
447                 }
448
449                 if($offset > 0) {
450                         $prevOffset = $offset - $limit;
451                         if($prevOffset < 0)$prevOffset = 0;
452                 }
453                 $totalCount = $count + $offset;
454
455                 if( $count >= $limit && $totalCounted){
456                         $totalCount  = $this->getTotalCount($main_query);
457                 }
458                 SugarVCR::recordIDs($this->seed->module_dir, array_keys($idIndex), $offset, $totalCount);
459                 $endOffset = (floor(($totalCount - 1) / $limit)) * $limit;
460                 $pageData['ordering'] = $order;
461                 $pageData['ordering']['sortOrder'] = $this->getReverseSortOrder($pageData['ordering']['sortOrder']);
462                 $pageData['urls'] = $this->generateURLS($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset,  $endOffset, $totalCounted);
463                 $pageData['offsets'] = array( 'current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
464                 $pageData['bean'] = array('objectName' => $seed->object_name, 'moduleDir' => $seed->module_dir);
465         $pageData['stamp'] = $this->stamp;
466         $pageData['access'] = array('view' => $this->seed->ACLAccess('DetailView'), 'edit' => $this->seed->ACLAccess('EditView'));
467                 $pageData['idIndex'] = $idIndex;
468         if(!$this->seed->ACLAccess('ListView')) {
469             $pageData['error'] = 'ACL restricted access';
470         }
471
472                 return array('data'=>$data , 'pageData'=>$pageData);
473         }
474
475
476         /**
477          * generates urls for use by the display  layer
478          *
479          * @param int $sortOrder
480          * @param int $offset
481          * @param int $prevOffset
482          * @param int $nextOffset
483          * @param int $endOffset
484          * @param int $totalCounted
485          * @return array of urls orderBy and baseURL are always returned the others are only returned  according to values passed in.
486          */
487         function generateURLS($sortOrder, $offset, $prevOffset, $nextOffset, $endOffset, $totalCounted) {
488                 $urls = array();
489                 $urls['baseURL'] = $this->getBaseURL(). 'lvso=' . $sortOrder. '&';
490                 $urls['orderBy'] = $urls['baseURL'] .$this->var_order_by.'=';
491
492                 $dynamicUrl = '';
493                 if($nextOffset > -1) {
494                         $urls['nextPage'] = $urls['baseURL'] . $this->var_offset . '=' . $nextOffset . $dynamicUrl;
495                 }
496                 if($offset > 0) {
497                         $urls['startPage'] = $urls['baseURL'] . $this->var_offset . '=0' . $dynamicUrl;
498                 }
499                 if($prevOffset > -1) {
500                         $urls['prevPage'] = $urls['baseURL'] . $this->var_offset . '=' . $prevOffset . $dynamicUrl;
501                 }
502                 if($totalCounted) {
503                         $urls['endPage'] = $urls['baseURL'] . $this->var_offset . '=' . $endOffset . $dynamicUrl;
504                 }else{
505                         $urls['endPage'] = $urls['baseURL'] . $this->var_offset . '=end' . $dynamicUrl;
506                 }
507
508                 return $urls;
509         }
510
511         /**
512          * generates the additional details span to be retrieved via ajax
513          *
514          * @param GUID id id of the record
515          * @return array string to attach to field
516          */
517         function getAdditionalDetailsAjax($id)
518     {
519         global $app_strings;
520
521         $jscalendarImage = SugarThemeRegistry::current()->getImageURL('info_inline.gif');
522
523         $extra = "<span id='adspan_" . $id . "' onmouseout=\"return SUGAR.util.clearAdditionalDetailsCall()\" "
524                 . "onmouseover=\"lvg_dtails('$id')\" "
525                                 . "onmouseout=\"return nd(1000);\" style='position: relative;'><img vertical-align='middle' class='info' border='0' src='$jscalendarImage'></span>";
526
527         return array('fieldToAddTo' => $this->additionalDetailsFieldToAdd, 'string' => $extra);
528         }
529
530     /**
531      * generates the additional details values
532      *
533      * @param unknown_type $fields
534      * @param unknown_type $adFunction
535      * @param unknown_type $editAccess
536      * @return array string to attach to field
537      */
538     function getAdditionalDetails($fields, $adFunction, $editAccess)
539     {
540         global $app_strings;
541
542         $results = $adFunction($fields);
543         $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
544
545         if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
546         $extra = "<span onmouseover=\"return overlib('" .
547             str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string'])
548             . "', CAPTION, '<div style=\'float:left\'>{$app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\'float: right\'>";
549         if($editAccess) $extra .= (!empty($results['editLink']) ? "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img  border=0 src=".SugarThemeRegistry::current()->getImageURL('edit_inline.gif')."></a>" : '');
550         $extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=0 src=".SugarThemeRegistry::current()->getImageURL('view_inline.gif')."></a>" : '')
551             . "', DELAY, 200, STICKY, MOUSEOFF, 1000, WIDTH, "
552             . (empty($results['width']) ? '300' : $results['width'])
553             . ", CLOSETEXT, '<img border=0 style=\'margin-left:2px; margin-right: 2px;\' src='".SugarThemeRegistry::current()->getImageURL('close.gif')."'></div>', "
554             . "CLOSETITLE, '{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}', CLOSECLICK, FGCLASS, 'olFgClass', "
555             . "CGCLASS, 'olCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');\" "
556             . "onmouseout=\"return nd(1000);\"><img style='padding: 0px 5px 0px 2px' border='0' src='".SugarThemeRegistry::current()->getImageURL('info_inline.png')."' ></span>";
557
558             $results = $adFunction($fields);
559             $results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
560
561             if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
562             $extra = "<span onmouseover=\"return overlib('" .
563                 str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string'])
564                 . "', CAPTION, '<div style=\'float:left\'>{$app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\'float: right\'>";
565             if($editAccess) $extra .= (!empty($results['editLink']) ? "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img  border=0 src=".SugarThemeRegistry::current()->getImageURL('edit_inline.gif')."></a>" : '');
566             $extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=0 src=".SugarThemeRegistry::current()->getImageURL('view_inline.gif')."></a>" : '')
567                 . "', DELAY, 200, STICKY, MOUSEOFF, 1000, WIDTH, "
568                 . (empty($results['width']) ? '300' : $results['width'])
569                 . ", CLOSETEXT, '<img border=0 style=\'margin-left:2px; margin-right: 2px;\' src=".SugarThemeRegistry::current()->getImageURL('close.gif')."></div>', "
570                 . "CLOSETITLE, '{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}', CLOSECLICK, FGCLASS, 'olFgClass', "
571                 . "CGCLASS, 'olCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');\" "
572                 . "onmouseout=\"return nd(1000);\"><img style='padding: 0px 5px 0px 2px' border='0' src='".SugarThemeRegistry::current()->getImageURL('info_inline.png')."' ></span>";
573
574             return array('fieldToAddTo' => $results['fieldToAddTo'], 'string' => $extra);
575     }
576
577 }