Пример #1
0
function getSecondaryColumns($Options, $module, $ogReport = "")
{
    if ($ogReport == "") {
        if (ITS4YouReports::isStoredITS4YouReport() === true) {
            $ogReport = ITS4YouReports::getStoredITS4YouReport();
        } else {
            $ogReport = new ITS4YouReports($recordid);
        }
    }
    global $app_list_strings, $app_strings;
    global $current_language;
    $adb = PearDatabase::getInstance();
    if (!isset($ogReport->module_list) || empty($ogReport->module_list)) {
        $ogReport->initListOfModules();
    }
    if ($module != "") {
        $secmodule = explode(":", $module);
        for ($i = 0; $i < count($secmodule); $i++) {
            $module_prefix = $secmodule[$i];
            $secmodule_arr = explode("x", $secmodule[$i]);
            $module_id = $secmodule_arr[0];
            $field_id = isset($secmodule_arr[1]) && $secmodule_arr[1] != "" ? $secmodule_arr[1] : "";
            $fieldname = $opt_fieldname = "";
            $modulename = vtlib_getModuleNameById($module_id);
            if ($field_id != "" && is_numeric($field_id)) {
                $fieldname_row = $adb->fetchByAssoc($adb->pquery("SELECT fieldlabel FROM vtiger_field WHERE fieldid=?", array($field_id)), 0);
                $fieldname = " " . $fieldname_row["fieldlabel"];
                $opt_fieldname = " (" . vtranslate($fieldname_row["fieldlabel"], $ogReport->primarymodule) . ")";
            } elseif ($field_id == "INV") {
                $fieldname = " Inventory";
                $opt_fieldname = " (Inventory)";
            } elseif ($field_id == "MIF") {
                $fieldname = " More Information";
                $opt_fieldname = " (" . vtranslate('LBL_MORE_INFORMATION', "Users") . ")";
            }
            //$mod_strings = return_module_language($current_language, $modulename);
            if (vtlib_isModuleActive($modulename)) {
                $block_listed = array();
                if (isset($_REQUEST["primarymoduleid"]) && $_REQUEST["primarymoduleid"] == 26) {
                    $campaignstatus_listed = false;
                }
                foreach ($ogReport->module_list[$modulename] as $key => $value) {
                    if (!isset($ogReport->sec_module_columnslist)) {
                        $ogReport->getSecModuleColumnsList($module);
                    }
                    if (isset($ogReport->sec_module_columnslist[$modulename . $fieldname][$value]) && !$block_listed[$value]) {
                        $block_listed[$value] = true;
                        $optgroup = $app_list_strings['moduleList'][$modulename] . " - " . vtranslate($value) . $opt_fieldname;
                        foreach ($ogReport->sec_module_columnslist[$modulename . $fieldname][$value] as $field => $fieldlabel) {
                            //if (isset($mod_strings[$fieldlabel]))
                            //    $fieldlabel = $mod_strings[$fieldlabel];
                            $fieldlabel = vtranslate($fieldlabel, $modulename);
                            // s$Options[$module_id][$optgroup][] = array("value" => $field, "text" => $fieldlabel);
                            $Options[$module_prefix][$optgroup][] = array("value" => $field, "text" => $fieldlabel);
                        }
                        if ($campaignstatus_listed !== true && isset($_REQUEST["primarymoduleid"]) && $_REQUEST["primarymoduleid"] == 26 && in_array($modulename, array("Leads", "Contacts", "Accounts"))) {
                            $campaignrelstatus_option = "vtiger_campaignrelstatus_{$field_id}:campaignrelstatus:" . $modulename . "_campaignrelstatus:Status:V:{$field_id}";
                            $campaignrelstatus_label = vtranslate("Campaign") . " " . vtranslate("Status");
                            $Options[$module_prefix][$optgroup][] = array("value" => $campaignrelstatus_option, "text" => $campaignrelstatus_label);
                            $campaignstatus_listed = true;
                        }
                    }
                }
                $access_count_listed = false;
                if ($_REQUEST["primarymoduleid"] != $_REQUEST["selectedmodule"] && $access_count_listed !== true && in_array($modulename, array("Calendar"))) {
                    $optgroup = $app_list_strings['moduleList'][$modulename] . " - " . vtranslate("Email Information", "ITS4YouReports");
                    $access_count_option = "access_count_{$field_id}:access_count:" . $modulename . "_access_count:Access Count:V:{$field_id}";
                    $access_count_label = vtranslate("Emails") . " " . vtranslate("Access Count");
                    $Options[$module_prefix][$optgroup][] = array("value" => $access_count_option, "text" => $access_count_label);
                    $access_count_listed = true;
                } elseif ($access_count_listed !== true && in_array($modulename, array("Calendar"))) {
                    $optgroup = $app_list_strings['moduleList'][$modulename] . " - " . vtranslate("Email Information", "ITS4YouReports");
                    $access_count_option = "access_count:access_count:" . $modulename . "_access_count:Access Count:V";
                    $access_count_label = vtranslate("Emails") . " " . vtranslate("Access Count");
                    $Options[$module_prefix][$optgroup][] = array("value" => $access_count_option, "text" => $access_count_label);
                    $access_count_listed = true;
                }
            }
        }
    }
    return $Options;
}