コード例 #1
0
ファイル: home.php プロジェクト: casati-dolibarr/corebos
 function getDisplayReportChart($reportId, $chartType)
 {
     require_once 'modules/Reports/CustomReportUtils.php';
     return CustomReportUtils::getReportChart($reportId, $chartType);
 }
コード例 #2
0
ファイル: SaveAndRun.php プロジェクト: mslokhat/corebos
 if ($showCharts == true) {
     $list_report_form->assign("SHOWCHARTS", $showCharts);
     require_once 'modules/Reports/CustomReportUtils.php';
     require_once 'include/ChartUtils.php';
     $groupBy = $oReportRun->getGroupingList($reportid);
     if (!empty($groupBy)) {
         foreach ($groupBy as $key => $value) {
             //$groupByConditon = explode(" ",$value);
             //$groupByNew = explode("'",$groupByConditon[0]);
             list($tablename, $colname, $module_field, $fieldname, $single) = explode(":", $key);
             list($module, $field) = explode("_", $module_field);
             $fieldDetails = $key;
             break;
         }
         //$groupByField = $oReportRun->GetFirstSortByField($reportid);
         $queryReports = CustomReportUtils::getCustomReportsQuery($Report_ID, $filtersql);
         $queryResult = $adb->pquery($queryReports, array());
         //ChartUtils::generateChartDataFromReports($queryResult, strtolower($groupByNew[1]));
         if ($adb->num_rows($queryResult)) {
             $pieChart = ChartUtils::getReportPieChart($queryResult, strtolower($module_field), $fieldDetails, $reportid);
             $barChart = ChartUtils::getReportBarChart($queryResult, strtolower($module_field), $fieldDetails, $reportid);
             $list_report_form->assign("PIECHART", $pieChart);
             $list_report_form->assign("BARCHART", $barChart);
         } else {
             $showCharts = false;
         }
     } else {
         $showCharts = false;
     }
     $list_report_form->assign("SHOWCHARTS", $showCharts);
 }
