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; }
function go() { $type = 'total'; $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput(); $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput(); $aOffsetData = $aOutput['total']; foreach ($aOutput['total'] as $date_i => $aData) { foreach ($aData as $i => $aTmp) { $compareFlag = $date_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[$date_i][$metric] = $offerPercent; } } } } $this->_formatMetric($type); //格式化 $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("total"); $aOutput['total.output'] = $oPlugin->ALYSfmtOutputHtml($aOffsetData); \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput); }
function _format_html_list($_sStr) { $aCssConfig = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("Css"); $aCss = $aCssConfig->ALYSfmtOuputListHtml(); $_sStr = str_replace(array_keys($aCss), array_values($aCss), $_sStr); return $_sStr; }
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); }
private static function _fmtHtml($sHtml) { $s = <<<OUTPUT <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=8" /> <title>[replace_title]</title> [replace_css_file] [replace_script_file] <script type="text/javascript"> \t\t\t[replace_script] </script> <style> [replace_style] </style> <body> \t{$sHtml} </body> </html> OUTPUT; $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("Statichtml"); return $oPlugin->ALYSbefore_output($s); }
function go() { // \YcheukfReport\Lib\ALYS\ALYSFunction::debug($this->aOutput, 'a', 'www'); $flashHtmlFormat = isset($this->aInput['output']['flashHtmlFormat']) ? $this->aInput['output']['flashHtmlFormat'] : 'fusion'; $oHtmlFormat = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("Report.Output.Flash.Format.Html." . $flashHtmlFormat . "." . $this->aInput['input']['flash']['type']); $oHtmlFormat->go(); }
public function _fmtOutput() { $type = 'detail'; $this->_fmtDimen_Metric($type); $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput(); $o = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("report.output." . $type . ".format." . $this->aInput['output']['format']); $o->go(); }
function go() { $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput(); $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("csv"); $sCsv = $oPlugin->ALYSfmtOutputCsv($aOutput); $aOutput['output'] = $sCsv; \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput); }
public function go() { $o = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("report.output.format.statichtml"); // $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput(); $sStaticKey = $o->go(); $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("email"); $aInfo = $oPlugin->ALYSbefore_email($sStaticKey); $m = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("ALYSEmail"); $m->send($aInfo['toEmail'], $aInfo['subject'], $aInfo['body']); // return $flag?1:0; }
public function _fmtOutput() { // $this->ALYSformat($type); $this->_getPercent(); $type = 'detail'; $this->aOutput[$type] = $this->_fmtTdStyle($type); \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput); //$aOutput['detail'] = $this->_fmtData(); $o = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("report.output." . $type . ".format." . $this->aInput['output']['format']); $o->go(); }
/** * @生成PDF文件 **/ function _createPdf($sFlash, $aTotal, $aList, $visitType, $top, $headFoot, $pageFooter = '') { $pdfname = 'allyes_' . uniqid() . ".pdf"; /** * @获取图表基础数据 **/ $css_total = $aTotal; $css_list = $aList; /** * @初使PDF对象 * 默认是I:在浏览器中打开,D:下载,F:在服务器生成pdf ,S:只返回pdf的字符串 **/ $pdf = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("pdf"); $_pdfname = $pdf->setInfo($pdfname, strtoupper($visitType), $top, $headFoot, $pageFooter); $pdf->addPage(); /** * @初使图表配置样式 **/ // $aCssConfig = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("Formatpdf"); // $aCss = $aCssConfig->ALYSload_style(); // // $akv = array(); // // 处理基本数据与样式的搭配(1) // $akv = $pdf->aRecur($aCss['total']); // $css_total = $pdf->replaceCss($akv,$total); // // // 处理基本数据与样式的搭配(2) // $akv = $pdf->aRecur($aCss['detail']); // $css_list = $pdf->replaceCss($akv,$list); // // //处理图片 $css_flash = $pdf->setImg($sFlash); //进一步处理不规则样式 // $css_list = preg_replace("/\<div class\=\"color\"\>\<\/div\>/i","",$css_list); // $css_total = preg_replace("/<div class=\"mdata\">/i","",$css_total); // $css_total = preg_replace("/\<\/div\>/i","",$css_total); //将数据添加至PDF类,使其形成PDF文件 $pdf->writeHTML(\YcheukfReport\Lib\ALYS\ALYSLang::_("PDF_FLASH_TITLE")); $pdf->Ln(); $pdf->writeHTML($css_flash); $pdf->writeHTML(\YcheukfReport\Lib\ALYS\ALYSLang::_("PDF_TOTAL_TITLE")); $pdf->Ln(); $pdf->writeHTML($css_total); $pdf->writeHTML(\YcheukfReport\Lib\ALYS\ALYSLang::_("PDF_LIST_TITLE")); $pdf->Ln(); $pdf->writeHTML($css_list); $pdf->read(); return $_pdfname; }
function go() { $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput(); $sHtml = ""; if (isset($aOutput['flash.output'])) { $sHtml .= $aOutput['flash.output'] . "\n\n"; } if (isset($aOutput['total.output'])) { $sHtml .= $aOutput['total.output'] . "\n\n"; } if (isset($aOutput['detail.output'])) { $sHtml .= $aOutput['detail.output'] . "\n\n"; } $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("xml"); $sTitle = $oPlugin->ALYSxml_title(); $aOutput['output'] = "<?xml version='1.0' encoding='UTF-8'?>\n<report>\n\n" . $sTitle . $sHtml . "\n\n</report>"; \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput); }
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; }
function go() { $th = ''; $sOutputFormat = strtolower($this->aInput['output']['format']); $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin('detail'); //标题列 $th .= $oPlugin->ALYSfmt_list_title($this->aInput['groups'], $sOutputFormat); //根据不同的输出类型处理是否要出现饼图/柱状图 if ($this->aInput['input']['detail']['showBarColFlag']) { $sHTML = ""; $keys = array_keys($this->aInput['groups']['metric']); for ($i = 0; $i < count($this->aInput['groups']['metric']); $i++) { $j = $keys[$i]; $aGroup = $this->aInput['groups']['metric'][$j]; if (!$aGroup['pieFieldAble']) { continue; } if (isset($aGroup['ispercent']) && false == $aGroup['ispercent']) { continue; } $selected = $this->aInput['input']['detail']['selected']; if ($aGroup['key'] == $selected) { $selected = 'selected'; } //$selected = $aGroup['pieFieldSelected'] ? 'selected':''; $sHTML .= '<OPTION VALUE="' . $aGroup['key'] . '" ' . $selected . '>' . \YcheukfReport\Lib\ALYS\ALYSLang::_($aGroup['label']) . '</OPTION>'; } $th .= "\n<th nowrap class='thPieList' class='td250'>" . \YcheukfReport\Lib\ALYS\ALYSLang::_('percent') . "<SELECT class='pieList'>{$sHTML}</SELECT></th>"; } ////表格主体//// $aryListData = $this->aOutput['detail']; //列表内容的HTML生成 $html = $oPlugin->ALYSfmt_list($aryListData); //外包装 $sContent = $oPlugin->ALYSfmt_list_table($th, $html); $this->aOutput['detail.output'] = $sContent; \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput); // var_export($this->aOutput); }
public static function _($s, $aReplace = array(), $returnFlag = 1) { $s = strtoupper($s); $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("lang"); $sLangVal = $oPlugin->ALYSbefore_translation($s); if ($sLangVal == $s) { $aDict = self::getDict(); $s = isset($aDict[$s]) ? $aDict[$s] : $s; if (is_array($aReplace)) { for ($i = 0; $i < count($aReplace); $i++) { $s = str_replace("[replace{$i}]", $aReplace[$i], $s); } } elseif (is_string($aReplace)) { $s = str_replace("[replace0]", $aReplace, $s); } $sLangVal = $s; } if ($returnFlag) { return $sLangVal; } else { echo $sLangVal; } }
/** * set db object */ public function setOdbp() { $sDboperator = \YcheukfReport\Lib\ALYS\ALYSConfig::get('dboperator'); self::$oInstant = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("dboperate." . $sDboperator); }
function _fmtOutput($type) { $o = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("report.output." . $type . ".format." . $this->aInput['output']['format']); $o->go(); }
public function __construct() { // $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get(); $this->DB = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("Dboperate.Sql"); }
function go() { $o = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("report.output.Flash.format.statichtml"); $o->go(); }
function go() { $bIsPerspective = 'perspective' == $this->aInput['input']['detail']['type'] ? true : false; //是否为透视图 $separator = $this->_getCsvSeparator(); $csvTitle = $csvBody = $tmpTdString = ''; $indexNum = 1; $csvTitle .= "NO {$separator}"; $oCSVPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("csv"); $csvBody = $oCSVPlugin->ALYSfmtOutputCsv(); //waiting... $arrGroup = $oCSVPlugin->ALYSfmtListTitle($this->aInput['groups']); //扩展 if (is_array($arrGroup)) { foreach ($arrGroup as $k => $aTmp) { foreach ($aTmp as $key => $aGroup) { /** * aGroup 数据结构 $aGroup = array( 'type'=>xxx 'key'=>xxx 'pieFieldSelected'=>true|false 是否为在饼图中被选中的指标 'pieFieldAble'=>true|false 是否出现在饼图的选择项中 'sortAble'=>true|false 'orderbyClass'=>''|orderby_asc|orderby 'thclass'=>array() 'tipclass'=>array() ) */ $key = $aGroup['key']; $label = \YcheukfReport\Lib\ALYS\ALYSLang::_($aGroup['key']); if ($k == 'metric') { $csvTitle .= \YcheukfReport\Lib\ALYS\ALYSLang::_($aGroup['label']) . ' - ' . $label . "{$separator}"; } else { $csvTitle .= $label . "{$separator}"; } } } } $csvTitle .= "\r\n"; $start = isset($this->aInput['input']['detail']['page']['startItem']) ? $this->aInput['input']['detail']['page']['startItem'] : 0; $aryListData = $this->aOutput['detail']; $aryListData = $oCSVPlugin->ALYSfmtListData($aryListData); $this->aOutput['detail.num'] = count($aryListData); if (is_array($aryListData)) { foreach ($aryListData as $i => $data) { if ($i == 0 && $start == 0) { $csvBody .= $csvTitle; } if (isset($data) && is_array($data)) { foreach ($data as $key => $aTmp) { foreach ($aTmp as $ii => $item) { $colspan = isset($item['colspan']) ? $item['colspan'] : 1; if ($colspan == 0) { continue; } //被前面的td跨列 $label = isset($item['tdKey']) && $item['tdKey'] == 'tdNO' ? $i + 1 + $start : (isset($item['label']) ? $item['label'] : ''); //$label = strip_tags(preg_replace('/'.$separator.'/', " ", $label)); //$label = strip_tags(str_replace($separator, " ", $label)); $label = strip_tags(str_replace("\r\n", " ", $label)); $label = strip_tags(str_replace("\n", " ", $label)); $sStyle = empty($style) ? "" : "style='{$style}'"; $sAlign = empty($align) ? "" : "align='{$align}'"; $sColspan = $colspan == 1 ? "" : "colspan='{$colspan}'"; $csvBody .= "\"{$label}\"" . str_repeat($separator, $colspan); } } } $csvBody .= "\r\n"; } } // var_export($csvBody); //无数据 标题加上 // if(empty($csvBody))$csvBody = $csvTitle; if (empty($aryListData)) { $csvBody .= $csvTitle; } //waiting $this->aOutput['detail.output'] = $csvBody; \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput); }
/** * 处理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; }
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; }
private function _getFlsTotal() { $aInput = $this->_aInput; if (empty($aInput['input']['total']) && empty($aInput['input']['flash'])) { return false; } $aInput['input']['detail'] = array(); \YcheukfReport\Lib\ALYS\ALYSFunction::clear(); $oReport = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass('report.start', $aInput); $oRe = $oReport->go(); return $oRe['output']; }
/** * 返回参数 */ public function go_end() { $afusion = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("Flash"); $html = array(); // echo $this->xmlData; $html = $afusion->ALYSfmtOutputFusionScript($this->xmlData, $this->flashType, $this->height); $this->aOutput['flash.output'] = $html[0]; $this->aOutput['flash.seriestips'] = $afusion->ALYSfmtSeriesTips($this->aInput['input']['flash']['seriestips']); $this->aOutput['flash.divid'] = $html[1]; $this->aOutput['flash.src'] = $html[2]; $this->aOutput['flash.xmlData'] = $this->xmlData; \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput); // $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get(); // $html = ''; // $src = $_ALYSconfig['fusion']['src'][$this->flashType]; // $ChartNoDataText = \YcheukfReport\Lib\ALYS\ALYSLang::_("ALYSFLASH_ChartNoDataText"); // $PBarLoadingText = \YcheukfReport\Lib\ALYS\ALYSLang::_("ALYSFLASH_PBarLoadingText"); // $XMLLoadingText = \YcheukfReport\Lib\ALYS\ALYSLang::_("ALYSFLASH_XMLLoadingText"); // $ParsingDataText = \YcheukfReport\Lib\ALYS\ALYSLang::_("ALYSFLASH_ParsingDataText"); // $RenderingChartText = \YcheukfReport\Lib\ALYS\ALYSLang::_("ALYSFLASH_RenderingChartText"); // $LoadDataErrorText = \YcheukfReport\Lib\ALYS\ALYSLang::_("ALYSFLASH_LoadDataErrorText"); // $InvalidXMLText = \YcheukfReport\Lib\ALYS\ALYSLang::_("ALYSFLASH_InvalidXMLText"); // $divId = 'ALYSfc_'.uniqid(); // $w = '100%'; // $h = $this->height; // $html = <<<OUTPUT // <div id='{$divId}_div' class='ALYSflash_trend_div'></div> // <script language='JavaScript'> // (function(){ // var oChart = new FusionCharts("{$src}?ChartNoDataText={$ChartNoDataText}&PBarLoadingText={$PBarLoadingText}&XMLLoadingText={$XMLLoadingText}&ParsingDataText={$ParsingDataText}&RenderingChartText={$RenderingChartText}&LoadDataErrorText={$LoadDataErrorText}&InvalidXMLText={$InvalidXMLText}", // '{$divId}', '{$w}', '{$h}', '0', '1', '','noScale'); // oChart.setTransparent(1); // oChart.setDataXML("{$this->xmlData}"); // oChart.render('{$divId}_div'); // })(); // </script> //OUTPUT; // $this->aOutput['flash.output'] = $html; //// $this->aOutput['flash.output'] = $this->xmlData; //// \YcheukfReport\Lib\ALYS\ALYSFunction::debug($aOutput,'a', 'aOutputaOutput'); }
/** * 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); }
/** * 重写 * 获得数据入口 */ 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; }
public static function _getClassPath($className) { $a = explode(".", $className); foreach ($a as $k => $s) { $bFlag = preg_match("/alys/i", $s) ? true : false; if ($bFlag) { $s = str_replace("alys", '', strtolower($s)); $s = "ALYS" . \YcheukfReport\Lib\ALYS\ALYSFunction::ucfirst($s); } else { $a[$k] = \YcheukfReport\Lib\ALYS\ALYSFunction::ucfirst($s); } } return $a; }
function go() { $o = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("report.output.Total.format.html"); $o->go(); }
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]; }
/** * ��������� */ 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); }