Exemple #1
0
 public static function ReportFilters(Vtiger_Request $request, $viewer)
 {
     require_once 'modules/ITS4YouReports/FilterUtils.php';
     $adb = PearDatabase::getInstance();
     $moduleName = $request->getModule();
     $R_Data = $request->getAll();
     $record = $request->get('record');
     $viewer->assign("MODULE", $moduleName);
     $reportModel = ITS4YouReports_Record_Model::getCleanInstance($record);
     $Report_Informations = $reportModel->getReportInformations();
     $primary_module = $reportModel->getPrimaryModule();
     $primary_moduleid = $reportModel->getPrimaryModuleId();
     $current_user = Users_Record_Model::getCurrentUserModel();
     $viewer->assign("DATEFORMAT", $current_user->date_format);
     $viewer->assign("JS_DATEFORMAT", parse_calendardate(vtranslate('NTC_DATE_FORMAT')));
     // ITS4YOU-CR SlOl 10. 9. 2013 16:13:47
     $LBL_INFORMATIONS_4YOU = vtranslate("LBL_STEP7_INFO", $moduleName);
     $viewer->assign("LBL_INFORMATIONS_4YOU", $LBL_INFORMATIONS_4YOU);
     // ITS4YOU-END 10. 9. 2013 16:13:50
     $BLOCK1 = "<option selected value='Not Accessible'>" . vtranslate('LBL_NOT_ACCESSIBLE') . "</option>";
     $user_privileges_path = 'user_privileges/user_privileges_' . $current_user->id . '.php';
     if (file_exists($user_privileges_path)) {
         require $user_privileges_path;
     }
     $related_modules = $reportModel->getReportRelatedModulesList();
     $advft_criteria = array();
     if ($record != "") {
         $reportModel->getSelectedStandardCriteria($reportid);
         $stdselectedcolumn = $reportModel->getSTDSelectedColumn();
         $relatedmodulesstring = $reportModel->getRelatedModulesString();
         $BLOCK1 .= getITSPrimaryStdFilterHTML($primary_module, $stdselectedcolumn);
         $BLOCK1 .= getITSSecondaryStdFilterHTML($relatedmodulesstring, $stdselectedcolumn);
         //added to fix the ticket #5117
         $selectedcolumnvalue = '"' . $stdselectedcolumn . '"';
         if (!$is_admin && isset($stdselectedcolumn) && strpos($BLOCK1, $selectedcolumnvalue) === false) {
             $viewer->assign("BLOCK1_STD", $BLOCK1);
         }
         $stdselectedfilter = $reportModel->getSTDSelectedFilter();
         $startdate = $reportModel->getStartDate();
         $enddate = $reportModel->getEndDate();
         if ($startdate != "") {
             $viewer->assign("STARTDATE_STD", getValidDisplayDate($startdate));
         }
         if ($enddate != "") {
             $viewer->assign("ENDDATE_STD", getValidDisplayDate($enddate));
         }
         $reportModel->getGroupFilterList($reportid);
         $reportModel->getAdvancedFilterList($reportid);
         $advft_criteria = $reportModel->getSelectedAdvancedFilter($reportid);
     } else {
         $primary_module = $R_Data["reportmodule"];
         $BLOCK1 .= getITSPrimaryStdFilterHTML($primary_module);
         if (!empty($related_modules[$primary_module])) {
             foreach ($related_modules[$primary_module] as $key => $value) {
                 $BLOCK1 .= getITSSecondaryStdFilterHTML($R_Data["secondarymodule_" . $value]);
             }
         }
         $viewer->assign("BLOCK1_STD", $BLOCK1);
         $stdselectedfilter = "";
     }
     $BLOCKCRITERIA = $reportModel->getSelectedStdFilterCriteria($stdselectedfilter);
     $viewer->assign("BLOCKCRITERIA_STD", $BLOCKCRITERIA);
     $BLOCKJS = $reportModel->getCriteriaJS();
     $viewer->assign("BLOCKJS_STD", $BLOCKJS);
     ///AdvancedFilter.php
     $summaries_criteria = $reportModel->getSummariesCriteria();
     $viewer->assign("CRITERIA_GROUPS", $advft_criteria);
     $viewer->assign("EMPTY_CRITERIA_GROUPS", empty($advft_criteria));
     $viewer->assign("SUMMARIES_CRITERIA", $summaries_criteria);
     /*
     if(isset($R_Data["mode"]) && $R_Data["mode"]!=""){
         $mode = vtlib_purify($R_Data["mode"]);
     }else{
         $mode = "generate";
     }
     */
     if ($record != "") {
         $viewer->assign('MODE', 'edit');
     } else {
         $viewer->assign('MODE', 'create');
     }
     $FILTER_OPTION = getAdvCriteriaHTML();
     $viewer->assign("FOPTION", $FILTER_OPTION);
     $secondarymodule = '';
     $secondarymodules = array();
     if (!empty($related_modules[$primary_module])) {
         foreach ($related_modules[$primary_module] as $key => $value) {
             if (isset($R_Data["secondarymodule_" . $value])) {
                 $secondarymodules[] = $R_Data["secondarymodule_" . $value];
             }
         }
     }
     $reportModel->getPriModuleColumnsList($primary_module);
     if (!empty($related_modules[$primary_module])) {
         foreach ($related_modules[$primary_module] as $key => $value) {
             $secondarymodules[] = $value["id"];
         }
         $secondary_modules_str = implode(":", $secondarymodules);
     }
     $reportModel->getSecModuleColumnsList($secondary_modules_str);
     if ($mode != "ChangeSteps") {
         $Options = getPrimaryColumns($Options, $reportModel->report->primarymodule, true, $reportModel->report);
         $secondarymodules = array();
         if (!empty($reportModel->report->related_modules[$reportModel->report->primarymodule])) {
             foreach ($reportModel->report->related_modules[$reportModel->report->primarymodule] as $key => $value) {
                 $exploded_mid = explode("x", $value["id"]);
                 if (strtolower($exploded_mid[1]) != "mif") {
                     $secondarymodules[] = $value["id"];
                 }
             }
         }
         $secondarymodules_str = implode(":", $secondarymodules);
         $Options_sec = getSecondaryColumns(array(), $secondarymodules_str, $reportModel->report);
         foreach ($Options_sec as $moduleid => $sec_options) {
             $Options = array_merge($Options, $sec_options);
         }
         // ITS4YOU-CR SlOl 16. 9. 2015 10:49:04 OTHER COLUMNS
         if (isset($R_Data["selectedColumnsStr"]) && $R_Data["selectedColumnsStr"] != "") {
             $selectedColumnsStr = $R_Data["selectedColumnsStr"];
             $selectedColumnsStringDecoded = html_entity_decode($selectedColumnsStr, ENT_QUOTES, $default_charset);
             $selectedColumns_arr = explode("<_@!@_>", $selectedColumnsStringDecoded);
         } else {
             $selectedColumnsStr = $reportModel->report->reportinformations["selectedColumnsString"];
             $selectedColumnsStringDecoded = html_entity_decode($selectedColumnsStr, ENT_QUOTES, $default_charset);
             $selectedColumns_arr = explode(";", $selectedColumnsStringDecoded);
         }
         if (!empty($selectedColumns_arr)) {
             $opt_label = vtranslate("LBL_Filter_SelectedColumnsGroup", "ITS4YouReports");
             foreach ($selectedColumns_arr as $sc_key => $sc_col_str) {
                 if ($sc_col_str != "") {
                     $in_options = false;
                     foreach ($Options as $opt_group => $opt_array) {
                         if ($reportModel->report->in_multiarray($sc_col_str, $opt_array, "value") === true) {
                             $in_options = true;
                             continue;
                         }
                     }
                     if ($in_options) {
                         continue;
                     } else {
                         $Options[$opt_label][] = array("value" => $sc_col_str, "text" => $reportModel->report->getColumnStr_Label($sc_col_str));
                     }
                 }
             }
         }
         // ITS4YOU-END
         foreach ($Options as $optgroup => $optionsdata) {
             if ($COLUMNS_BLOCK_JSON != "") {
                 $COLUMNS_BLOCK_JSON .= "(|@!@|)";
             }
             $COLUMNS_BLOCK_JSON .= $optgroup;
             $COLUMNS_BLOCK_JSON .= "(|@|)";
             $COLUMNS_BLOCK_JSON .= Zend_JSON::encode($optionsdata);
         }
         $viewer->assign("COLUMNS_BLOCK_JSON", $COLUMNS_BLOCK_JSON);
         $adv_sel_fields = $reportModel->getAdvSelFields();
         $sel_fields = Zend_Json::encode($adv_sel_fields);
         $viewer->assign("SEL_FIELDS", $sel_fields);
         $default_charset = vglobal("default_charset");
         $std_filter_columns = $reportModel->getStdFilterColumns();
         $std_filter_columns_js = implode("<%jsstdjs%>", $std_filter_columns);
         $std_filter_columns_js = html_entity_decode($std_filter_columns_js, ENT_QUOTES, $default_charset);
         $viewer->assign("std_filter_columns", $std_filter_columns_js);
         $Date_Filter_Values = $reportModel->getDateFilterValues();
         $std_filter_criteria = Zend_Json::encode($Date_Filter_Values);
         $viewer->assign("std_filter_criteria", $std_filter_criteria);
     }
     $rel_fields = $reportModel->getAdvRelFields();
     $viewer->assign("REL_FIELDS", Zend_Json::encode($rel_fields));
     /*NEWS*/
     //error_reporting(63);ini_set("display_errors",1);
     $primary_module = $reportModel->report->primarymodule;
     $primary_moduleid = $reportModel->report->primarymoduleid;
     // NEW ADVANCE FILTERS START
     $reportModel->report->getGroupFilterList($reportModel->report->record);
     $reportModel->report->getAdvancedFilterList($reportModel->report->record);
     $reportModel->report->getSummariesFilterList($reportModel->report->record);
     $sel_fields = Zend_Json::encode($reportModel->report->adv_sel_fields);
     $viewer->assign("SEL_FIELDS", $sel_fields);
     if (isset($_REQUEST["reload"])) {
         $criteria_groups = $reportModel->report->getRequestCriteria($sel_fields);
     } else {
         $criteria_groups = $reportModel->report->advft_criteria;
     }
     $viewer->assign("CRITERIA_GROUPS", $criteria_groups);
     $viewer->assign("EMPTY_CRITERIA_GROUPS", empty($criteria_groups));
     $viewer->assign("SUMMARIES_CRITERIA", $reportModel->report->summaries_criteria);
     $FILTER_OPTION = getAdvCriteriaHTML();
     $viewer->assign("FOPTION", $FILTER_OPTION);
     $COLUMNS_BLOCK_JSON = $reportModel->report->getAdvanceFilterOptionsJSON($primary_module);
     $viewer->assign("COLUMNS_BLOCK", $COLUMNS_BLOCK);
     if ($mode != "ajax") {
         //echo "<div class='none' style='display:none;' id='filter_columns'>" . $COLUMNS_BLOCK_JSON . "</div>";
         //echo "<input type='hidden' name='filter_columns' id='filter_columns' value='".$COLUMNS_BLOCK_JSON."' />";
         $viewer->assign("filter_columns", $COLUMNS_BLOCK_JSON);
         $sel_fields = Zend_Json::encode($reportModel->report->adv_sel_fields);
         $viewer->assign("SEL_FIELDS", $sel_fields);
         global $default_charset;
         $std_filter_columns = $reportModel->report->getStdFilterColumns();
         $std_filter_columns_js = implode("<%jsstdjs%>", $std_filter_columns);
         $std_filter_columns_js = html_entity_decode($std_filter_columns_js, ENT_QUOTES, $default_charset);
         $viewer->assign("std_filter_columns", $std_filter_columns_js);
         $std_filter_criteria = Zend_Json::encode($reportModel->report->Date_Filter_Values);
         $viewer->assign("std_filter_criteria", $std_filter_criteria);
     }
     $rel_fields = $reportModel->report->adv_rel_fields;
     $rel_fields = Zend_Json::encode($rel_fields);
     $rel_fields = str_replace("'", "\\'", $rel_fields);
     $viewer->assign("REL_FIELDS", $rel_fields);
     // NEW ADVANCE FILTERS END
     $BLOCKJS = $reportModel->getCriteriaJS();
     $viewer->assign("BLOCKJS_STD", $BLOCKJS);
     /*NEWE*/
     return $viewer->view('ReportFilters.tpl', $moduleName, true);
 }
    $ITS4YouReports->getSelectedStandardCriteria($reportid);
    $BLOCK1 .= getITSPrimaryStdFilterHTML($ITS4YouReports, $ITS4YouReports->primarymodule, $ITS4YouReports->stdselectedcolumn);
    $BLOCK1 .= getITSSecondaryStdFilterHTML($ITS4YouReports, $ITS4YouReports->relatedmodulesstring, $ITS4YouReports->stdselectedcolumn);
    //added to fix the ticket #5117
    $selectedcolumnvalue = '"' . $ITS4YouReports->stdselectedcolumn . '"';
    if (!$is_admin && isset($ITS4YouReports->stdselectedcolumn) && strpos($BLOCK1, $selectedcolumnvalue) === false) {
        $smarty_obj->assign("BLOCK1_STD", $BLOCK1);
    }
    $BLOCKCRITERIA = $ITS4YouReports->getSelectedStdFilterCriteria($ITS4YouReports->stdselectedfilter);
    $smarty_obj->assign("BLOCKCRITERIA_STD", $BLOCKCRITERIA);
    if (isset($ITS4YouReports->startdate) && isset($ITS4YouReports->enddate)) {
        $smarty_obj->assign("STARTDATE_STD", getValidDisplayDate($ITS4YouReports->startdate));
        $smarty_obj->assign("ENDDATE_STD", getValidDisplayDate($ITS4YouReports->enddate));
    } else {
        $smarty_obj->assign("STARTDATE_STD", $ITS4YouReports->startdate);
        $smarty_obj->assign("ENDDATE_STD", $ITS4YouReports->enddate);
    }
} else {
    $primarymodule = vtlib_purify($_REQUEST["reportmodule"]);
    $BLOCK1 .= getITSPrimaryStdFilterHTML($ITS4YouReports, $primarymodule);
    if (!empty($ITS4YouReports->related_modules[$primarymodule])) {
        foreach ($ITS4YouReports->related_modules[$primarymodule] as $key => $value) {
            $BLOCK1 .= getITSSecondaryStdFilterHTML($ITS4YouReports, $_REQUEST["secondarymodule_" . $value]);
        }
    }
    $smarty_obj->assign("BLOCK1_STD", $BLOCK1);
    $BLOCKCRITERIA = $ITS4YouReports->getSelectedStdFilterCriteria();
    $smarty_obj->assign("BLOCKCRITERIA_STD", $BLOCKCRITERIA);
}
$BLOCKJS = $ITS4YouReports->getCriteriaJS();
$smarty_obj->assign("BLOCKJS_STD", $BLOCKJS);