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