コード例 #1
0
ファイル: ITS4YouReports.php プロジェクト: cin-system/cinrepo
function getPrimaryColumns($Options, $module, $id_added = false, $ogReport = "")
{
    //    if ($ogReport == "") {
    if (ITS4YouReports::isStoredITS4YouReport() === true) {
        $ogReport = ITS4YouReports::getStoredITS4YouReport();
    } else {
        $ogReport = new ITS4YouReports();
    }
    //    }
    global $app_list_strings;
    global $app_strings;
    global $current_language;
    $mod_strings = return_module_language($current_language, $module);
    $block_listed = array();
    // ITS4YOU-CR SlOl 3. 3. 2014 10:43:03
    if (!isset($ogReport->pri_module_columnslist[$module]) || empty($ogReport->pri_module_columnslist[$module]) || $ogReport->pri_module_columnslist[$module] == "") {
        $ogReport->getPriModuleColumnsList($module);
    }
    if (!isset($ogReport->module_list[$module]) || empty($ogReport->module_list[$module])) {
        $ogReport->initListOfModules();
    }
    $lead_converted_added = false;
    // ITS4YOU-END 3. 3. 2014 10:43:06pri_module_columnslist[$module]
    if ($module == "Calendar") {
        $calendar_block = vtranslate($module, $module);
        $cal_options = $cal_options_f[$calendar_block] = array();
        $skip_fields = array("eventstatus", "status");
        $status_arr = array();
        foreach ($ogReport->pri_module_columnslist[$module] as $block_key => $field_array) {
            foreach ($field_array as $column_str => $column_label) {
                $column_arr = explode(":", $column_str);
                if (!in_array($column_arr[1], $skip_fields)) {
                    $cal_options[$block_key][$column_str] = $column_label;
                } elseif (empty($status_arr)) {
                    $status_arr = array("value" => $column_str, "text" => $column_label);
                }
            }
            $count_arri = 0;
            $due_date_populated = $duration_minutes_populated = $duration_hours_populated = false;
            foreach ($cal_options as $b => $inter) {
                $count_arri++;
                if ($block_key != "Custom Information") {
                    if (!empty($intersect)) {
                        $intersect = array_intersect_assoc($intersect, $cal_options[$block_key]);
                        $Dintersect1 = array_diff($cal_options[$block_key], $intersect);
                        $Dintersect2 = array_diff($cal_options[$prev_block_key], $intersect);
                        foreach ($intersect as $field => $fieldlabel) {
                            if (isset($mod_strings[$fieldlabel])) {
                                $fieldlabel = $mod_strings[$fieldlabel];
                            }
                            if (!$ogReport->in_multiarray($field, $cal_options_f[$calendar_block], "value")) {
                                $cal_options_f[$calendar_block][] = array("value" => $field, "text" => $fieldlabel);
                            }
                        }
                        foreach ($Dintersect1 as $field => $fieldlabel) {
                            // FIX FOR DUAL CALENDAR OPTIONS !!! S
                            if ($ogReport->in_multiarray($field, $cal_options_f[$calendar_block], "value") == true) {
                                continue;
                            }
                            if (strpos($field, "vtiger_activity:due_date:") !== false) {
                                $cal_options_f[$calendar_block][] = array("value" => $field, "text" => $fieldlabel);
                                continue;
                            }
                            if (strpos($field, "vtiger_activity:duration_minutes:Calendar_Duration_Minutes:duration_minutes:") !== false) {
                                $cal_options_f[$calendar_block][] = array("value" => $field, "text" => $fieldlabel);
                                continue;
                            }
                            if (strpos($field, "vtiger_activity:duration_hours:Calendar_Duration:duration_hours:") !== false) {
                                $cal_options_f[$calendar_block][] = array("value" => $field, "text" => $fieldlabel);
                                continue;
                            }
                            if (isset($mod_strings[$fieldlabel])) {
                                $fieldlabel = $mod_strings[$fieldlabel];
                            }
                            // FIX FOR DUAL CALENDAR OPTIONS !!! E
                            if (!$ogReport->in_multiarray($field, $cal_options_f[$block_key], "value")) {
                                $cal_options_f[$block_key][] = array("value" => $field, "text" => $fieldlabel);
                            }
                        }
                        foreach ($Dintersect2 as $field => $fieldlabel) {
                            // FIX FOR DUAL CALENDAR OPTIONS !!! S
                            if (strpos($field, "vtiger_activity:due_date:") !== false) {
                                continue;
                            }
                            if (strpos($field, "vtiger_activity:duration_minutes:Calendar_Duration_Minutes:duration_minutes:") !== false) {
                                continue;
                            }
                            if (strpos($field, "vtiger_activity:duration_hours:Calendar_Duration:duration_hours:") !== false) {
                                continue;
                            }
                            if (isset($mod_strings[$fieldlabel])) {
                                $fieldlabel = $mod_strings[$fieldlabel];
                            }
                            // FIX FOR DUAL CALENDAR OPTIONS !!! E
                            if (!$ogReport->in_multiarray($field, $cal_options_f[$prev_block_key], "value")) {
                                $cal_options_f[$prev_block_key][] = array("value" => $field, "text" => $fieldlabel);
                            }
                        }
                    } else {
                        $intersect = $cal_options[$block_key];
                    }
                    if ($block_key != $prev_block_key) {
                        $prev_block_key = $block_key;
                    }
                } else {
                    foreach ($field_array as $field => $fieldlabel) {
                        if (isset($mod_strings[$fieldlabel])) {
                            $fieldlabel = $mod_strings[$fieldlabel];
                        }
                        if (!$ogReport->in_multiarray($field, $cal_options_f[$block_key], "value")) {
                            $cal_options_f[$block_key][] = array("value" => $field, "text" => $fieldlabel);
                        }
                    }
                }
            }
        }
        $access_count_listed = false;
        if (in_array($module, array("Calendar")) && $access_count_listed !== true) {
            $optgroup = $app_list_strings['moduleList'][$module] . " - " . vtranslate("Email Information", "ITS4YouReports");
            $access_count_option = "access_count:access_count:" . $module . "_access_count:Access Count:V";
            $access_count_label = vtranslate("Emails") . " " . vtranslate("Access Count");
            $cal_options_f[$optgroup][] = array("value" => $access_count_option, "text" => $access_count_label);
            $access_count_listed = true;
        }
        if (!empty($status_arr)) {
            $cal_options_f[$calendar_block][] = $status_arr;
        }
        ksort($cal_options_f);
        $Options = array_merge($Options, $cal_options_f);
    } else {
        foreach ($ogReport->module_list[$module] as $key => $value) {
            if (isset($ogReport->pri_module_columnslist[$module][$value]) && !$block_listed[$value]) {
                $block_listed[$key] = true;
                $optgroup = $app_list_strings['moduleList'][$module] . " - " . vtranslate($value);
                if ($id_added == false) {
                    $Options[$optgroup]["vtiger_crmentity:crmid:" . $module . "_ID:crmid:I"] = vtranslate(vtranslate($module) . ' ID');
                    $id_added = true;
                }
                foreach ($ogReport->pri_module_columnslist[$module][$value] as $field => $fieldlabel) {
                    if (isset($mod_strings[$fieldlabel])) {
                        $fieldlabel = $mod_strings[$fieldlabel];
                    }
                    $Options[$optgroup][] = array("value" => $field, "text" => $fieldlabel);
                }
            }
        }
    }
    return $Options;
}