/**
     * @return void
     * @param unknown $data
     * @param unknown $xTemplateSection
     * @param unknown $html_varName
     * @desc INTERNAL FUNCTION handles the rows
     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
     * All Rights Reserved.
     * Contributor(s): ______________________________________..
     */
    function processListRows($data, $xtemplateSection, $html_varName)
    {
        global $odd_bg;
        global $even_bg;
        global $hilite_bg;
        global $app_strings, $sugar_version, $sugar_config;
        global $currentModule;
        static $overlib_included;
        if (!$overlib_included) {
            echo '<script type="text/javascript" src="include/javascript/sugar_grp_overlib.js"></script>
				<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
            $overlib_included = true;
        }
        $this->xTemplate->assign('BG_HILITE', $hilite_bg);
        $this->xTemplate->assign('CHECKALL', "<img src='" . SugarThemeRegistry::current()->getImageURL('blank.gif') . "' width=\"1\" height=\"1\" alt=\"\" />");
        //$this->xTemplate->assign("BG_CLICK", $click_bg);
        $oddRow = true;
        $count = 0;
        reset($data);
        //GETTING OFFSET
        $offset = $this->getOffset($html_varName);
        $timeStamp = $this->unique_id();
        $_SESSION[$html_varName . "_FROM_LIST_VIEW"] = $timeStamp;
        $associated_row_data = array();
        //mail merge list
        $mergeList = array();
        $module = '';
        //todo what is this?  It is using an array as a boolean
        while (list($aVal, $aItem) = each($data)) {
            if (isset($this->data_array)) {
                $fields = $this->data_array;
            } else {
                $aItem->check_date_relationships_load();
                $fields = $aItem->get_list_view_data();
            }
            if (is_object($aItem)) {
                // cn: bug 5349
                //add item id to merge list, if the button is clicked
                $mergeList[] = $aItem->id;
                if (empty($module)) {
                    $module = $aItem->module_dir;
                }
            }
            //ADD OFFSET TO ARRAY
            $fields['OFFSET'] = $offset + $count + 1;
            $fields['STAMP'] = $timeStamp;
            if ($this->shouldProcess) {
                $prerow = '';
                if (!isset($this->data_array)) {
                    $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='" . $fields['ID'] . "'>";
                }
                $this->xTemplate->assign('PREROW', $prerow);
                $this->xTemplate->assign('CHECKALL', "<input type='checkbox' class='checkbox' name='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked)'>");
            }
            if (!isset($this->data_array)) {
                $tag = $aItem->listviewACLHelper();
                $this->xTemplate->assign('TAG', $tag);
            }
            if ($oddRow) {
                $ROW_COLOR = 'oddListRow';
                $BG_COLOR = $odd_bg;
            } else {
                $ROW_COLOR = 'evenListRow';
                $BG_COLOR = $even_bg;
            }
            $oddRow = !$oddRow;
            $this->xTemplate->assign('ROW_COLOR', $ROW_COLOR);
            $this->xTemplate->assign('BG_COLOR', $BG_COLOR);
            if (isset($this->data_array)) {
                $this->xTemplate->assign('KEY', $aVal);
                $this->xTemplate->assign('VALUE', $aItem);
                $this->xTemplate->assign('INDEX', $count);
            } else {
                //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
                // Bug #2786
                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'))) {
                    $additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
                    if (file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')) {
                        $additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
                    }
                    require_once $additionalDetailsFile;
                    $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name;
                    $results = $ad_function($fields);
                    $results['string'] = str_replace(array("&#039", "'"), '\\&#039', $results['string']);
                    // no xss!
                    if (trim($results['string']) == '') {
                        $results['string'] = $app_strings['LBL_NONE'];
                    }
                    $extra = " <img border='0' onmouseover=\"return overlib('" . str_replace(array("\rn", "\r", "\n"), array('', '', '<br />'), $results['string']) . "', CAPTION, '<div style=\\'float:left\\'>{$this->local_app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\\'float: right\\'>";
                    if ($aItem->ACLAccess('EditView')) {
                        $extra .= !empty($results['editLink']) ? "<a title=\\'{$app_strings['LBL_EDIT_BUTTON']}\\' href={$results['editLink']}><img border=0 src={$this->local_image_path}edit_inline.gif></a>" : '';
                    }
                    $extra .= (!empty($results['viewLink']) ? "<a title=\\'{$app_strings['LBL_VIEW_BUTTON']}\\' href={$results['viewLink']}><img style=\\'margin-left: 2px;\\' border=0 src={$this->local_image_path}view_inline.gif></a>" : '') . "', DELAY, 200, STICKY, MOUSEOFF, 1000, WIDTH, " . (empty($results['width']) ? '300' : $results['width']) . ", CLOSETEXT, '<img border=0  style=\\'margin-left:2px; margin-right: 2px;\\' src={$this->local_image_path}close.gif></div>', " . "CLOSETITLE, '{$this->local_app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}', CLOSECLICK, FGCLASS, 'olFgClass', " . "CGCLASS, 'olCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');\" " . "onmouseout=\"return nd(1000);\" src='" . SugarThemeRegistry::current()->getImageURL('MoreDetail.png') . "' width=8 height=7>";
                    $fields[$results['fieldToAddTo']] = $extra . '&nbsp;' . $fields[$results['fieldToAddTo']] . '</a>';
                }
                $this->xTemplate->assign($html_varName, $fields);
                $aItem->setupCustomFields($aItem->module_dir);
                $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
            }
            if (!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
                $count++;
            }
            if (isset($this->data_array)) {
                $count++;
            }
            if (!isset($this->data_array)) {
                $aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection);
                if ($this->xTemplate->exists($xtemplateSection . '.row.pro')) {
                    $this->xTemplate->parse($xtemplateSection . '.row.pro');
                }
            }
            $this->xTemplate->parse($xtemplateSection . '.row');
            if (isset($fields['ID'])) {
                $associated_row_data[$fields['ID']] = $fields;
            }
        }
        global $timedate;
        if (empty($timedate)) {
            $timedate = new TimeDate();
        }
        $microtime = $timedate->get_microtime_string();
        $_SESSION['MAILMERGE_RECORDS'] = $mergeList;
        $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module;
        if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
            $_SESSION['MAILMERGE_MODULE'] = $module;
        }
        if ($this->process_for_popups) {
            $json = getJSONobj();
            $associated_javascript_data = '<script type="text/javascript">' . "\n" . 'var associated_javascript_data = ' . $json->encode($associated_row_data) . ";\n" . '</script>';
            $this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data);
        }
        $this->xTemplate->parse($xtemplateSection);
    }
