Example #1
0
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     $separator = $this->_getCsvSeparator();
     $trendType = $aInput['input']['flash']['type'] = isset($aInput['input']['flash']['type']) ? $aInput['input']['flash']['type'] : "trend";
     $aOffsetData = $aOutput['total'];
     foreach ($aOutput['total'] as $i => $aTmp) {
         $compareFlag = $i != 0 ? 1 : 0;
         foreach ($aTmp as $metric => $v) {
             if ($compareFlag) {
                 if (empty($v)) {
                     $offerPercent = 0;
                 } else {
                     $offerPercent = $aOutput['total'][0][0][$metric] ? ($aOutput['total'][0][0][$metric] - $v) * 100 / $v : 0;
                 }
                 $aOffsetData[$i][$metric] = $offerPercent;
             }
         }
     }
     $sHTML = "";
     //		\YcheukfReport\Lib\ALYS\ALYSFunction::debug($aOutput,'a', 'aOutputaOutput');
     switch (strtolower($trendType)) {
         default:
         case "trend":
         case "multdate":
             $index = 0;
             foreach ($aOutput['total'][0] as $metric => $vvv) {
                 foreach ($vvv as $metric2 => $vvv2) {
                     if ($metric != $metric2) {
                         continue;
                     }
                     $sHTML .= "\r\n";
                     $keyLabel = \YcheukfReport\Lib\ALYS\ALYSLang::_($metric2);
                     $keyLabelTip = \YcheukfReport\Lib\ALYS\ALYSLang::_($metric2 . '-tip');
                     $sHTML .= '"' . $keyLabel . '"' . $separator;
                     $offerPercentHTML = "";
                     if ($ii != 0) {
                         if ($aOffsetData[$ii][$metric] == 0) {
                             $offerPercentCls = "zero";
                         } else {
                             $offerPercentCls = $aOffsetData[$ii][$metric] > 0 ? "plus2" : 'negative';
                         }
                         $offerPercentLabel = abs(round($aOffsetData[$ii][$metric], 2)) . "%";
                         $offsetPercentHTML = '(' . $offerPercentLabel . ')';
                         $sHTML .= '"' . $vvv2 . '' . $offsetPercentHTML . '"' . $separator;
                     } else {
                         $sHTML .= '"' . $oDict->ALYSmetricFormat($metric2, $vvv2) . '"' . $separator;
                     }
                 }
                 $index++;
             }
             break;
     }
     $sHTML .= "\r\n";
     //		var_export($sHTML);
     $aOutput['total.output'] = $sHTML;
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
Example #2
0
 public function getConf($type)
 {
     $aConf = array();
     if (!count($this->aInput['input'][$type]['table'])) {
         throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_INPUT_TABLE_EMPTY');
     }
     $aInput = $this->aInput['input'][$type];
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     //查找的order limit设置
     $aDataConf = array();
     if (!empty($aInput['dataConf']['orderBy'])) {
         $aDataConf['orderby'] = $aInput['dataConf']['orderBy'];
     }
     if (!empty($aInput['dataConf']['length'])) {
         $aDataConf['limit'] = 1;
         $aDataConf['start'] = empty($aInput['dataConf']['start']) ? 0 : (int) $aInput['dataConf']['start'];
         $aDataConf['length'] = (int) $aInput['dataConf']['length'];
     }
     if (is_array($aInput['tables'])) {
         foreach ($aInput['tables'] as $table => $aTable) {
             $aConftion = $this->getCondition($type, $table);
             $aConftionAry = $this->getCondition($type, $table, 'array');
             //$aConftion=array_merge(array($sDate),$aConftion);
             //echo $table;
             //print_r($aConftion);
             $aConf[$table] = array('noRecord' => 0, 'limit' => 0, 'dimen_array' => $this->getDimenFieldArray($type, $table), 'metric_array' => $this->getMetricFieldArray($type, $table), 'field_array' => $this->getField($type, $table, 'array'), 'groupby' => $aTable['dimen']['key'], 'table' => $oDict->ALYStableDefine($table), 'condition' => $aConftion, 'condition_array' => $aConftionAry);
             $aConf[$table] = array_merge($aConf[$table], $aDataConf);
         }
     }
     //print_r($aConf);
     return $aConf;
 }