コード例 #3
0
 public static function generateChartDataFromReports($queryResult, $groupbyField, $fieldDetails = '', $reportid = '')
 {
     require_once 'modules/Reports/CustomReportUtils.php';
     require_once 'include/Webservices/Utils.php';
     require_once 'include/Webservices/Query.php';
     global $adb, $current_user, $theme, $default_charset;
     $inventorymodules = array('Quotes', 'SalesOrder', 'PurchaseOrder', 'Invoice', 'Products', 'PriceBooks', 'Vendors', 'Services');
     $rows = $adb->num_rows($queryResult);
     $condition = "is";
     $current_theme = $theme;
     $groupByFields = array();
     $yaxisArray = array();
     $ChartDataArray = array();
     $target_val = array();
     $report = new ReportRun($reportid);
     $restrictedModules = array();
     if ($report->secondarymodule != '') {
         $reportModules = explode(":", $report->secondarymodule);
     } else {
         $reportModules = array();
     }
     array_push($reportModules, $report->primarymodule);
     $restrictedModules = false;
     foreach ($reportModules as $mod) {
         if (isPermitted($mod, 'index') != "yes" || vtlib_isModuleActive($mod) == false) {
             if (!is_array($restrictedModules)) {
                 $restrictedModules = array();
             }
             $restrictedModules[] = $mod;
         }
     }
     if (is_array($restrictedModules) && count($restrictedModules) > 0) {
         $ChartDataArray['error'] = "<h4>" . getTranslatedString('LBL_NO_ACCESS', 'Reports') . ' - ' . implode(',', $restrictedModules) . "</h4>";
         return $ChartDataArray;
     }
     if ($fieldDetails != '') {
         list($tablename, $colname, $module_field, $fieldname, $single) = explode(":", $fieldDetails);
         list($module, $field) = split("_", $module_field);
         $dateField = false;
         if ($single == 'D') {
             $dateField = true;
             $query = "SELECT * FROM vtiger_reportgroupbycolumn WHERE reportid=? ORDER BY sortid";
             $result = $adb->pquery($query, array($reportid));
             $criteria = $adb->query_result($result, 0, 'dategroupbycriteria');
         }
     }
     preg_match('/&amp;/', $groupbyField, $matches);
     if (!empty($matches)) {
         $groupfield = str_replace('&amp;', '&', $groupbyField);
         $groupbyField = $report->replaceSpecialChar($groupfield);
     }
     $handler = vtws_getModuleHandlerFromName($module, $current_user);
     $meta = $handler->getMeta();
     $meta->retrieveMeta();
     $referenceFields = $meta->getReferenceFieldDetails();
     if ($rows > 0) {
         $resultRow = $adb->query_result_rowdata($queryResult, 0);
         if (!array_key_exists($groupbyField, $resultRow)) {
             $ChartDataArray['error'] = "<h4>" . getTranslatedString('LBL_NO_PERMISSION_FIELD', 'Dashboard') . "</h4>";
             return $ChartDataArray;
         }
     }
     for ($i = 0; $i < $rows; $i++) {
         $groupFieldValue = $adb->query_result($queryResult, $i, strtolower($groupbyField));
         $decodedGroupFieldValue = html_entity_decode($groupFieldValue, ENT_QUOTES, $default_charset);
         if (!empty($groupFieldValue)) {
             if (in_array($module_field, $report->append_currency_symbol_to_value)) {
                 $valueComp = explode('::', $groupFieldValue);
                 $groupFieldValue = $valueComp[1];
             }
             if ($dateField) {
                 if (!empty($groupFieldValue)) {
                     $groupByFields[] = CustomReportUtils::getXAxisDateFieldValue($groupFieldValue, $criteria);
                 } else {
                     $groupByFields[] = "Null";
                 }
             } else {
                 if (in_array($fieldname, array_keys($referenceFields))) {
                     if (count($referenceFields[$fieldname]) > 1) {
                         $refenceModule = CustomReportUtils::getEntityTypeFromName($decodedGroupFieldValue, $referenceFields[$fieldname]);
                     } else {
                         $refenceModule = $referenceFields[$fieldname][0];
                     }
                     $groupByFields[] = $groupFieldValue;
                     if ($fieldname == 'currency_id' && in_array($module, $inventorymodules)) {
                         $tablename = 'vtiger_currency_info';
                     } elseif ($refenceModule == 'DocumentFolders' && $fieldname == 'folderid') {
                         $tablename = 'vtiger_attachmentsfolder';
                         $colname = 'foldername';
                     } else {
                         require_once "modules/{$refenceModule}/{$refenceModule}.php";
                         $focus = new $refenceModule();
                         $tablename = $focus->table_name;
                         $colname = $focus->list_link_field;
                         $condition = "c";
                     }
                 } else {
                     $groupByFields[] = $groupFieldValue;
                 }
             }
             $yaxisArray[] = $adb->query_result($queryResult, $i, 'groupby_count');
             if ($fieldDetails != '') {
                 if ($dateField) {
                     $advanceSearchCondition = CustomReportUtils::getAdvanceSearchCondition($fieldDetails, $criteria, $groupFieldValue);
                     if ($module == 'Calendar') {
                         $link_val = "index.php?module=" . $module . "&query=true&action=ListView&" . $advanceSearchCondition;
                     } else {
                         $link_val = "index.php?module=" . $module . "&query=true&action=index&" . $advanceSearchCondition;
                     }
                 } else {
                     $cvid = getCvIdOfAll($module);
                     $esc_search_str = urlencode($decodedGroupFieldValue);
                     if ($single == 'DT') {
                         $esc_search_str = urlencode($groupFieldValue);
                         if (strtolower($fieldname) == 'modifiedtime' || strtolower($fieldname) == 'createdtime') {
                             $tablename = 'vtiger_crmentity';
                             $colname = $fieldname;
                         }
                     }
                     if ($fieldname == 'assigned_user_id') {
                         $tablename = 'vtiger_crmentity';
                         $colname = 'smownerid';
                     }
                     if ($fieldname == 'serviceid' && in_array($module, getInventoryModules())) {
                         $fieldname = 'productid';
                     }
                     if ($module == 'Calendar') {
                         $link_val = "index.php?module=" . $module . "&action=ListView&search_text=" . $esc_search_str . "&search_field=" . $fieldname . "&searchtype=BasicSearch&query=true&operator=e&viewname=" . $cvid;
                     } else {
                         $link_val = "index.php?module=" . $module . "&action=index&search_text=" . $esc_search_str . "&search_field=" . $fieldname . "&searchtype=BasicSearch&query=true&operator=e&viewname=" . $cvid;
                     }
                 }
                 $target_val[] = $link_val;
             }
         }
     }
     if (count($groupByFields) == 0) {
         $ChartDataArray['error'] = "<div class='componentName'>" . getTranslatedString('LBL_NO_DATA', 'Reports') . "</div";
     }
     $ChartDataArray['xaxisData'] = $groupByFields;
     $ChartDataArray['yaxisData'] = $yaxisArray;
     $ChartDataArray['targetLink'] = $target_val;
     $theme = $current_theme;
     return $ChartDataArray;
 }
