public function getConditionByInput() { $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput(); $aCondition = array(); //日期 $dateField = \YcheukfReport\Lib\ALYS\Report::getDateFeildByTable(); foreach ($aInput['date'] as $aDate) { $aCondition[] = "(" . $dateField . " >= '" . $aDate['s'] . "' and " . $dateField . " <= '" . $aDate['e'] . "')"; } //filter if (is_array($aInput['filters'])) { foreach ($aInput['filters'] as $condition) { $aCondition[] = $condition['key'] . ' ' . $condition['op'] . ' ' . $condition['value']; } } $sCondition = 1; if (is_array($aCondition) && !empty($aCondition)) { $sCondition = implode(' and ', $aCondition); } return $sCondition; }
/** * ��������� */ 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); }