Example #3
0
 public function getConf($type)
 {
     $aConf = array();
     if (!count($this->aInput['input'][$type]['table'])) {
         throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_INPUT_TABLE_EMPTY');
     }
     $aInput = $this->aInput['input'][$type];
     $sGroupBy = empty($aInput['groupBy']) ? '' : $aInput['groupBy'];
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     foreach ($aInput['tables'] as $table => $aTable) {
         $aConftion = $this->getCondition($type, $table);
         $aConftionAry = $this->getCondition($type, $table, 'array');
         $aConf[$table] = array('noRecord' => 0, 'limit' => 0, 'dimen_array' => $this->getDimenFieldArray($type, $table), 'metric_array' => $this->getMetricFieldArray($type, $table), 'field_array' => $this->getField($type, $table, 'array'), 'table' => $oDict->ALYStableDefine($table), 'condition' => $aConftion, 'condition_array' => $aConftionAry);
         //if($sGroupBy)$aConf[$table]['groupby']=$sGroupBy;
     }
     //print_r($aConf);
     return $aConf;
 }
Example #4
0
 /**
  * 格式小数位数等
  */
 public function _formatMetric($type)
 {
     $aMainTable = $this->aInput['input'][$type]['mainTable'];
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     $this->aInput['internal'][$type]['datas'] = $aOrgData = $this->aOutput[$type];
     if (isset($this->aInput['input']['flash']['type']) && $this->aInput['input']['flash']['type'] == 'geography' and $type == 'flash') {
         if (count($aOrgData)) {
             foreach ($aOrgData as $date_i => $aData) {
                 if (count($aData) < 1) {
                     continue;
                 }
                 foreach ($aData as $field => $data) {
                     if (count($data) < 1) {
                         continue;
                     }
                     foreach ($data as $k => $v) {
                         $this->aOutput[$type][$date_i][$field][$k] = $oDict->ALYSmetricFormat($field, $v, $data);
                     }
                 }
             }
         }
     } else {
         if (count($aOrgData)) {
             foreach ($aOrgData as $date_i => $aData) {
                 if (count($aData) < 1) {
                     continue;
                 }
                 foreach ($aData as $date => $data) {
                     if (count($aMainTable['showField']) < 1) {
                         continue;
                     }
                     foreach ($aMainTable['showField'] as $metric) {
                         $this->aOutput[$type][$date_i][$date][$metric] = $oDict->ALYSmetricFormat($metric, $data[$metric], $data);
                     }
                 }
             }
         }
     }
     \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput);
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
 }
Example #5
0
 private function _getInSQL($array, $aDimenKey2Field)
 {
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     $sql_conf = array();
     if (is_array($array)) {
         foreach ($array as $k => $v) {
             $quotes = $oDict->ALYSgetDimenTypeOf($k);
             $in_str = implode($quotes . ',' . $quotes, $v);
             $in_str = "(" . $quotes . $in_str . $quotes . ")";
             $sql_conf[] = array('key' => $aDimenKey2Field[$k], 'op' => 'IN', 'value' => $in_str);
         }
     }
     return $sql_conf;
 }