コード例 #4
0
ファイル: Record.php プロジェクト: cin-system/cinrepo
 /**
  * Function saves Reports Sorting Fields
  */
 function saveSortFields()
 {
     $db = PearDatabase::getInstance();
     $sortFields = $this->get('sortFields');
     $i = 0;
     foreach ($sortFields as $fieldInfo) {
         $db->pquery('INSERT INTO its4you_reports4you_sortcol(sortcolid, reportid, columnname, sortorder) VALUES (?,?,?,?)', array($i, $this->getId(), $fieldInfo[0], $fieldInfo[1]));
         if (CustomReportUtils::IsDateField($fieldInfo[0])) {
             if (empty($fieldInfo[2])) {
                 $fieldInfo[2] = 'None';
             }
             $db->pquery("INSERT INTO vtiger_reportgroupbycolumn(reportid, sortid, sortcolname, dategroupbycriteria)\n                                    VALUES(?,?,?,?)", array($this->getId(), $i, $fieldInfo[0], $fieldInfo[2]));
         }
         $i++;
     }
 }
コード例 #5
0
ファイル: Save.php プロジェクト: kduqi/corebos
         $groupByTime1Sql = 'INSERT INTO vtiger_reportgroupbycolumn(REPORTID,SORTID,SORTCOLNAME,DATEGROUPBYCRITERIA) values(?,?,?,?)';
         $groupByTime1Res = $adb->pquery($groupByTime1Sql, array($reportid, 1, $sort_by1, $groupTime1));
     }
 }
 if ($sort_by2 != "") {
     $sort_by2sql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (?,?,?,?)";
     $sort_by2result = $adb->pquery($sort_by2sql, array(2, $reportid, $sort_by2, $sort_order2));
     if (CustomReportUtils::IsDateField($sort_by2)) {
         $groupByTime2Sql = 'INSERT INTO vtiger_reportgroupbycolumn(REPORTID,SORTID,SORTCOLNAME,DATEGROUPBYCRITERIA) values(?,?,?,?)';
         $groupByTime2Res = $adb->pquery($groupByTime2Sql, array($reportid, 2, $sort_by2, $groupTime2));
     }
 }
 if ($sort_by3 != "") {
     $sort_by3sql = "insert into vtiger_reportsortcol (SORTCOLID,REPORTID,COLUMNNAME,SORTORDER) values (?,?,?,?)";
     $sort_by3result = $adb->pquery($sort_by3sql, array(3, $reportid, $sort_by3, $sort_order3));
     if (CustomReportUtils::IsDateField($sort_by3)) {
         $groupByTime3Sql = 'INSERT INTO vtiger_reportgroupbycolumn(REPORTID,SORTID,SORTCOLNAME,DATEGROUPBYCRITERIA) values(?,?,?,?)';
         $groupByTime3Res = $adb->pquery($groupByTime3Sql, array($reportid, 3, $sort_by3, $groupTime3));
     }
 }
 $log->info("Reports :: Save->Successfully saved vtiger_reportsortcol");
 //<<<<step3 vtiger_reportsortcol>>>>>>>
 $idelreportdatefiltersql = "delete from vtiger_reportdatefilter where datefilterid=?";
 $idelreportdatefiltersqlresult = $adb->pquery($idelreportdatefiltersql, array($reportid));
 //<<<<step5 standarfilder>>>>>>>
 $ireportmodulesql = "insert into vtiger_reportdatefilter (DATEFILTERID,DATECOLUMNNAME,DATEFILTER,STARTDATE,ENDDATE) values (?,?,?,?,?)";
 $ireportmoduleresult = $adb->pquery($ireportmodulesql, array($reportid, $stdDateFilterField, $stdDateFilter, $startdate, $enddate));
 $log->info("Reports :: Save->Successfully saved vtiger_reportdatefilter");
 //<<<<step5 standarfilder>>>>>>>
 //<<<<step4 columnstototal>>>>>>>
 $idelreportsummarysql = "delete from vtiger_reportsummary where reportsummaryid=?";