Example #1
0
 /**
  * 获得数据入口
  */
 public function getData()
 {
     $type = 'total';
     if (\YcheukfReport\Lib\ALYS\Report\Advance::isAdvanced($type)) {
         $aData = $this->getAdvancedData($type);
     } else {
         $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
         $aConf = $this->getConf($type);
         $aDatesNew = $this->getDateNew($type);
         $aDates = $this->getDate($type);
         $aConfs = array();
         foreach ($aDates as $k => $Date) {
             foreach ($aConf as $table => $Conf) {
                 $aConfs[$k][$table] = $Conf;
                 $aCondition = $Conf['condition'];
                 if (isset($aInput['nodateFlag']) && !$aInput['nodateFlag']) {
                     //have date
                     $aCondition = array_merge(array($aDatesNew[$k][$table]), $aCondition);
                 }
                 //					$aCondition=array_merge(array($aDatesNew[$k][$table]),$aCondition);
                 $aConfs[$k][$table]['condition'] = $aCondition;
             }
         }
         //\YcheukfReport\Lib\ALYS\ALYSFunction::debug($aConfs, 'a', 'aConfs');
         foreach ($aConfs as $k => $aConf) {
             foreach ($aConf as $table => $Conf) {
                 list($aData[$k][$table], $nTmpTotal) = $this->{$type}->getAlldata($Conf);
             }
         }
     }
     $aData = $this->_executeSqlData($type, $aData);
     return $aData;
 }
Example #2
0
 public function initInputAdvance($type)
 {
     $aMainTable = array();
     $tables = array();
     //$aMainTable ��֯
     $table = 'mainTable';
     $aMetric = \YcheukfReport\Lib\ALYS\Report\Advance::getAdvanceMetrics($type);
     if ('detail' == $type) {
         $aDimens = \YcheukfReport\Lib\ALYS\Report\Advance::getAdvanceDimens($type);
         $aMainTable['showField'] = array_merge($aDimens, $aMetric);
     } else {
         $aMainTable['showField'] = $aMetric;
     }
     if (empty($aMainTable['showField'])) {
         throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', 'need metrics');
     }
     $aMainTable['field3'] = array();
     $aMainTable['table2Field'] = array();
     $aMainTable['table'] = $table;
     //ֻ����һ������
     if (is_array($aMainTable['showField'])) {
         foreach ($aMainTable['showField'] as $f) {
             $aMainTable['field2Table'][$f] = $table;
         }
     }
     //tables ��֯
     $aDimens = \YcheukfReport\Lib\ALYS\Report\Advance::getAdvanceDimens($type);
     $tables[$table]['dimen']['key'] = $aDimens;
     $tables[$table]['dimen']['dimenkey2field'] = array_flip($aDimens);
     $this->aInput['input'][$type]['mainTable'] = $aMainTable;
     $this->aInput['input'][$type]['tables'] = $tables;
     //��ʼά�� ָ�� (����)
     $this->aInput['input'][$type]['table'][$table]['dimen'] = $this->aInput['input'][$type]['advanced']['dimen'];
     $this->aInput['input'][$type]['table'][$table]['metric'] = $this->aInput['input'][$type]['advanced']['metric'];
     \YcheukfReport\Lib\ALYS\Report\Start::setInput($this->aInput);
 }