Example #6
0
 /**
  * ׼���������
  */
 public function initInput($type)
 {
     $this->_chkInputParam($type);
     if (\YcheukfReport\Lib\ALYS\Report\Advance::isAdvanced($type)) {
         $this->initInputAdvance($type);
         //			return;
     }
     $aTmpTables = array();
     $aTables = $this->aInput['input'][$type]['table'];
     $aMainTable['showField'] = array();
     $aMainTable['field3'] = array();
     $aMainTable['table2Field'] = array();
     //ֻ���date,day
     //echo "$type=";echo "aTables=";print_r($aTables);
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     foreach ($aTables as $table => $aTable) {
         if (!isset($aMainTable['table'])) {
             $aMainTable['table'] = $table;
         }
         $aDimenField = array();
         if (!empty($aTable['dimen']) && is_array($aTable['dimen'])) {
             foreach ($aTable['dimen'] as $dimen) {
                 $key = $dimen['key'];
                 if (isset($aTmpTables[$table]['dimen']['key']) && in_array($key, $aTmpTables[$table]['dimen']['key'])) {
                     continue;
                 }
                 //dimenȥ��
                 if ($dimen['group']) {
                     $interval = $dimen['selected'];
                     $sField = $oDict->ALYSdimen2Field($key, $interval, $type, $table);
                     $aTmpTables[$table]['dimen']['key'][] = $key;
                     $aTmpTables[$table]['dimen']['dimenkey2selected'][$key] = $interval;
                     $aTmpTables[$table]['dimen']['dimenkey2field'][$key] = $sField;
                     $aTmpTables[$table]['dimen']['field'][] = $sField . " as " . $key;
                     $aDimenField['key'][] = $sField;
                     if (empty($aMainTable['table2Field'][$table])) {
                         $aMainTable['table2Field'][$table] = \YcheukfReport\Lib\ALYS\Report::getDateFeildByTable($type, $table);
                     }
                     if ($type != 'flash') {
                         //Ϊflashʱ����ҪshowField
                         if (!in_array($key, $aMainTable['showField'])) {
                             $aMainTable['showField'][] = $key;
                             //��ʾ���ֶ� ά��
                             $aMainTable['field2Table'][$key] = $table;
                         }
                     }
                 } else {
                     $interval = $dimen['selected'];
                     $sField = $oDict->ALYSdimen2Field($key, $interval, $type, $table);
                     $aTmpTables[$table]['dimen']['field'][] = $sField . " as " . $key;
                 }
                 foreach ($this->aInput['filters'] as $aFilter) {
                     if (in_array($aFilter['key'], $dimen['options'])) {
                         $aTmpTables[$table]['filter'][] = $aFilter;
                     }
                 }
             }
         }
         //var_export($aTmpTables);
         $tmpAry = array();
         if (is_array($aDimenField['key'])) {
             foreach ($aDimenField['key'] as $field) {
                 $tmpAry[] = "CAST(IF(" . $field . "<=>null, 0, " . $field . ") AS CHAR)";
             }
             $aTmpTables[$table]['dimen']['concatKey'] = "CONCAT_WS('" . $this->splitChar . "', " . implode(',', $tmpAry) . ") as concatKey";
         }
         $aTmpTables[$table]['metric'] = array();
         if (!empty($aTable['metric']) && is_array($aTable['metric'])) {
             foreach ($aTable['metric'] as $metric) {
                 if ($metric['show']) {
                     //if($aMainTable['table']==$table)
                     if (!in_array($metric['key'], $aMainTable['showField'])) {
                         $aMainTable['showField'][] = $metric['key'];
                         //��ʾ���ֶ� ָ��
                     }
                     if (3 == $metric['type'][0]) {
                         //ȥ��
                         if (!in_array($metric['key'], $aMainTable['showField'])) {
                             $aMainTable['showField'][] = $metric['key'];
                             //��ʾ���ֶ� ָ��
                         }
                     } else {
                         if (!in_array($metric['key'], $aMainTable['showField'])) {
                             $aMainTable['showField'][] = $metric['key'];
                         }
                     }
                     //		var_export($aMainTable['showField']);
                     switch ($metric['type'][0]) {
                         case 1:
                         case 2:
                             //if(!in_array($metric['key'],$aTmpTables[$table]['metric'])){
                             $aTmpTables[$table]['metric'][] = $metric['key'];
                             //}
                             $aMainTable['field2Table'][$metric['key']] = $table;
                             break;
                         case 3:
                             if (!in_array($metric['key'], $aMainTable['field3'])) {
                                 $aMainTable['field3'][] = $metric['key'];
                                 //��ʾ���ֶ� ָ��
                             }
                             if ($table == $aMainTable['table']) {
                                 //�������
                                 $key = $metric['type'][1][0];
                                 if (!in_array($key, $aTmpTables[$table]['metric'])) {
                                     $aTmpTables[$table]['metric'][] = $key;
                                 }
                                 $aMainTable['field2Table'][$key] = $table;
                             } else {
                                 //�ӱ����
                                 $key = $metric['type'][1][0];
                                 if (!in_array($key, $aTmpTables[$table]['metric'])) {
                                     $aTmpTables[$table]['metric'][] = $key;
                                 }
                                 $aMainTable['field2Table'][$key] = $table;
                             }
                             break;
                     }
                 }
             }
         }
     }
     $this->aInput['input'][$type]['groupby'] = $this->getFlashGroupBy();
     $this->aInput['input'][$type]['mainTable'] = $aMainTable;
     $this->aInput['input'][$type]['tables'] = $aTmpTables;
     \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput);
 }
Example #7
0
 function _getId2Label($sDimen, $aData)
 {
     $aLabel[$sDimen] = array();
     if (!empty($sDimen)) {
         if (is_array($aData)) {
             foreach ($aData as $key => $value) {
                 $aIDs[$sDimen][] = $key;
             }
             $oId2Label = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Id2label');
             $aLabel = $oId2Label->ALYSchgId2Label(array($sDimen), $aIDs);
         }
     }
     return $aLabel[$sDimen];
 }