Exemple #2
0
    /**
     * @return void
     * @param unknown $data
     * @param unknown $xTemplateSection
     * @param unknown $html_varName
     * @desc INTERNAL FUNCTION handles the rows
     * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
     * All Rights Reserved.
     * Contributor(s): ______________________________________..
     */
    function processListRows($data, $xtemplateSection, $html_varName)
    {
        global $odd_bg;
        global $even_bg;
        global $hilite_bg;
        global $app_strings, $sugar_version, $sugar_config;
        global $currentModule;
        static $overlib_included;
        if (!$overlib_included) {
            echo '<script type="text/javascript" src="include/javascript/sugar_grp_overlib.js"></script>
				<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
            $overlib_included = true;
        }
        $this->xTemplate->assign('BG_HILITE', $hilite_bg);
        $this->xTemplate->assign('CHECKALL', "<img src='" . SugarThemeRegistry::current()->getImageURL('blank.gif') . "' width=\"1\" height=\"1\" alt=\"\" />");
        //$this->xTemplate->assign("BG_CLICK", $click_bg);
        $oddRow = true;
        $count = 0;
        reset($data);
        //GETTING OFFSET
        $offset = $this->getOffset($html_varName);
        $timeStamp = $this->unique_id();
        $_SESSION[$html_varName . "_FROM_LIST_VIEW"] = $timeStamp;
        $associated_row_data = array();
        //mail merge list
        $mergeList = array();
        $module = '';
        //todo what is this?  It is using an array as a boolean
        while (list($aVal, $aItem) = each($data)) {
            if (isset($this->data_array)) {
                $fields = $this->data_array;
            } else {
                $aItem->check_date_relationships_load();
                $fields = $aItem->get_list_view_data();
            }
            if (is_object($aItem)) {
                // cn: bug 5349
                //add item id to merge list, if the button is clicked
                $mergeList[] = $aItem->id;
                if (empty($module)) {
                    $module = $aItem->module_dir;
                }
            }
            //ADD OFFSET TO ARRAY
            $fields['OFFSET'] = $offset + $count + 1;
            $fields['STAMP'] = $timeStamp;
            if ($this->shouldProcess) {
                $prerow = '';
                if (!isset($this->data_array)) {
                    $prerow .= "<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='" . $fields['ID'] . "'>";
                }
                $this->xTemplate->assign('PREROW', $prerow);
                $this->xTemplate->assign('CHECKALL', "<input type='checkbox' class='checkbox' name='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked)'>");
            }
            if (!isset($this->data_array)) {
                $tag = $aItem->listviewACLHelper();
                $this->xTemplate->assign('TAG', $tag);
            }
            if ($oddRow) {
                $ROW_COLOR = 'oddListRow';
                $BG_COLOR = $odd_bg;
            } else {
                $ROW_COLOR = 'evenListRow';
                $BG_COLOR = $even_bg;
            }
            $oddRow = !$oddRow;
            $this->xTemplate->assign('ROW_COLOR', $ROW_COLOR);
            $this->xTemplate->assign('BG_COLOR', $BG_COLOR);
            if (isset($this->data_array)) {
                $this->xTemplate->assign('KEY', $aVal);
                $this->xTemplate->assign('VALUE', $aItem);
                $this->xTemplate->assign('INDEX', $count);
            } else {
                //AED -- some modules do not have their additionalDetails.php established. Add a check to ensure require_once does not fail
                // Bug #2786
                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'))) {
                    $additionalDetailsFile = 'modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
                    if (file_exists('custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php')) {
                        $additionalDetailsFile = 'custom/modules/' . $aItem->module_dir . '/metadata/additionalDetails.php';
                    }
                    require_once $additionalDetailsFile;
                    $ad_function = (empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $aItem->object_name;
                    $results = $ad_function($fields);
                    $results['string'] = str_replace(array("&#039", "'"), '\\&#039', $results['string']);
                    // no xss!
                    if (trim($results['string']) == '') {
                        $results['string'] = $app_strings['LBL_NONE'];
                    }
                    $fields[$results['fieldToAddTo']] = $fields[$results['fieldToAddTo']] . '</a>';
                }
                $this->xTemplate->assign($html_varName, $fields);
                $aItem->setupCustomFields($aItem->module_dir);
                $aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
            }
            if (!isset($this->data_array) && $aItem->ACLAccess('DetailView')) {
                $count++;
            }
            if (isset($this->data_array)) {
                $count++;
            }
            if (!isset($this->data_array)) {
                $aItem->list_view_parse_additional_sections($this->xTemplate, $xtemplateSection);
                if ($this->xTemplate->exists($xtemplateSection . '.row.pro')) {
                    $this->xTemplate->parse($xtemplateSection . '.row.pro');
                }
            }
            $this->xTemplate->parse($xtemplateSection . '.row');
            if (isset($fields['ID'])) {
                $associated_row_data[$fields['ID']] = $fields;
            }
        }
        global $timedate;
        if (empty($timedate)) {
            $timedate = new TimeDate();
        }
        $microtime = $timedate->get_microtime_string();
        $_SESSION['MAILMERGE_RECORDS'] = $mergeList;
        $_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $module;
        if (empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
            $_SESSION['MAILMERGE_MODULE'] = $module;
        }
        if ($this->process_for_popups) {
            $json = getJSONobj();
            $is_show_fullname = showFullName() ? 1 : 0;
            $associated_javascript_data = '<script type="text/javascript">' . "\n" . 'var associated_javascript_data = ' . $json->encode($associated_row_data) . ";\n" . 'var is_show_fullname = ' . $is_show_fullname . ";\n" . '</script>';
            $this->xTemplate->assign('ASSOCIATED_JAVASCRIPT_DATA', $associated_javascript_data);
        }
        $this->xTemplate->parse($xtemplateSection);
    }