Ejemplo n.º 1
0
 /**
  * displays the tabs (top of the search form)
  *
  * @param string $currentKey key in $this->tabs to show as the current tab
  *
  * @return string html
  */
 function displayTabs($currentKey)
 {
     $GLOBALS['log']->debug('SearchForm.php->displayTabs(): tabs=' . print_r($this->tabs, true));
     $tabPanel = new SugarWidgetTabs($this->tabs, $currentKey, 'SUGAR.searchForm.searchFormSelect');
     if (isset($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select'] != '_none') {
         $saved_search = BeanFactory::getBean('SavedSearch');
         $saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']);
     }
     $str = $tabPanel->display();
     $str .= '<script>';
     if (!empty($_REQUEST['displayColumns'])) {
         $str .= 'SUGAR.savedViews.displayColumns = "' . $_REQUEST['displayColumns'] . '";';
     } elseif (isset($saved_search->contents['displayColumns']) && !empty($saved_search->contents['displayColumns'])) {
         $str .= 'SUGAR.savedViews.displayColumns = "' . $saved_search->contents['displayColumns'] . '";';
     }
     if (!empty($_REQUEST['hideTabs'])) {
         $str .= 'SUGAR.savedViews.hideTabs = "' . $_REQUEST['hideTabs'] . '";';
     } elseif (isset($saved_search->contents['hideTabs']) && !empty($saved_search->contents['hideTabs'])) {
         $str .= 'SUGAR.savedViews.hideTabs = "' . $saved_search->contents['hideTabs'] . '";';
     }
     if (!empty($_REQUEST['orderBy'])) {
         $str .= 'SUGAR.savedViews.selectedOrderBy = "' . $_REQUEST['orderBy'] . '";';
     } elseif (isset($saved_search->contents['orderBy']) && !empty($saved_search->contents['orderBy'])) {
         $str .= 'SUGAR.savedViews.selectedOrderBy = "' . $saved_search->contents['orderBy'] . '";';
     }
     if (!empty($_REQUEST['sortOrder'])) {
         $str .= 'SUGAR.savedViews.selectedSortOrder = "' . $_REQUEST['sortOrder'] . '";';
     } elseif (isset($saved_search->contents['sortOrder']) && !empty($saved_search->contents['sortOrder'])) {
         $str .= 'SUGAR.savedViews.selectedSortOrder = "' . $saved_search->contents['sortOrder'] . '";';
     }
     $str .= '</script>';
     return $str;
 }
Ejemplo n.º 2
0
    function display($showContainer = true, $forceTabless = false)
    {
        global $layout_edit_mode, $sugar_version, $sugar_config, $current_user, $app_strings;
        if (isset($layout_edit_mode) && $layout_edit_mode) {
            return;
        }
        global $modListHeader;
        ob_start();
        echo '<script type="text/javascript" src="' . getJSPath('include/SubPanel/SubPanelTiles.js') . '"></script>';
        ?>
<script>
if(document.DetailView != null &&
   document.DetailView.elements != null &&
   document.DetailView.elements.layout_def_key != null &&
   typeof document.DetailView.elements['layout_def_key'] != 'undefined'){
    document.DetailView.elements['layout_def_key'].value = '<?php 
        echo $this->layout_def_key;
        ?>
';
}
</script>
<?php 
        $tabs = array();
        $default_div_display = 'inline';
        if (!empty($sugar_config['hide_subpanels_on_login'])) {
            if (!isset($_SESSION['visited_details'][$this->focus->module_dir])) {
                setcookie($this->focus->module_dir . '_divs', '');
                unset($_COOKIE[$this->focus->module_dir . '_divs']);
                $_SESSION['visited_details'][$this->focus->module_dir] = true;
            }
            $default_div_display = 'none';
        }
        $div_cookies = get_sub_cookies($this->focus->module_dir . '_divs');
        //Display the group header. this section is executed only if the tabbed interface is being used.
        $current_key = '';
        if (!empty($this->show_tabs)) {
            require_once 'include/tabs.php';
            $tab_panel = new SugarWidgetTabs($tabs, $current_key, 'showSubPanel');
            echo get_form_header('Related', '', false);
            echo "<br />" . $tab_panel->display();
        }
        if (empty($_REQUEST['subpanels'])) {
            $selected_group = $forceTabless ? '' : $this->getSelectedGroup();
            $usersLayout = $current_user->getPreference('subpanelLayout', $this->focus->module_dir);
            // we need to use some intelligence here when restoring the user's layout, as new modules with new subpanels might have been installed since the user's layout was recorded
            // this means that we can't just restore the old layout verbatim as the new subpanels would then go walkabout
            // so we need to do a merge while attempting as best we can to preserve the sense of the specified order
            // this is complicated by the different ordering schemes used in the two sources for the panels: the user's layout uses an ordinal layout, the panels from getTabs have an explicit ordering driven by the 'order' parameter
            // it's not clear how to best reconcile these two schemes; so we punt on it, and add all new panels to the end of the user's layout. At least this will give them a clue that something has changed...
            // we also now check for tabs that have been removed since the user saved his or her preferences.
            $tabs = $this->getTabs($showContainer, $selected_group);
            if (!empty($usersLayout)) {
                $availableTabs = $tabs;
                $tabs = array_intersect($usersLayout, $availableTabs);
                // remove any tabs that have been removed since the user's layout was saved
                foreach (array_diff($availableTabs, $usersLayout) as $tab) {
                    $tabs[] = $tab;
                }
            }
        } else {
            $tabs = explode(',', $_REQUEST['subpanels']);
        }
        $tab_names = array();
        if ($showContainer) {
            echo '<ul class="noBullet" id="subpanel_list">';
        }
        //echo "<li id='hidden_0' style='height: 5px' class='noBullet'>&nbsp;&nbsp;&nbsp;</li>";
        if (empty($GLOBALS['relationships'])) {
            if (!class_exists('Relationship')) {
                require 'modules/Relationships/Relationship.php';
            }
            $rel = new Relationship();
            $rel->load_relationship_meta();
        }
        // this array will store names of sub-panels that can contain items
        // of each module
        $module_sub_panels = array();
        foreach ($tabs as $tab) {
            //load meta definition of the sub-panel.
            $thisPanel = $this->subpanel_definitions->load_subpanel($tab);
            if ($thisPanel === false) {
                continue;
            }
            //this if-block will try to skip over ophaned subpanels. Studio/MB are being delete unloaded modules completely.
            //this check will ignore subpanels that are collections (activities, history, etc)
            if (!isset($thisPanel->_instance_properties['collection_list']) and isset($thisPanel->_instance_properties['get_subpanel_data'])) {
                //ignore when data source is a function
                if (!isset($this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']])) {
                    if (stripos($thisPanel->_instance_properties['get_subpanel_data'], 'function:') === false) {
                        Log::fatal("Bad subpanel definition, it has incorrect value for get_subpanel_data property " . $tab);
                        continue;
                    }
                } else {
                    $rel_name = '';
                    if (isset($this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']]['relationship'])) {
                        $rel_name = $this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']]['relationship'];
                    }
                    if (empty($rel_name) or !isset($GLOBALS['relationships'][$rel_name])) {
                        Log::fatal("Missing relationship definition " . $rel_name . ". skipping " . $tab . " subpanel");
                        continue;
                    }
                }
            }
            if ($thisPanel->isCollection()) {
                // collect names of sub-panels that may contain items of each module
                $collection_list = $thisPanel->get_inst_prop_value('collection_list');
                if (is_array($collection_list)) {
                    foreach ($collection_list as $data) {
                        if (!empty($data['module'])) {
                            $module_sub_panels[$data['module']][$tab] = true;
                        }
                    }
                }
            } else {
                $module = $thisPanel->get_module_name();
                if (!empty($module)) {
                    $module_sub_panels[$module][$tab] = true;
                }
            }
            echo '<li class="noBullet" id="whole_subpanel_' . $tab . '">';
            $display = 'none';
            $div_display = $default_div_display;
            $cookie_name = $tab . '_v';
            if (isset($thisPanel->_instance_properties['collapsed']) && $thisPanel->_instance_properties['collapsed']) {
                $div_display = 'none';
            }
            if (isset($div_cookies[$cookie_name])) {
                //If defaultSubPanelExpandCollapse is set, ignore the cookie that remembers whether the panel is expanded or collapsed.
                //To be used with the above 'collapsed' metadata setting so they will always be set the same when the page is loaded.
                if (!isset($sugar_config['defaultSubPanelExpandCollapse']) || $sugar_config['defaultSubPanelExpandCollapse'] == false) {
                    $div_display = $div_cookies[$cookie_name];
                }
            }
            if (!empty($sugar_config['hide_subpanels'])) {
                $div_display = 'none';
            }
            if ($thisPanel->isDefaultHidden()) {
                $div_display = 'none';
            }
            if ($div_display == 'none') {
                $opp_display = 'inline';
            } else {
                $opp_display = 'none';
            }
            if (!empty($this->layout_def_key)) {
                $layout_def_key = $this->layout_def_key;
            } else {
                $layout_def_key = '';
            }
            if (empty($this->show_tabs)) {
                $show_icon_html = SugarThemeRegistry::current()->getImage('advanced_search', 'border="0" align="absmiddle"', null, null, '.gif', translate('LBL_SHOW'));
                $hide_icon_html = SugarThemeRegistry::current()->getImage('basic_search', 'border="0" align="absmiddle"', null, null, '.gif', translate('LBL_HIDE'));
                $max_min = "<a name=\"{$tab}\"> </a><span id=\"show_link_" . $tab . "\" style=\"display: {$opp_display}\"><a href='#' class='utilsLink' onclick=\"current_child_field = '" . $tab . "';showSubPanel('" . $tab . "',null,null,'" . $layout_def_key . "');document.getElementById('show_link_" . $tab . "').style.display='none';document.getElementById('hide_link_" . $tab . "').style.display='';return false;\">" . "" . $show_icon_html . "</a></span>";
                $max_min .= "<span id=\"hide_link_" . $tab . "\" style=\"display: {$div_display}\"><a href='#' class='utilsLink' onclick=\"hideSubPanel('" . $tab . "');document.getElementById('hide_link_" . $tab . "').style.display='none';document.getElementById('show_link_" . $tab . "').style.display='';return false;\">" . "" . $hide_icon_html . "</a></span>";
                echo '<div id="subpanel_title_' . $tab . '"';
                if (empty($sugar_config['lock_subpanels']) || $sugar_config['lock_subpanels'] == false) {
                    echo ' onmouseover="this.style.cursor = \'move\';"';
                }
                echo '>' . get_form_header($thisPanel->get_title(), $max_min, false) . '</div>';
            }
            echo <<<EOQ
<div cookie_name="{$cookie_name}" id="subpanel_{$tab}" style="display:{$div_display}">
    <script>document.getElementById("subpanel_{$tab}" ).cookie_name="{$cookie_name}";</script>
EOQ;
            $display_spd = '';
            if ($div_display != 'none') {
                echo "<script>SUGAR.util.doWhen(\"typeof(markSubPanelLoaded) != 'undefined'\", function() {markSubPanelLoaded('{$tab}');});</script>";
                $old_contents = ob_get_contents();
                @ob_end_clean();
                ob_start();
                include_once 'include/SubPanel/SubPanel.php';
                $subpanel_object = new SubPanel($this->module, $_REQUEST['record'], $tab, $thisPanel, $layout_def_key);
                $subpanel_object->setTemplateFile('include/SubPanel/SubPanelDynamic.html');
                $subpanel_object->display();
                $subpanel_data = ob_get_contents();
                @ob_end_clean();
                ob_start();
                echo $this->get_buttons($thisPanel, $subpanel_object->subpanel_query);
                $buttons = ob_get_contents();
                @ob_end_clean();
                ob_start();
                echo $old_contents;
                //echo $buttons;
                $display_spd = $subpanel_data;
            }
            echo <<<EOQ
    <div id="list_subpanel_{$tab}">{$display_spd}</div>
</div>
EOQ;
            array_push($tab_names, $tab);
            echo '</li>';
        }
        // end $tabs foreach
        if ($showContainer) {
            echo '</ul>';
            if (!empty($selected_group)) {
                // closing table from tpls/singletabmenu.tpl
                echo '</td></tr></table>';
            }
        }
        // drag/drop code
        $tab_names = '["' . join($tab_names, '","') . '"]';
        global $sugar_config;
        if (empty($sugar_config['lock_subpanels']) || $sugar_config['lock_subpanels'] == false) {
            echo <<<EOQ
    <script>
    \tvar SubpanelInit = function() {
    \t\tSubpanelInitTabNames({$tab_names});
    \t}
        var SubpanelInitTabNames = function(tabNames) {
    \t\tsubpanel_dd = new Array();
    \t\tj = 0;
    \t\tfor(i in tabNames) {
    \t\t\tsubpanel_dd[j] = new ygDDList('whole_subpanel_' + tabNames[i]);
    \t\t\tsubpanel_dd[j].setHandleElId('subpanel_title_' + tabNames[i]);
    \t\t\tsubpanel_dd[j].onMouseDown = SUGAR.subpanelUtils.onDrag;
    \t\t\tsubpanel_dd[j].afterEndDrag = SUGAR.subpanelUtils.onDrop;
    \t\t\tj++;
    \t\t}

    \t\tYAHOO.util.DDM.mode = 1;
    \t}
    \tcurrentModule = '{$this->module}';
    \tSUGAR.util.doWhen(
    \t    "typeof(SUGAR.subpanelUtils) == 'object' && typeof(SUGAR.subpanelUtils.onDrag) == 'function'" +
    \t        " && document.getElementById('subpanel_list')",
    \t    SubpanelInit
    \t);
    </script>
EOQ;
        }
        $module_sub_panels = array_map('array_keys', $module_sub_panels);
        $module_sub_panels = json_encode($module_sub_panels);
        echo <<<EOQ
<script>
var ModuleSubPanels = {$module_sub_panels};
</script>
EOQ;
        $ob_contents = ob_get_contents();
        ob_end_clean();
        return $ob_contents;
    }
Ejemplo n.º 3
0
 function display($showContainer = true, $forceTabless = false)
 {
     global $layout_edit_mode, $sugar_version, $sugar_config, $current_user, $app_strings, $modListHeader;
     if (isset($layout_edit_mode) && $layout_edit_mode) {
         return;
     }
     $template = new Sugar_Smarty();
     $template_header = "";
     $template_body = "";
     $template_footer = "";
     $tabs = array();
     $tabs_properties = array();
     $tab_names = array();
     $default_div_display = 'inline';
     if (!empty($sugar_config['hide_subpanels_on_login'])) {
         if (!isset($_SESSION['visited_details'][$this->focus->module_dir])) {
             setcookie($this->focus->module_dir . '_divs', '', 0, null, null, false, true);
             unset($_COOKIE[$this->focus->module_dir . '_divs']);
             $_SESSION['visited_details'][$this->focus->module_dir] = true;
         }
         $default_div_display = 'none';
     }
     $div_cookies = get_sub_cookies($this->focus->module_dir . '_divs');
     if (empty($_REQUEST['subpanels'])) {
         $selected_group = $forceTabless ? '' : $this->getSelectedGroup();
         $usersLayout = $current_user->getPreference('subpanelLayout', $this->focus->module_dir);
         // we need to use some intelligence here when restoring the user's layout, as new modules with new subpanels might have been installed since the user's layout was recorded
         // this means that we can't just restore the old layout verbatim as the new subpanels would then go walkabout
         // so we need to do a merge while attempting as best we can to preserve the sense of the specified order
         // this is complicated by the different ordering schemes used in the two sources for the panels: the user's layout uses an ordinal layout, the panels from getTabs have an explicit ordering driven by the 'order' parameter
         // it's not clear how to best reconcile these two schemes; so we punt on it, and add all new panels to the end of the user's layout. At least this will give them a clue that something has changed...
         // we also now check for tabs that have been removed since the user saved his or her preferences.
         $tabs = $this->getTabs($showContainer, $selected_group);
         if (!empty($usersLayout)) {
             $availableTabs = $tabs;
             $tabs = array_intersect($usersLayout, $availableTabs);
             // remove any tabs that have been removed since the user's layout was saved
             foreach (array_diff($availableTabs, $usersLayout) as $tab) {
                 $tabs[] = $tab;
             }
         }
     } else {
         $tabs = explode(',', $_REQUEST['subpanels']);
     }
     // Display the group header. this section is executed only if the tabbed interface is being used.
     $current_key = '';
     if (!empty($this->show_tabs)) {
         require_once 'include/tabs.php';
         $tab_panel = new SugarWidgetTabs($tabs, $current_key, 'showSubPanel');
         $template_header .= get_form_header('Related', '', false);
         $template_header .= $tab_panel->display();
     }
     if (empty($GLOBALS['relationships'])) {
         if (!class_exists('Relationship')) {
             require 'modules/Relationships/Relationship.php';
         }
         $rel = new Relationship();
         $rel->load_relationship_meta();
     }
     foreach ($tabs as $t => $tab) {
         // load meta definition of the sub-panel.
         $thisPanel = $this->subpanel_definitions->load_subpanel($tab);
         if ($thisPanel === false) {
             continue;
         }
         // this if-block will try to skip over ophaned subpanels. Studio/MB are being delete unloaded modules completely.
         // this check will ignore subpanels that are collections (activities, history, etc)
         if (!isset($thisPanel->_instance_properties['collection_list']) and isset($thisPanel->_instance_properties['get_subpanel_data'])) {
             // ignore when data source is a function
             if (!isset($this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']])) {
                 if (stripos($thisPanel->_instance_properties['get_subpanel_data'], 'function:') === false) {
                     $GLOBALS['log']->fatal("Bad subpanel definition, it has incorrect value for get_subpanel_data property " . $tab);
                     continue;
                 }
             } else {
                 $rel_name = '';
                 if (isset($this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']]['relationship'])) {
                     $rel_name = $this->focus->field_defs[$thisPanel->_instance_properties['get_subpanel_data']]['relationship'];
                 }
                 if (empty($rel_name) or !isset($GLOBALS['relationships'][$rel_name])) {
                     $GLOBALS['log']->fatal("Missing relationship definition " . $rel_name . ". skipping " . $tab . " subpanel");
                     continue;
                 }
             }
         }
         if ($thisPanel->isCollection()) {
             // collect names of sub-panels that may contain items of each module
             $collection_list = $thisPanel->get_inst_prop_value('collection_list');
             if (is_array($collection_list)) {
                 foreach ($collection_list as $data) {
                     if (!empty($data['module'])) {
                         $module_sub_panels[$data['module']][$tab] = true;
                     }
                 }
             }
         } else {
             $module = $thisPanel->get_module_name();
             if (!empty($module)) {
                 $module_sub_panels[$module][$tab] = true;
             }
         }
         $display = 'none';
         $div_display = $default_div_display;
         $cookie_name = $tab . '_v';
         if (isset($thisPanel->_instance_properties['collapsed']) && $thisPanel->_instance_properties['collapsed']) {
             $div_display = 'none';
         }
         if (isset($div_cookies[$cookie_name])) {
             // If defaultSubPanelExpandCollapse is set, ignore the cookie that remembers whether the panel is expanded or collapsed.
             // To be used with the above 'collapsed' metadata setting so they will always be set the same when the page is loaded.
             if (!isset($sugar_config['defaultSubPanelExpandCollapse']) || $sugar_config['defaultSubPanelExpandCollapse'] == false) {
                 $div_display = $div_cookies[$cookie_name];
             }
         }
         if (!empty($sugar_config['hide_subpanels']) or $thisPanel->isDefaultHidden()) {
             $div_display = 'none';
         }
         if ($div_display == 'none') {
             $opp_display = 'inline';
             $tabs_properties[$t]['expanded_subpanels'] = false;
         } else {
             $opp_display = 'none';
             $tabs_properties[$t]['expanded_subpanels'] = true;
         }
         if (!empty($this->layout_def_key)) {
             $layout_def_key = $this->layout_def_key;
         } else {
             $layout_def_key = '';
         }
         if (empty($this->show_tabs)) {
             ///
             /// Legacy Support for subpanels
             $show_icon_html = SugarThemeRegistry::current()->getImage('advanced_search', 'border="0" align="absmiddle"', null, null, '.gif', translate('LBL_SHOW'));
             $hide_icon_html = SugarThemeRegistry::current()->getImage('basic_search', 'border="0" align="absmiddle"', null, null, '.gif', translate('LBL_HIDE'));
             $tabs_properties[$t]['show_icon_html'] = $show_icon_html;
             $tabs_properties[$t]['hide_icon_html'] = $hide_icon_html;
             $max_min = "<a name=\"{$tab}\"> </a><span id=\"show_link_" . $tab . "\" style=\"display: {$opp_display}\"><a href='#' class='utilsLink' onclick=\"current_child_field = '" . $tab . "';showSubPanel('" . $tab . "',null,null,'" . $layout_def_key . "');document.getElementById('show_link_" . $tab . "').style.display='none';document.getElementById('hide_link_" . $tab . "').style.display='';return false;\">" . "" . $show_icon_html . "</a></span>";
             $max_min .= "<span id=\"hide_link_" . $tab . "\" style=\"display: {$div_display}\"><a href='#' class='utilsLink' onclick=\"hideSubPanel('" . $tab . "');document.getElementById('hide_link_" . $tab . "').style.display='none';document.getElementById('show_link_" . $tab . "').style.display='';return false;\">" . "" . $hide_icon_html . "</a></span>";
             $tabs_properties[$t]['title'] = $thisPanel->get_title();
             $tabs_properties[$t]['module_name'] = $thisPanel->get_module_name();
             $tabs_properties[$t]['get_form_header'] = get_form_header($thisPanel->get_title(), $max_min, false, false);
         }
         $tabs_properties[$t]['cookie_name'] = $cookie_name;
         $tabs_properties[$t]['div_display'] = $div_display;
         $tabs_properties[$t]['opp_display'] = $opp_display;
         // Get Subpanel
         include_once 'include/SubPanel/SubPanel.php';
         $subpanel_object = new SubPanel($this->module, $_REQUEST['record'], $tab, $thisPanel, $layout_def_key);
         $arr = array();
         // TODO: Remove x-template:
         $tabs_properties[$t]['subpanel_body'] = $subpanel_object->ProcessSubPanelListView('include/SubPanel/SubPanelDynamic.html', $arr);
         // Get subpanel buttons
         $tabs_properties[$t]['buttons'] = $this->get_buttons($thisPanel, $subpanel_object->subpanel_query);
         array_push($tab_names, $tab);
     }
     $tab_names = '["' . join($tab_names, '","') . '"]';
     $module_sub_panels = array_map('array_keys', $module_sub_panels);
     $module_sub_panels = json_encode($module_sub_panels);
     $template->assign('layout_def_key', $this->layout_def_key);
     $template->assign('show_subpanel_tabs', $this->show_tabs);
     $template->assign('subpanel_tabs', $tabs);
     $template->assign('subpanel_tabs_properties', $tabs_properties);
     $template->assign('module_sub_panels', $module_sub_panels);
     $template->assign('sugar_config', $sugar_config);
     $template->assign('REQUEST', $_REQUEST);
     $template->assign('GLOBALS', $GLOBALS);
     $template->assign('selected_group', $selected_group);
     $template->assign('tab_names', $tab_names);
     $template->assign('module_sub_panels', $module_sub_panels);
     $template->assign('module', $this->module);
     $template_body = $template->fetch('include/SubPanel/tpls/SubPanelTiles.tpl');
     return $template_header . $template_body . $template_footer;
 }
Ejemplo n.º 4
0
function template_reports_report(&$reporter, &$args)
{
    global $current_user;
    global $current_language;
    global $mod_strings, $app_strings;
    global $sugar_config, $sugar_version;
    $sort_by = '';
    $sort_dir = '';
    $summary_sort_by = '';
    $summary_sort_dir = '';
    $report_type = '';
    $smarty = new Sugar_Smarty();
    if (isset($reporter->report_def['order_by'][0]['name']) && isset($reporter->report_def['order_by'][0]['table_key'])) {
        $sort_by = $reporter->report_def['order_by'][0]['table_key'] . ":" . $reporter->report_def['order_by'][0]['name'];
    }
    // if
    if (isset($reporter->report_def['order_by'][0]['sort_dir'])) {
        $sort_dir = $reporter->report_def['order_by'][0]['sort_dir'];
    }
    // if
    if (!empty($reporter->report_def['summary_order_by'][0]['group_function']) && $reporter->report_def['summary_order_by'][0]['group_function'] == 'count') {
        $summary_sort_by = $reporter->report_def['summary_order_by'][0]['table_key'] . ":" . 'count';
    } else {
        if (isset($reporter->report_def['summary_order_by'][0]['name'])) {
            $summary_sort_by = $reporter->report_def['summary_order_by'][0]['table_key'] . ":" . $reporter->report_def['summary_order_by'][0]['name'];
            if (!empty($reporter->report_def['summary_order_by'][0]['group_function'])) {
                $summary_sort_by .= ":" . $reporter->report_def['summary_order_by'][0]['group_function'];
            } else {
                if (!empty($reporter->report_def['summary_order_by'][0]['column__function'])) {
                    $summary_sort_by .= ":" . $reporter->report_def['summary_order_by'][0]['column_function'];
                }
            }
            // else if
        }
    }
    // else if
    if (isset($reporter->report_def['summary_order_by'][0]['sort_dir'])) {
        $summary_sort_dir = $reporter->report_def['summary_order_by'][0]['sort_dir'];
    }
    // if
    if (isset($reporter->report_def['report_type'])) {
        $report_type = $reporter->report_def['report_type'];
    }
    // if
    $issetSaveResults = false;
    $isSaveResults = false;
    if (isset($args['save_result'])) {
        $issetSaveResults = true;
        $smarty->assign('save_report_as_str', $_REQUEST['save_report_as']);
        if ($args['save_result']) {
            $isSaveResults = true;
        }
        // if
    }
    // if
    $smarty->assign('mod_strings', $mod_strings);
    $smarty->assign('app_strings', $app_strings);
    $smarty->assign('current_language', $current_language);
    $smarty->assign('sugar_config', $sugar_config);
    $smarty->assign('sugar_version', $sugar_version);
    $smarty->assign('issetSaveResults', $issetSaveResults);
    $smarty->assign('isSaveResults', $isSaveResults);
    $smarty->assign('report_type', $report_type);
    $form_header = get_form_header($mod_strings['LBL_TITLE'] . ": " . $args['reporter']->saved_report->name, "", false);
    $smarty->assign('form_header', $form_header);
    $smarty->assign('report_offset', $reporter->report_offset);
    $smarty->assign('sort_by', $sort_by);
    $smarty->assign('sort_dir', $sort_dir);
    $smarty->assign('summary_sort_by', $summary_sort_by);
    $smarty->assign('summary_sort_dir', $summary_sort_dir);
    if (isset($_REQUEST['save_as']) && $_REQUEST['save_as'] == 'true') {
        $report_id = '';
    } else {
        if (isset($reporter->saved_report->id)) {
            $report_id = $reporter->saved_report->id;
        } elseif (!empty($_REQUEST['record'])) {
            $report_id = $_REQUEST['record'];
        } else {
            $report_id = '';
        }
    }
    // else
    $smarty->assign('report_id', $report_id);
    $smarty->assign('to_pdf', isset($_REQUEST['to_pdf']) ? $_REQUEST['to_pdf'] : "");
    $smarty->assign('to_csv', isset($_REQUEST['to_csv']) ? $_REQUEST['to_csv'] : "");
    if (!empty($args['reporter']->saved_report)) {
        $context = array("bean" => $args['reporter']->saved_report);
    } else {
        $context = array();
    }
    $report_edit_access = SugarACL::checkAccess('Reports', 'edit', $context);
    $smarty->assign('report_edit_access', $report_edit_access);
    $report_delete_access = SugarACL::checkAccess('Reports', 'delete', $context);
    $smarty->assign('report_delete_access', $report_delete_access);
    $report_export_access = SugarACL::checkAccess('Reports', 'export', $context);
    $smarty->assign('report_export_access', $report_export_access);
    $smarty->assign('form_submit', empty($_REQUEST['form_submit']) ? false : $_REQUEST['form_submit']);
    $global_json = getJSONobj();
    global $ACLAllowedModules;
    $ACLAllowedModules = getACLAllowedModules();
    $smarty->assign('ACLAllowedModules', $global_json->encode(array_keys($ACLAllowedModules)));
    require_once 'include/tabs.php';
    $tabs = array();
    array_push($tabs, array('title' => $mod_strings['LBL_1_REPORT_ON'], 'link' => 'module_join_tab', 'key' => 'module_join_tab'));
    array_push($tabs, array('title' => $mod_strings['LBL_2_FILTER'], 'link' => 'filters_tab', 'key' => 'filters_tab'));
    //array_push($tabs,array('title'=>$mod_strings['LBL_3_GROUP'],'link'=>'group_by_tab','key'=>'group_by_tab'));
    //array_push($tabs,array('title'=>$mod_strings['LBL_3_CHOOSE'],'link'=>'columns_tab','key'=>'columns_tab'));
    if ($args['reporter']->report_type == 'tabular') {
        array_push($tabs, array('title' => $mod_strings['LBL_3_GROUP'], 'hidden' => true, 'link' => 'group_by_tab', 'key' => 'group_by_tab'));
        array_push($tabs, array('title' => $mod_strings['LBL_3_CHOOSE'], 'link' => 'columns_tab', 'key' => 'columns_tab'));
        array_push($tabs, array('title' => $mod_strings['LBL_5_CHART_OPTIONS'], 'hidden' => true, 'link' => 'chart_options_tab', 'key' => 'chart_options_tab'));
    } else {
        array_push($tabs, array('title' => $mod_strings['LBL_3_GROUP'], 'link' => 'group_by_tab', 'key' => 'group_by_tab'));
        array_push($tabs, array('title' => $mod_strings['LBL_4_CHOOSE'], 'link' => 'columns_tab', 'key' => 'columns_tab'));
        array_push($tabs, array('title' => $mod_strings['LBL_5_CHART_OPTIONS'], 'link' => 'chart_options_tab', 'key' => 'chart_options_tab'));
    }
    $current_key = 'module_join_tab';
    $tab_panel = new SugarWidgetTabs($tabs, $current_key, 'showReportTab');
    $smarty->assign('tab_panel_display', $tab_panel->display());
    template_reports_tables($smarty, $args);
    if ($reporter->report_type == 'summary') {
        $summary_display = '';
        if ($reporter->show_columns) {
            $column_display = '';
        } else {
            $column_display = 'none';
        }
        // else
    } else {
        $summary_display = 'none';
        $column_display = '';
    }
    // else
    $summary_join_selector = '&nbsp;<div style="padding-bottom:2px">' . $mod_strings['LBL_MODULE'] . ': <select onChange="viewJoinChanged(this);" id="view_join_summary" name="view_join_summary"></select></div>';
    $chooser_args_summary = array('id' => 'summary_table', 'title' => $mod_strings['LBL_CHOOSE_SUMMARIES'] . ':', 'left_name' => 'display_summary', 'right_name' => 'hidden_summary', 'left_label' => $mod_strings['LBL_DISPLAY_SUMMARIES'], 'right_label' => $summary_join_selector, 'display' => $summary_display, 'onmoveleft' => 'reload_columns(\'join\')', 'onmoveright' => 'reload_columns(\'join\')');
    $join_selector = '&nbsp;<div style="padding-bottom:2px">' . $mod_strings['LBL_MODULE'] . ': <select onChange="viewJoinChanged(this);" id="view_join" name="view_join"></select></div>';
    $chooser_args = array('id' => 'columns_table', 'title' => $mod_strings['LBL_CHOOSE_COLUMNS'] . ':', 'left_name' => 'display_columns', 'right_name' => 'hidden_columns', 'left_label' => $mod_strings['LBL_DISPLAY_COLUMNS'], 'right_label' => $join_selector, 'display' => $column_display, 'topleftcontent' => $join_selector, 'onmoveleft' => 'reload_columns(\'join\')', 'onmoveright' => 'reload_columns(\'join\')');
    $smarty->assign('template_grups_choosers1', template_groups_chooser($chooser_args_summary));
    if ($summary_display == 'none') {
        $smarty->assign('summary_display_style', "display:none");
    }
    // if
    if ($reporter->show_columns) {
        $smarty->assign('show_columns_reports', true);
    }
    // if
    $smarty->assign('column_display', $column_display);
    $smarty->assign('template_grups_choosers2', template_groups_chooser($chooser_args));
    template_reports_filters($smarty, $args);
    $smarty->assign('reporter_report_type', $args['reporter']->report_type);
    template_reports_group_by($smarty, $args);
    template_reports_chart_options($smarty, $args);
    $smarty->assign('md5_current_user_id', md5($current_user->id));
    $smarty->assign('args_image_path', $args['IMAGE_PATH']);
    template_reports_request_vars_js($smarty, $reporter, $args);
    $smarty->assign('cache_path', sugar_cached(''));
    // Set fiscal start date
    $admin = BeanFactory::getBean('Administration');
    $config = $admin->getConfigForModule('Forecasts', 'base');
    if (!empty($config['is_setup']) && !empty($config['timeperiod_start_date'])) {
        $smarty->assign("fiscalStartDate", $config['timeperiod_start_date']);
    }
    $smarty->assign('ENTROPY', mt_rand());
    echo $smarty->fetch("modules/Reports/templates/_template_reports_report.tpl");
    ob_start();
    ?>
<script language="javascript">
if(typeof YAHOO != 'undefined') YAHOO.util.Event.addListener(window, 'load', load_page);
</script>
<?php 
    reportResults($reporter, $args);
    /*
    $do_chart = false;
    
    $dbStart = microtime();
    
    if ($reporter->report_type == 'summary' && ! empty($reporter->report_def['summary_columns'])) {
    if ($reporter->show_columns &&
    	!empty($reporter->report_def['display_columns']) &&
            !empty($reporter->report_def['group_defs'])) {
    
    	template_summary_combo_view($reporter,$args);
    	$do_chart = true;
    
        } else if($reporter->show_columns &&
              !empty($reporter->report_def['display_columns']) &&
              	   empty($reporter->report_def['group_defs'])) {
    	template_detail_and_total_list_view($reporter,$args);
    } else if (!empty($reporter->report_def['group_defs'])) {
    	template_summary_list_view($reporter,$args);
    	$do_chart = true;
    } else {
    	template_total_view($reporter,$args);
    } // else
    } else if (!empty($reporter->report_def['display_columns'])) {
    template_list_view($reporter,$args);
    } // else if
    
    if ($reporter->report_def['chart_type']== 'none') {
    $do_chart = false;
    }
    echo "time = " . microtime_diff($dbStart, microtime())."s ";
    ?>
    </div>
    <?php
    $contents = ob_get_contents();
    ob_end_clean();
    
    if ($do_chart) {
       		template_chart($reporter);
    } // if
    
    print $contents;
    */
}
Ejemplo n.º 5
0
 /**
  * displays the tabs (top of the search form)
  * 
  * @param string $currentKey key in $this->tabs to show as the current tab
  * 
  * @return string html
  */
 function displayTabs($currentKey)
 {
     if (substr_count($currentKey, 'advanced_search') > 0) {
         $this->tabs[2]['hidden'] = false;
     }
     $tabPanel = new SugarWidgetTabs($this->tabs, $currentKey, 'SUGAR.searchForm.searchFormSelect');
     $str = $tabPanel->display();
     $str .= '<script>';
     if (!empty($_REQUEST['displayColumns'])) {
         $str .= 'SUGAR.savedViews.displayColumns = "' . $_REQUEST['displayColumns'] . '";';
     }
     if (!empty($_REQUEST['hideTabs'])) {
         $str .= 'SUGAR.savedViews.hideTabs = "' . $_REQUEST['hideTabs'] . '";';
     }
     if (!empty($_REQUEST['orderBy'])) {
         $str .= 'SUGAR.savedViews.selectedOrderBy = "' . $_REQUEST['orderBy'] . '";';
     }
     if (!empty($_REQUEST['sortOrder'])) {
         $str .= 'SUGAR.savedViews.selectedSortOrder = "' . $_REQUEST['sortOrder'] . '";';
     }
     $str .= '</script>';
     return $str;
 }
Ejemplo n.º 6
0
 function ConnectorWidgetTabs(&$tabs, $current_key, $jscallback, $class = 'tablist')
 {
     parent::SugarWidgetTabs($tabs, $current_key, $jscallback);
     $this->class = $class;
 }
    function display($showContainer = true, $forceTabless = false)
    {
        global $layout_edit_mode, $sugar_version, $sugar_config, $current_user, $app_strings;
        if (isset($layout_edit_mode) && $layout_edit_mode) {
            return;
        }
        global $modListHeader;
        ob_start();
        echo '<script type="text/javascript" src="include/javascript/popup_parent_helper.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>';
        echo '<script type="text/javascript" src="include/SubPanel/SubPanelTiles.js?s=' . $sugar_version . '&c=' . $sugar_config['js_custom_version'] . '"></script>';
        ?>
<script>
if(document.DetailView != null && 
   document.DetailView.elements != null && 
   document.DetailView.elements.layout_def_key != null && 
   typeof document.DetailView.elements['layout_def_key'] != 'undefined'){
    document.DetailView.elements['layout_def_key'].value = '<?php 
        echo $this->layout_def_key;
        ?>
';
}
</script>
<?php 
        $tabs = array();
        $default_div_display = 'inline';
        if (!empty($sugar_config['hide_subpanels_on_login'])) {
            if (!isset($_SESSION['visited_details'][$this->focus->module_dir])) {
                setcookie($this->focus->module_dir . '_divs', '');
                unset($_COOKIE[$this->focus->module_dir . '_divs']);
                $_SESSION['visited_details'][$this->focus->module_dir] = true;
            }
            $default_div_display = 'none';
        }
        $div_cookies = get_sub_cookies($this->focus->module_dir . '_divs');
        //Display the group header. this section is executed only if the tabbed interface is being used.
        $current_key = '';
        if (!empty($this->show_tabs)) {
            require_once 'include/tabs.php';
            $tab_panel = new SugarWidgetTabs($tabs, $current_key, 'showSubPanel');
            echo get_form_header('Related', '', false);
            echo "<br />" . $tab_panel->display();
        }
        if (empty($_REQUEST['subpanels'])) {
            $selected_group = $forceTabless ? '' : $this->getSelectedGroup();
            $tabs = $this->getTabs($showContainer, $selected_group);
        } else {
            $tabs = explode(',', $_REQUEST['subpanels']);
        }
        $tab_names = array();
        if ($showContainer) {
            echo '<ul class="noBullet" id="subpanel_list">';
        }
        //echo "<li id='hidden_0' style='height: 5px' class='noBullet'>&nbsp;&nbsp;&nbsp;</li>";
        foreach ($tabs as $tab) {
            echo '<li class="noBullet" id="whole_subpanel_' . $tab . '">';
            //load meta definition of the sub-panel.
            $thisPanel = $this->subpanel_definitions->load_subpanel($tab);
            $display = 'none';
            $div_display = $default_div_display;
            $cookie_name = $tab . '_v';
            if (isset($div_cookies[$cookie_name])) {
                $div_display = $div_cookies[$cookie_name];
            }
            if (!empty($sugar_config['hide_subpanels'])) {
                $div_display = 'none';
            }
            if ($div_display == 'none') {
                $opp_display = 'inline';
            } else {
                $opp_display = 'none';
            }
            if (empty($this->show_tabs)) {
                global $theme;
                $theme_path = "themes/" . $theme . "/";
                $image_path = $theme_path . "images/";
                $show_icon_html = get_image($image_path . 'advanced_search', 'alt="' . translate('LBL_SHOW') . '" border="0 align="absmiddle""');
                $hide_icon_html = get_image($image_path . 'basic_search', 'alt="' . translate('LBL_HIDE') . '" border="0" align="absmiddle"');
                $max_min = "<a name=\"{$tab}\"> </a><span id=\"show_link_" . $tab . "\" style=\"display: {$opp_display}\"><a href='#' class='utilsLink' onclick=\"current_child_field = '" . $tab . "';showSubPanel('" . $tab . "');document.getElementById('show_link_" . $tab . "').style.display='none';document.getElementById('hide_link_" . $tab . "').style.display='';return false;\">" . "" . $show_icon_html . "</a></span>";
                $max_min .= "<span id=\"hide_link_" . $tab . "\" style=\"display: {$div_display}\"><a href='#' class='utilsLink' onclick=\"hideSubPanel('" . $tab . "');document.getElementById('hide_link_" . $tab . "').style.display='none';document.getElementById('show_link_" . $tab . "').style.display='';return false;\">" . "" . $hide_icon_html . "</a></span>";
                echo '<div id="subpanel_title_' . $tab . '"';
                if (empty($sugar_config['lock_subpanels']) || $sugar_config['lock_subpanels'] == false) {
                    echo ' onmouseover="this.style.cursor = \'move\';"';
                }
                echo '>' . get_form_header($thisPanel->get_title(), $max_min, false) . '</div>';
            }
            echo <<<EOQ
<div cookie_name="{$cookie_name}" id="subpanel_{$tab}" style="display:{$div_display}">
    <script>document.getElementById("subpanel_{$tab}" ).cookie_name="{$cookie_name}";</script>
EOQ;
            $display_spd = '';
            if ($div_display != 'none') {
                echo "<script>markSubPanelLoaded('{$tab}');</script>";
                $old_contents = ob_get_contents();
                @ob_end_clean();
                ob_start();
                include_once 'include/SubPanel/SubPanel.php';
                $subpanel_object = new SubPanel($this->module, $_REQUEST['record'], $tab, $thisPanel);
                $subpanel_object->setTemplateFile('include/SubPanel/SubPanelDynamic.html');
                $subpanel_object->display();
                $subpanel_data = ob_get_contents();
                @ob_end_clean();
                ob_start();
                echo $this->get_buttons($thisPanel, $subpanel_object->subpanel_query);
                $buttons = ob_get_contents();
                @ob_end_clean();
                ob_start();
                echo $old_contents;
                echo $buttons;
                $display_spd = $subpanel_data;
            }
            echo <<<EOQ
    <div id="list_subpanel_{$tab}">{$display_spd}</div>
</div>
EOQ;
            array_push($tab_names, $tab);
            echo '</li>';
        }
        // end $tabs foreach
        echo '<li style="height: 5px" class="noBullet">&nbsp;&nbsp;&nbsp;</li>';
        if ($showContainer) {
            echo '</ul>';
            if (!empty($selected_group)) {
                // closing table from tpls/singletabmenu.tpl
                echo '</td></tr></table>';
            }
        }
        // drag/drop code
        $tab_names = '["' . join($tab_names, '","') . '"]';
        global $sugar_config;
        if (empty($sugar_config['lock_subpanels']) || $sugar_config['lock_subpanels'] == false) {
            echo <<<EOQ
    <script>
    \tvar SubpanelInit = function() {
    \t\tSubpanelInitTabNames({$tab_names});
    \t}
        var SubpanelInitTabNames = function(tabNames) {
    \t\tsubpanel_dd = new Array();
    \t\tj = 0;
    \t\tfor(i in tabNames) {
    \t\t\tsubpanel_dd[j] = new ygDDList('whole_subpanel_' + tabNames[i]);
    \t\t\tsubpanel_dd[j].setHandleElId('subpanel_title_' + tabNames[i]);
    \t\t\tsubpanel_dd[j].onMouseDown = SUGAR.subpanelUtils.onDrag;  
    \t\t\tsubpanel_dd[j].afterEndDrag = SUGAR.subpanelUtils.onDrop;
    \t\t\tj++;
    \t\t}
    \t
    \t\tYAHOO.util.DDM.mode = 1;
    \t}
    \tcurrentModule = '{$this->module}'; 
    \tYAHOO.util.Event.addListener(window, 'load', SubpanelInit);
    </script>  
EOQ;
        }
        $ob_contents = ob_get_contents();
        ob_end_clean();
        return $ob_contents;
    }