Example #8
0
 /**
  * 横向柱状图
  * #edit by Paul 2012.5.28
  */
 public function bar2dFunction()
 {
     $sDimen = $this->aDimen[0];
     $sCount = 0;
     $this->aChartStyles['tipTitle'] = \YcheukfReport\Lib\ALYS\ALYSLang::_($sDimen);
     //异常处理
     if (count($this->aMainTable['showField']) != 1) {
         throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_INPUT_METRIC_NUM_WRONG', '有且只能为1个指标');
     }
     $aDimenFilter = array();
     if (!empty($this->aInput['input']['flash']['table'][$this->aMainTable['table']]['dimen'][0]['dimenFilter'])) {
         $aDimenFilter = $this->aInput['input']['flash']['table'][$this->aMainTable['table']]['dimen'][0]['dimenFilter'];
     }
     $datasets = "";
     //var_dump($this->aDatas);
     if (isset($this->aMainTable['showField']) && is_array($this->aMainTable['showField'])) {
         foreach ($this->aMainTable['showField'] as $date_i => $showField) {
             //根据dimenFilter重组数据
             if (!empty($aDimenFilter)) {
                 if (!is_array($aDimenFilter)) {
                     throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', 'dimenFilter must be array');
                 }
                 $aTmpFlash = $aTmpData = array();
                 foreach ($aDimenFilter as $df) {
                     if (empty($this->aFlashDatas[$date_i][$df][$showField])) {
                         $aTmpFlash[$df][$showField] = 0;
                         $aTmpData[$df][$showField] = 0;
                     } else {
                         $aTmpFlash[$df][$showField] = $this->aFlashDatas[$date_i][$df][$showField];
                         $aTmpData[$df][$showField] = $this->aDatas[$date_i][$df][$showField];
                     }
                 }
                 $this->aDatas[$date_i] = $aTmpData;
                 $this->aFlashDatas[$date_i] = $aTmpFlash;
             }
             if (!empty($this->aDatas[$date_i]) && is_array($this->aDatas[$date_i])) {
                 $iSumValue = 0;
                 //总数 用于后边求百分比
                 //调用Id2label翻译
                 if (!empty($sDimen)) {
                     foreach ($this->aDatas[$date_i] as $key => $value) {
                         //$iSumValue+=$this->aFlashDatas[$date_i][$key][$showField];
                         $aIDs[$sDimen][] = $key;
                     }
                     $oId2Label = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Id2label');
                     $aLabel = $oId2Label->ALYSchgId2Label($this->dimenkey2selected, $aIDs);
                 }
                 foreach ($this->aDatas[$date_i] as $date => $Data) {
                     $value = $this->aFlashDatas[$date_i][$date][$showField];
                     $datasets .= "<set label='" . (empty($sDimen) ? \YcheukfReport\Lib\ALYS\ALYSFunction::_htmlspecialchars($date) : \YcheukfReport\Lib\ALYS\ALYSFunction::_htmlspecialchars($aLabel[$sDimen][$date])) . "' value='" . $value . "' tooltext=' ' color='58b819'/>";
                     $sCount++;
                 }
             } else {
                 //无数据
                 $datasets .= "<set />";
             }
         }
     }
     $categories = array();
     return array($categories, $datasets, $sCount);
 }
