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 _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() { $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 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; }
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); }
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; } }
/** * 处理特殊字符串 */ public static function _htmlspecialchars($str) { $afusion = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("Flash"); return $afusion->ALYShtmlspecialchars($str); }
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); }
/** * 返回参数 */ 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'); }
/** * 为表格的TD组织数组 */ public function _fmtTdStyle($type) { $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin('detail'); $aBgColor = $oPlugin->ALYSgetListBgColor(); $bNOColorFlag = 1; //用来控制列表中是否出现色块的bool switch ($this->aInput['input']['detail']['type']) { case 'table_pie': $bNOColorFlag = 1; break; default: $bNOColorFlag = 0; break; } $aOrgData = array(); $TablePieThSpanFlag = 0; $aPureData = $this->aInput['internal']['listData']; //纯数据 未格式化的 $aOrgData = $this->aOutput[$type]; //通过format的数据 //适应多时段情况 $iDataCnt = 0; //表示最多数据条数 后边作循环用 $iMultNum = count($aOrgData); //表示一共显示多少个时段 foreach ($aOrgData as $k => $v) { $iVcnt = count($v); $iDataCnt = $iVcnt > $iDataCnt ? $iVcnt : $iDataCnt; if (is_array($v)) { foreach ($v as $k1 => $v1) { $v[$k1]['concatKey'] = $k1; } } $aOrgData[$k] = array_values($v); //索引数字化 $aPureData[$k] = array_values($aPureData[$k]); } $aDatas = array(); for ($i = 0; $i < $iDataCnt; $i++) { $index_i_t = $i + 1; if (isset($aBgColor[$i])) { $BgColor = $aBgColor[$i]; } else { $BgColor = $aBgColor[10]; } $sStyleTmp = $bNOColorFlag ? 'style=\'background-color: #' . $BgColor . '\'' : ''; $aDatas[$i]['dimens'][0] = array('label' => "<b _listbodybcss ><b {$sStyleTmp}> </b>" . $index_i_t . "</b>", 'className' => 'fline', 'align' => 'center', 'tdKey' => 'tdNO', 'tdVal' => $index_i_t); $trClass = $aDatas[$i]['dimens'][0]['tdVal'] % 2 ? 1 : 2; if ($trClass == 1) { $aDatas[$i]['dimens'][0]['trClass'] = 'report_table_tr_0'; } else { $aDatas[$i]['dimens'][0]['trClass'] = 'report_table_tr_1'; } foreach ($this->aDimen as $l => $dimen) { $l_t = $l; $l++; $aDatas[$i]['dimens'][$l] = array('className' => 'td150', 'labelLTag' => '', 'labelRTag' => '', 'tdClass' => '', 'tdKey' => $dimen); for ($mn = 0; $mn < $iMultNum; $mn++) { $aConcat = explode($this->splitChar, $aOrgData[$mn][$i]['concatKey']); //var_dump($aConcat);exit; $aDatas[$i]['dimens'][$l]['label' . ($mn ? $mn : '')] = $aOrgData[$mn][$i][$dimen]; $aDatas[$i]['dimens'][$l]['tdVal'] = $aConcat[$l_t]; } } foreach ($this->aMetric as $m => $metric) { //$iPureVal = if ($this->orderby == $metric) { //排序 if ($i % 2 == 0) { $className_t = 'current_odd td150'; } else { $className_t = 'current_even td150'; } $aDatas[$i]['guideLines'][$m] = array('className' => $className_t); for ($mn = 0; $mn < $iMultNum; $mn++) { $aDatas[$i]['guideLines'][$m]['label' . ($mn ? $mn : '')] = @$aOrgData[$mn][$i][$metric]; $aDatas[$i]['guideLines'][$m]['tdVal' . ($mn ? $mn : '')] = @$aPureData[$mn][$i][$metric]; } } else { switch ($metric) { case $this->sThLabel: //饼图,柱状图 switch ($this->aInput['input']['detail']['type']) { case 'table_pie': //饼图 if ($TablePieThSpanFlag == 0) { $aDatas[$i]['guideLines'][$m] = array('rowspan' => $iDataCnt, 'label' => @$aOrgData[0][$i][$metric]); $TablePieThSpanFlag = 1; } else { $aDatas[$i]['guideLines'][$m]['colspan'] = 0; } break; case 'table_list': //柱状图 //柱状图 default: for ($mn = 0; $mn < $iMultNum; $mn++) { $aDatas[$i]['guideLines'][$m]['label' . ($mn ? $mn : '')] = @$aOrgData[$mn][$i][$metric]; $aDatas[$i]['guideLines'][$m]['tdVal' . ($mn ? $mn : '')] = @$aPureData[$mn][$i][$metric]; } break; } break; default: for ($mn = 0; $mn < $iMultNum; $mn++) { $aDatas[$i]['guideLines'][$m]['label' . ($mn ? $mn : '')] = @$aOrgData[$mn][$i][$metric]; $aDatas[$i]['guideLines'][$m]['tdVal' . ($mn ? $mn : '')] = @$aPureData[$mn][$i][$metric]; } break; } } $aDatas[$i]['guideLines'][$m]['metric'] = $metric; } } // var_export($this->aMetric); // var_export($aDatas); return $aDatas; }
/** * 获取所有Metric */ public function getMetrics($type = 'detail') { $aInput = self::getInput(); if (!is_array($aInput['input'][$type]['table'])) { throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_INPUT_NO_' . $type . '_DIMEN', $p); } $aRe = array(); foreach ($aInput['input'][$type]['table'] as $table => $aTmp) { $aRe = array_merge($aRe, $aTmp['metric']); } $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin($type); $aRe = $oPlugin->ALYSfmt_metric($aRe); return $aRe; }
/** * 为柱状条格式化TD 属性 */ public function _percent($type) { //配置 $totalPercent = 100; //饼图总共份额 $iRound = 2; //小数点后保留位数 $iMaxDisplay = 10; //饼图最大显示数据条数 $sSelectedMetric = $this->aInput['input']['detail']['selected']; //当前选择的指标名 $sTotalMetric = $this->aInput['input']['detail']['totalselected']; //total的字段名 用于计算百分比 //颜色 $oPlugin = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin('detail'); $aBgColor = $oPlugin->ALYSgetListBgColor(); //没有设置百分比选项,使用默认 if (!isset($sSelectedMetric)) { $keys = array_keys($this->aInput['groups']['metric']); $sSelectedMetric = $keys[0]; } //total的字段名 if (isset($sTotalMetric) && !empty($sTotalMetric)) { $sTotalSelectedMetric = $sTotalMetric; } else { $sTotalSelectedMetric = preg_replace('/_nosum$/', '', $sSelectedMetric); //去掉最后的“不加”标识 } //显示在饼图上的内容 维度字段名 $dimen = $this->aInput['input']['detail']['pieDisplay']; if (!isset($dimen) or $dimen == null) { $dimen = $this->aDimen[0]; } //var_dump($this->aOutput[$type]);exit; //初始化 $i = 0; //条数计数器 $fCurrentPercentSum = 0; //当前页当前指标百分比累加的总数 $fCurrentSum = 0; //当前页当前指标累加的总数 $iMax = 0; //最大数值 设置isSliced='1' $aData = array(); $aOrgData = $this->aInput['internal'][$type]['datas']; //原始数据 用于计算 //取得total总和 $sum = $this->aInput['internal']['total']['datas'][0][0][$sTotalSelectedMetric]; //计算伪指标的百分比 if (is_array($this->aOutput[$type])) { foreach ($this->aOutput[$type] as $k => $v) { foreach ($v as $kk => $vv) { $tmp = array(); if ($i > $iMaxDisplay - 1) { break; //超出最大条数 跳出 } $tmp['percent'] = $sum > 0 ? round($aOrgData[$k][$kk][$sSelectedMetric] / $sum * 100, $iRound) : 0; $fCurrentPercentSum += $tmp['percent']; $fCurrentSum += $aOrgData[$k][$kk][$sSelectedMetric]; $tmp['dimen'] = \YcheukfReport\Lib\ALYS\ALYSFunction::_htmlspecialchars($vv[$dimen]); $tmp['metric'] = $aOrgData[$k][$kk][$sSelectedMetric]; $tmp['metricDisplay'] = $vv[$sSelectedMetric]; $tmp['color'] = $aBgColor[$i]; $aData[] = $tmp; if ($tmp['metric'] > $iMax) { $iMax = $tmp['metric']; } $i++; } } } //"其它" 的数据 if ($totalPercent - $fCurrentPercentSum > 0) { $tmp['percent'] = round($totalPercent - $fCurrentPercentSum, $iRound); $tmp['dimen'] = ALYSLANG::_('other'); $tmp['metric'] = $sum - $fCurrentSum > 0 ? $sum - $fCurrentSum : 0; $tmp['metricDisplay'] = $tmp['metric']; $tmp['color'] = $aBgColor[$i]; if ($tmp['metric'] > $iMax) { $iMax = $tmp['metric']; } if ($tmp['metric'] > 0) { $aData[] = $tmp; } } //组织xml $pie_datasets = $pie_grid_datasets = ''; if (is_array($aData)) { foreach ($aData as $v) { $isSliced = $v['metric'] >= $iMax ? " isSliced='1'" : ''; $pie_datasets .= "<set value='" . $v['percent'] . "'" . $isSliced . " label='" . $v['dimen'] . "' color='" . $v['color'] . "' displayValue='" . $v['dimen'] . "," . $v['metricDisplay'] . "' tooltext='" . $v['dimen'] . "{br}" . $v['percent'] . "%' />"; $pie_grid_datasets .= "<set value='" . $v['metric'] . "'" . $isSliced . " label='" . $v['dimen'] . "' color='" . $v['color'] . "' displayValue='" . $v['dimen'] . "," . $v['metricDisplay'] . "' tooltext='" . $v['dimen'] . "{br}" . $v['percent'] . "%' />"; } } $iDataCnt = count($aData); //取得样式 $afusion = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("Flash"); $style = $afusion->ALYSoutput_flash_trend_html_style(); $this->aChartStyles = $style[0]['pie3D']; $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get(); foreach ($this->aChartStyles as $k => $v) { $s1 .= " {$k}='{$v}'"; } $xmlDataPie = "<chart {$s1}>" . $pie_datasets . "</chart>"; $xmlDataPieGrid = "<chart {$s1}>" . $pie_grid_datasets . "</chart>"; $height = $afusion->ALYSoutput_flash_pie3D($iDataCnt); //获取饼图高度 $aHtml = array(); $aHtml = $afusion->ALYSfmtOutputFusionScript($xmlDataPie, 'pie3D', $height['pie3D']); $aHtml2 = $afusion->ALYSfmtOutputFusionScript($xmlDataPieGrid, 'SSGrid', $height['SSGrid']); $this->aOutput['detail.pieScript'] = $aHtml[0]; $this->aOutput['detail.pieGridScript'] = $aHtml2[0]; //组织伪指标中的内容 foreach ($this->aOutput[$type] as $k => $v) { $index2 = 0; foreach ($v as $kk => $vv) { $this->aOutput[$type][$k][$kk][$this->sThLabel] = $k == 0 && $index2 == 0 ? $aHtml[0] . $aHtml2[0] : ""; $index2++; } } // var_export($this->aOutput[$type]); //为th增加一列伪指标:百分比 array_push($this->aMetric, $this->sThLabel); \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput); }