Example #3
0
 /**
  * 获得数据入口
  */
 public function getData()
 {
     $type = 'detail';
     if (\YcheukfReport\Lib\ALYS\Report\Advance::isAdvanced($type)) {
         $aData = $this->getAdvancedData($type);
         //			var_dump($aData);
     } else {
         $this->_init();
         //初始化
         $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
         $aConf = $this->getConf($type);
         $aDatesNew = $this->getDateNew($type);
         $aDates = $this->getDate($type);
         //			print_r($aConf);
         $aConfs = array();
         $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
         //			var_dump($aInput['nodateFlag']);
         foreach ($aDates as $k => $Date) {
             foreach ($aConf as $table => $Conf) {
                 $aConfs[$k][$table] = $Conf;
                 $aCondition = $Conf['condition'];
                 if (isset($aInput['nodateFlag']) && !$aInput['nodateFlag']) {
                     //have date
                     $aCondition = array_merge(array($aDatesNew[$k][$table]), $aCondition);
                 }
                 //					$aCondition=array_merge(array($aDatesNew[$k][$table]),$aCondition);
                 $aConfs[$k][$table]['condition'] = $aCondition;
             }
         }
         //			var_dump($aCondition);
         foreach ($aConfs as $k => $aConf) {
             foreach ($aConf as $table => $Conf) {
                 list($aData[$k][$table], $nTotal) = $this->{$type}->getAlldata($Conf);
                 //主表数据
                 $this->_setTotal($type, $nTotal);
                 break;
             }
         }
         //		\YcheukfReport\Lib\ALYS\ALYSFunction::debug($aData, 'a', 'aData');
         $aInput = $this->aInput['input'][$type];
         $mainTable = $aInput['mainTable']['table'];
         $table2Field = $aInput['mainTable']['table2Field'];
         //echo "dimens=";print_r($dimens);
         //$aGroup=$aInput['tables'][$mainTable]['dimen']['key'];
         //$aGroup=$aInput['tables'][$mainTable]['dimen']['dimenkey2field'];
         $aConcatKey = array();
         //次表条件
         foreach ($aConfs as $k => $aConfTmp) {
             if (!empty($aData[$k][$mainTable])) {
                 foreach ($aData[$k][$mainTable] as $j => $Data) {
                     foreach ($aInput['tables'] as $table => $aTable) {
                         if ($table != $mainTable) {
                             $dimens = $aInput['tables'][$table]['dimen'];
                             foreach ($dimens['dimenkey2field'] as $keyTmp => $fieldTmp) {
                                 $aConcatKey[$k][$fieldTmp][$j] = $Data[$keyTmp];
                             }
                         }
                     }
                 }
             } else {
                 //若主表无数据, 则将此表条件制空
                 foreach ($aInput['tables'] as $table => $aTable) {
                     if ($table != $mainTable) {
                         $dimens = $aInput['tables'][$table]['dimen'];
                         foreach ($dimens['dimenkey2field'] as $keyTmp => $fieldTmp) {
                             $aConcatKey[$k][$fieldTmp][$j] = '';
                         }
                     }
                 }
             }
         }
         //		echo "aConcatKey=";print_r($aConcatKey);
         $aConfSecond = array();
         foreach ($aInput['tables'] as $table => $aTable) {
             //次表
             if ($table != $mainTable) {
                 $aConftion = array();
                 $aConftion = $this->getCondition($type, $table);
                 $aConftionAry = $this->getCondition($type, $table, 'array');
                 $aConfSecond[$table] = array('noRecord' => 0, 'limit' => 0, 'field_array' => $this->getField($type, $table, 'array'), 'dimen_array' => $this->getDimenFieldArray($type, $table), 'metric_array' => $this->getMetricFieldArray($type, $table), 'groupby' => $aInput['tables'][$table]['dimen']['key'], 'table' => $oDict->ALYStableDefine($table), 'condition' => $aConftion, 'condition_array' => $aConftionAry);
             }
         }
         $aConfSeconds = array();
         foreach ($aDates as $k => $Date) {
             foreach ($aConfSecond as $table => $Conf) {
                 $aConfSeconds[$k][$table] = $Conf;
                 $aCondition = $Conf['condition'];
                 $aCondition = array_merge(array($aDatesNew[$k][$table]), $aCondition);
                 if (is_array($aConcatKey[$k])) {
                     foreach ($aConcatKey[$k] as $group => $val) {
                         $aTmp = array();
                         $val = array_unique($val);
                         $quotes = $oDict->ALYSgetDimenTypeOf($group);
                         //		var_export($group);
                         //		var_export($quotes);
                         //		var_export($val);
                         //echo "<hr>";
                         foreach ($val as $v) {
                             $aTmp[] = $quotes . $v . $quotes;
                         }
                         $aCondition[] = $group . ' in (' . implode(',', $aTmp) . ')';
                     }
                 }
                 $aConfSeconds[$k][$table]['condition'] = $aCondition;
             }
         }
         foreach ($aConfSeconds as $k => $aConf) {
             foreach ($aConf as $table => $Conf) {
                 list($aData[$k][$table], $nTmpTotal) = $this->{$type}->getAlldata($Conf);
                 //次表数据
             }
         }
     }
     //		echo "<xmp>";
     //		echo "aConfSeconds=";print_r($aConfSeconds);
     $aData = $this->_executeSqlData($type, $aData);
     //		echo "<xmp>";
     return $aData;
 }
Example #4
0
 /**
  * 为table_pie, table_bar加入total的input
  */
 private function _getTotalInput($aInput)
 {
     $aRe = array();
     $tableType = $aInput['detail']['type'];
     if ($tableType == 'table_pie' or $tableType == 'table_bar') {
         if (\YcheukfReport\Lib\ALYS\Report\Advance::isAdvanced('detail')) {
             //自定义数据
             $aRe['advanced'] = array('type' => 'datas', 'dimen' => $aInput['detail']['advanced']['dimen'], 'metric' => $aInput['detail']['advanced']['metric'], 'data' => $aInput['detail']['advanced']['total']);
         } else {
             $aRe['table'] = $aInput['detail']['table'];
         }
         $aRe['type'] = 'common';
     }
     return $aRe;
 }