Example #9
0
 /**
  * 重写
  * 获得数据入口
  */
 public function getData()
 {
     $type_R = 'detail';
     $nIndex = 0;
     $aInput = $this->aInput['input'][$type_R];
     $mainTable = $aInput['mainTable']['table'];
     $dimens = $aInput['tables'][$mainTable]['dimen'];
     //获取列表数据
     $aData_R = array();
     $aData_R = $this->aInput['internal']['listData'][$nIndex];
     $aConcatKey = array();
     //次表条件
     if (count($aData_R) > 0) {
         foreach ($aData_R as $j => $aDataTmp) {
             foreach ($dimens['key'] as $groupField) {
                 if ('perspective' == $aInput['type']) {
                     //若为透视图的x轴, 则跳过该搜索条件过滤
                     if ($groupField == $aInput['table'][$mainTable]['xdimen_key'][0]) {
                         continue;
                     }
                     $sValTmp = $aDataTmp[$groupField];
                     //						foreach($aDataTmp[$groupField] as $sKeyTmp =>$sValTmp){
                     $aConcatKey[$nIndex][$dimens['dimenkey2field'][$groupField]][$sValTmp] = $sValTmp;
                     //						}
                     ////						$aConcatKey = $aConcatKeyNew;
                 } else {
                     $aConcatKey[$nIndex][$dimens['dimenkey2field'][$groupField]][$j] = $aDataTmp[$groupField];
                 }
             }
         }
     }
     //		var_export($aConcatKey);
     //				if('perspective' == $aInput['type'] && $group==$aInput['table'][$mainTable]['xdimen_key'][0])//
     //		var_export($aConcatKey);
     $type = 'flash';
     $aConf = $this->getConf($type);
     $aDates = $this->getDate($type);
     $aFlashConfig = array();
     foreach ($aDates as $k => $Date) {
         foreach ($aConf as $table => $aConfigTmp) {
             $aFlashConfig[$k][$table] = $aConfigTmp;
             $aCondition = $aConfigTmp['condition'];
             $aCondition = array_merge(array($Date), $aCondition);
             $aFlashConfig[$k][$table]['condition'] = $aCondition;
         }
     }
     //		var_export($aInput['table'][$mainTable]['xdimen_key'][0]);
     $aConfSeconds = array();
     $aSortIndexs = $this->aInput['input'][$type]['sort_indexs'];
     $oId2Label = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Id2label');
     //		\YcheukfReport\Lib\ALYS\ALYSFunction::debug( $aSortIndexs, 'a', 'aSortIndexs');
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     $aListDataCondition = array();
     $aFlashSeries = array();
     //flash legend列表中的翻译
     if (count($aConcatKey) > 0) {
         foreach ($aConcatKey[$nIndex] as $group => $val) {
             $quotes = $oDict->ALYSgetDimenTypeOf($group);
             $k = 0;
             foreach ($val as $v) {
                 if (in_array($k, $aSortIndexs)) {
                     $aLabel = $oId2Label->ALYSchgId2Label(array($group), array($group => array($v)));
                     $aFlashSeries[$k][] = $aLabel[$group][$v];
                     $groupCondition[$k] = $group . " in (" . $quotes . $v . $quotes . ")";
                     $aListDataCondition[$k][] = $groupCondition[$k];
                 }
                 $k++;
             }
         }
     }
     //重写flash的series栏
     $this->aInput['input'][$type]['seriestips'] = array();
     foreach ($aFlashSeries as $i => $row) {
         $this->aInput['input'][$type]['seriestips'][] = join(",", $row);
     }
     //		unset($aListDataCondition[1]);
     //		\YcheukfReport\Lib\ALYS\ALYSFunction::debug($aFlashConfig, 'a', 'aFlashConfig');
     $nIndexSecond = 0;
     foreach ($aFlashConfig[$nIndex] as $table => $aConfigTmp) {
         foreach ($aListDataCondition as $sort_i => $aTmp) {
             $aCondition = $aConfigTmp['condition'];
             if ($this->aInput['input'][$type]['sort_totalflag'] && $nIndexSecond == 0) {
                 //若需要统计总计
                 $aConfSeconds[$nIndexSecond][$table] = $aConfigTmp;
                 array_unshift($this->aInput['input'][$type]['seriestips'], \YcheukfReport\Lib\ALYS\ALYSLang::_('SORT_TOTAL'));
                 $nIndexSecond++;
             }
             foreach ($aListDataCondition[$sort_i] as $aConditionTmp) {
                 $aCondition[] = $aConditionTmp;
             }
             $aConfSeconds[$nIndexSecond][$table] = $aConfigTmp;
             $aConfSeconds[$nIndexSecond][$table]['condition'] = $aCondition;
             $nIndexSecond++;
         }
     }
     //		\YcheukfReport\Lib\ALYS\ALYSFunction::debug($aConfSeconds, 'a', 'aConfSeconds');
     foreach ($aConfSeconds as $k => $aConf) {
         foreach ($aConf as $table => $aConfigTmp) {
             list($aData[$k][$table], $nTmpTotal) = $this->{$type}->getAlldata($aConfigTmp);
         }
     }
     $aData = $this->_executeSqlData($type, $aData);
     \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput);
     return $aData;
 }
Example #10
0
 /**
  * 处理sql结果数据
  */
 public function _executeSqlData($type, $aDatas)
 {
     //var_dump($aDatas);
     $aDataNs = array();
     $aTables = $this->aInput['input'][$type]['tables'];
     $aMainTable = $this->aInput['input'][$type]['mainTable'];
     $sMainTableName = $aMainTable['table'];
     //主表名
     //所有field 包括show为false的
     $arrFieldShowFalse = array();
     $arrField2TableShowFalse = array();
     if (isset($this->aInput['input'][$type]['table'][$sMainTableName]['metric'])) {
         $arrFields = $this->aInput['input'][$type]['table'][$sMainTableName]['metric'];
         foreach ($arrFields as $fv) {
             if (isset($fv['show']) && false == $fv['show']) {
                 $arrFieldShowFalse[] = $fv['key'];
                 $arrField2TableShowFalse[$fv['key']] = $sMainTableName;
             }
         }
     }
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     //		var_export($aTables[$aMainTable['table']]);
     $allField = array();
     $aReplace = array('+', '-', '*', '/', '(', ')');
     $sAllField = '';
     //		print_r($aMainTable['showField']);
     foreach ($aMainTable['showField'] as $showField) {
         if (in_array($showField, $aMainTable['field3'])) {
             $sEval = $oDict->ALYSmetricExpresion($showField);
             $sEval = preg_replace('/\\s+/', '', $sEval);
             $sAllField .= str_replace($aReplace, ',', $sEval) . ',';
         } else {
             $allField[] = $showField;
         }
     }
     $sAllField = preg_replace('/,+/', ',', $sAllField);
     $sAllField = substr($sAllField, 0, -1);
     if ($sAllField) {
         $allField = array_unique(array_merge($allField, explode(',', $sAllField)));
     }
     $allField = array_unique(array_merge($allField, $arrFieldShowFalse));
     $allFieldTmp = $this->_sortArray($allField);
     //		var_export($allFieldTmp);
     //找到拼接数组的gap
     $aExtraDimen = array();
     foreach ($aTables as $table => $aTmp) {
         if ($table == $aMainTable['table']) {
             continue;
         }
         foreach ($aTables[$aMainTable['table']]['dimen']['key'] as $i => $sDimen) {
             if (!in_array($sDimen, $aTables[$table]['dimen']['key'])) {
                 $aExtraDimen[$table][$sDimen] = $i;
             }
         }
     }
     $aTable2Field = $aMainTable['field2Table'];
     if (is_array($arrField2TableShowFalse)) {
         $aTable2Field = $aTable2Field + $arrField2TableShowFalse;
     }
     //print_r($aMainTable['showField']);
     //$allField=array('sp_ns');
     //		print_r($aDatas);
     //print_r($aTable2Field);
     //echo "aDatas=";print_r($aDatas);
     $aConcatKey2ConcatKey = array();
     //拼接数组的映射数组
     $aDataNsKey = array();
     //		var_export($aMainTable['table']);
     //		var_export($aDatas);
     foreach ($aDatas as $date_i => $aData) {
         foreach ($aTables as $table => $v) {
             foreach ($aData[$table] as $Data) {
                 if ($table == $aMainTable['table']) {
                     //var_dump($Data['concatKey']);
                     $aConcatKey2ConcatKey[$table][$Data['concatKey']] = $Data['concatKey'];
                 } else {
                     foreach ($aConcatKey2ConcatKey[$aMainTable['table']] as $vTmp) {
                         //							$this->splitChar
                         $aSplit = explode($this->splitChar, $vTmp);
                         if (isset($aExtraDimen[$table])) {
                             foreach ($aExtraDimen[$table] as $k2) {
                                 unset($aSplit[$k2]);
                             }
                         }
                         $vTmp2 = join($this->splitChar, $aSplit);
                         $aConcatKey2ConcatKey[$table][$vTmp] = $vTmp2;
                     }
                 }
                 $aDataNsKey[$date_i][$table][$Data['concatKey']] = $Data;
             }
         }
     }
     //		print_r($aTables[$aMainTable['table']]['dimen']['dimenkey2selected']);
     //		print_r($aDataNsKey);
     //		print_r($aTable2Field);
     foreach ($aDataNsKey as $date_i => $aData) {
         if (is_array($aData[$aMainTable['table']])) {
             foreach ($aData[$aMainTable['table']] as $k => $Data) {
                 //$aDataNs[$date_i][$k]['concatKey']=$Data['concatKey'];
                 $concatKey = $Data['concatKey'];
                 foreach ($allField as $field) {
                     if (empty($field)) {
                         continue;
                     }
                     $sTmpTable = $aTable2Field[$field];
                     $dataConcatKey = $aConcatKey2ConcatKey[$sTmpTable][$concatKey];
                     $sSelectedField = isset($aTables[$aMainTable['table']]['dimen']['dimenkey2selected'][$field]) ? $aTables[$aMainTable['table']]['dimen']['dimenkey2selected'][$field] : $field;
                     $aDataNs[$date_i][$concatKey][$field] = isset($aData[$sTmpTable][$dataConcatKey][$sSelectedField]) ? $aData[$sTmpTable][$dataConcatKey][$sSelectedField] : (isset($aData[$sTmpTable][$dataConcatKey][$field]) ? $aData[$sTmpTable][$dataConcatKey][$field] : 0);
                 }
             }
         }
     }
     //print_r($aMainTable['field3']);
     //var_dump($aDataNs);
     //print_r($allField);
     $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
     foreach ($aDataNs as $date_i => $aDataN) {
         foreach ($aDataN as $key => $Data) {
             foreach ($aMainTable['field3'] as $field3) {
                 $sEval = $oDict->ALYSmetricExpresion($field3);
                 //echo "sEval=".$sEval;
                 foreach ($allFieldTmp as $field) {
                     if (empty($Data[$field])) {
                         $Data[$field] = 0;
                     }
                     $sEval = str_replace($field, $Data[$field], $sEval);
                 }
                 //echo "sEval=".$sEval;
                 @eval('$val=' . $sEval . ';');
                 if (!$val) {
                     $val = 0;
                 }
                 $aDataNs[$date_i][$key][$field3] = $val;
             }
         }
     }
     $aData = $aDataNs;
     //var_dump($aData);
     return $aData;
 }
Example #11
0
 /**
  * ID 转化为label
  */
 public function _chgId2Lable($type)
 {
     $aID = array();
     foreach ($this->aOutput[$type] as $date_i => $aData) {
         foreach ($aData as $Data) {
             foreach ($this->aDimen as $dimen) {
                 $aID[$dimen][] = $Data[$dimen];
             }
         }
     }
     $oId2Label = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Id2label');
     $aLabel = $oId2Label->ALYSchgId2Label($this->dimenkey2selected, $aID);
     foreach ($this->aOutput[$type] as $date_i => $aData) {
         foreach ($aData as $concatKey => $Data) {
             foreach ($this->aDimen as $dimen) {
                 $this->aOutput[$type][$date_i][$concatKey][$dimen] = $aLabel[$dimen][(string) $Data[$dimen]];
             }
         }
     }
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
 }
Example #12
0
 private function _chgId2LabelForXField($aXDimen, $aXField)
 {
     $oId2Label = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Id2label');
     return $oId2Label->ALYSchgId2Label(array($aXDimen), array($aXDimen => $aXField));
 }
Example #13
0
 /**
  * 不同的部分
  */
 public function go_diff()
 {
     $geoType = $this->dateType;
     $showLabels = 0;
     $type = 'flash';
     $aInput = $this->aInput['input'][$type];
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     $noDataShowLabel = empty($_ALYSconfig['fusion']['geography']['noDataShowLabel']) ? 0 : 1;
     $geographyRange = empty($aInput['geoRangeStyle']) ? 'common' : $aInput['geoRangeStyle'];
     unset($this->aChartStyles['range']);
     $field = $aInput['mainTable']['showField'][0];
     $oId2Label = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Id2label');
     $aTmp = $oId2Label->ALYSchgId2Label($this->dimenkey2selected);
     $aryLabelSet4Geo = $aTmp[key($this->dimenkey2selected)];
     $Data = $this->aDatas[0][$field];
     $DataN = $this->aFlashDatas[0][$field];
     //$Data = $DataN = array(58=>900);
     //		var_dump($aTmp);
     //翻译citykey
     $sCitykey = 'num2citykey';
     $aIDs = array();
     if (is_array($DataN)) {
         foreach ($DataN as $k => $v) {
             $aIDs[$sCitykey][] = $k;
         }
     }
     $aLabel = $oId2Label->ALYSchgId2Label(array($sCitykey => $sCitykey), $aIDs);
     $aCityMap = $aLabel[$sCitykey];
     //var_dump($aCityMap,$Data);exit;
     $fieldLabel = \YcheukfReport\Lib\ALYS\ALYSLang::_($field);
     if ($geoType == 'country') {
         $aCountrySN2Id = $this->_getCountryShortName2Id();
         $aryLabelSet4Geo = $this->_getCompatibleCode($aryLabelSet4Geo);
         foreach ($aryLabelSet4Geo as $shortName => $geoLabel) {
             $fusionCountryId = $this->_chgLocationCode2FusionCode($shortName);
             if (empty($aCountrySN2Id[$fusionCountryId])) {
                 continue;
             }
             $iniId = $aCountrySN2Id[$fusionCountryId];
             if ($Data[$fusionCountryId]) {
                 if (!empty($_ALYSconfig['fusion']['geography']['linkble'])) {
                     $event = $shortName == 'CN' ? "link=\\\"JavaScript:changeGeoMap('country', '" . $shortName . "');\\\"" : "";
                 }
                 $value = $DataN[$fusionCountryId];
                 $entitys .= "<entity id='" . $iniId . "' value='" . $value . "' showLabel='1' displayValue='" . $geoLabel . "' toolText='" . $fieldLabel . ',' . $geoLabel . ',' . $Data[$fusionCountryId] . "' " . $event . "/>";
             } else {
                 $entitys .= "<entity id='" . $iniId . "' value='0' displayValue='" . $geoLabel . "' toolText='" . $geoLabel . "' showLabel='" . $noDataShowLabel . "' />";
             }
         }
     } elseif ($geoType == 'province') {
         unset($Data['CN00']);
         foreach ($aryLabelSet4Geo as $shortName => $geoLabel) {
             list($t, $geoLabel) = explode('-', $geoLabel);
             $countryCode = substr($shortName, 0, 2);
             if ($countryCode == 'CN') {
                 $provinceCode = substr($shortName, 2, 2);
                 $fusionProvinceId = 'CN.' . $provinceCode;
                 $fusionProvinceId = $this->_chgLocationCode2FusionCode($fusionProvinceId);
                 if (!empty($_ALYSconfig['fusion']['geography']['linkble'])) {
                     $event = " link=\\\"JavaScript:changeGeoMap('province', '" . $countryCode . '.' . $provinceCode . "');\\\"";
                 }
                 if (!empty($aCityMap[$shortName])) {
                     $shortName = $aCityMap[$shortName];
                 }
                 if ($Data[$shortName]) {
                     //$selectedProvince = ($geoType == 'city' && strtoupper($provinceCode)==strtoupper($aryData['geoTypeProvinceCode']))? "fontBold='1' fontSize='16' fontColor='0' color='FF9933'":"";
                     $value = $DataN[$shortName];
                     $entitys .= "<entity id='" . $fusionProvinceId . "' value='" . $value . "' showLabel='1' displayValue='" . $geoLabel . "' toolText='" . $fieldLabel . ',' . $geoLabel . ',' . $Data[$shortName] . "' {$event} {$selectedProvince}/>";
                 } else {
                     $entitys .= "<entity id='" . $fusionProvinceId . "' value='0' displayValue='" . $geoLabel . "' toolText='" . $geoLabel . "' showLabel='" . $noDataShowLabel . "'  {$event}/>";
                 }
             } else {
                 unset($Data[$shortName]);
             }
         }
         $showLabels = 1;
     }
     //echo "aryLabelSet4Geo=";print_r($aryLabelSet4Geo);
     //$colorRange = $this->_getFusionColorRange($field, @max($DataN));
     if ('percent' == $geographyRange) {
         $colorRange = $this->_rangeColor1to10percent(@max($DataN));
     } elseif ('5hundred' == $geographyRange) {
         $colorRange = $this->_rangeColor1to5hun(@max($DataN));
     } else {
         $colorRange = $this->_getFusionColorRange($field, @max($DataN));
     }
     $s1 = "";
     $sUrlBase = \YcheukfCommon\Lib\Functions::getBaseUrl($_ALYSconfig['smHandle']);
     if (count($this->aChartStyles)) {
         foreach ($this->aChartStyles as $k => $v) {
             $s1 .= " {$k}='{$v}'";
         }
         if (isset($_ALYSconfig['fusion']['exportHandler'])) {
             $s1 .= " exportHandler='" . $sUrlBase . '/' . $_ALYSconfig['fusion']['exportHandler'] . "'";
         }
     }
     $this->xmlData = "<map showLabels ='" . $showLabels . "' legendCaption='" . $fieldLabel . "' {$s1}>" . $colorRange . "<data>" . $entitys . '</data></map>';
 }