예제 #1
0
 public function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $sHtml = "";
     $oPluginStatic = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("Statichtml");
     if (isset($aOutput['flash.output'])) {
         $sHtml .= $oPluginStatic->ALYSfmtOutputFlash($aOutput['flash.output']);
     }
     if (isset($aOutput['total.output'])) {
         $aOutput['total.output'] = parent::_forma_html_total($aOutput['total.output']);
         $sHtml .= $oPluginStatic->ALYSfmtOutputTotal($aOutput['total.output']);
     }
     if (isset($aOutput['detail.output'])) {
         $aOutput['detail.output'] = parent::_format_html_list($aOutput['detail.output']);
         $sHtml .= $oPluginStatic->ALYSfmtOutputList($aOutput['detail.output']);
     }
     $sHtml = self::_fmtHtml($sHtml);
     $cache = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("ALYSCache");
     $cache->setHandle('report_static_html');
     $keyName = uniqid();
     $cache->save($keyName, $sHtml);
     $aOutput['output'] = $keyName;
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
     return $keyName;
 }
예제 #2
0
파일: Xml.php 프로젝트: ycheukf/report
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
     $trendType = $aInput['input']['flash']['type'] = isset($aInput['input']['flash']['type']) ? $aInput['input']['flash']['type'] : "trend";
     $xmlDataEntity = "";
     if ('bubble' == $trendType) {
         $xmlDataEntity .= "\n\r<bubble>";
         foreach ($aOutput['flash'] as $i => $aTmp) {
             $xmlDataEntity .= "\n\r<entity>\n";
             $xmlDataEntity .= "<column>" . $i . "</column>\n";
             foreach ($aTmp as $date => $aTmp2) {
                 $xmlDataEntity .= "<column>" . $aTmp2 . "</column>";
             }
             $xmlDataEntity .= "\n</entity>";
         }
         $xmlDataEntity .= "\n\r</bubble>";
     } else {
         foreach ($aOutput['flash'] as $i => $aTmp) {
             $xmlDataEntity .= "\n\r<trend>";
             foreach ($aTmp as $date => $aTmp2) {
                 $xmlDataEntity .= "\n\r<entity>\n";
                 $xmlDataEntity .= "<column>" . $date . "</column>\n";
                 $xmlDataEntity .= "<column>" . current(array_values($aTmp2)) . "</column>";
                 $xmlDataEntity .= "\n</entity>";
             }
             $xmlDataEntity .= "\n\r</trend>";
         }
     }
     $aOutput['flash.output'] = "<flash>\n\n" . $xmlDataEntity . "</flash>\n\n";
     \YcheukfReport\Lib\ALYS\Report\Start::setInput($aInput);
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
예제 #3
0
파일: Csv.php 프로젝트: ycheukf/report
 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);
 }
예제 #4
0
파일: Json.php 프로젝트: ycheukf/report
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aryListData = $aOutput['detail'];
     $xmlDataEntity = "";
     for ($i = 0; $i < count($aryListData); $i++) {
         if (isset($aryListData[$i]) && is_array($aryListData[$i])) {
             foreach ($aryListData[$i] as $key => $aTmp) {
                 foreach ($aTmp as $ii => $item) {
                     $colspan = isset($item['colspan']) ? $item['colspan'] : 1;
                     if ($colspan == 0) {
                         continue;
                     }
                     //被前面的td跨列
                     $label = isset($item['label']) ? $item['label'] : '';
                     //$label = strip_tags(preg_replace('/'.$separator.'/', " ", $label));
                     $label = strip_tags(str_replace("\t", " ", $label));
                     $label = strip_tags(str_replace("\r\n", " ", $label));
                     $label = strip_tags(str_replace("\n", " ", $label));
                     $xmlDataEntity .= "\n\t\t<column>" . $label . "<column>";
                 }
             }
         }
         $xmlDataEntity .= "\n\t</entity>\n\t<entity>";
     }
     $xmlDataEntity = substr($xmlDataEntity, 0, strrpos($xmlDataEntity, "<entity"));
     $aRe = array("title" => 'xx', "data" => empty($xmlDataEntity) ? "<entitys></entitys>" : "<entitys>\n\t<entity>" . $xmlDataEntity . "\n</entitys>", 'pagination' => array('listCount' => $listCount, 'items_per_page' => $aParm['items_per_page'], 'current_page' => $aParm['current_page']));
     //		var_export($aRe);
     $aOutput['detail.output'] = $aOutput['detail'];
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
예제 #5
0
파일: Pdf.php 프로젝트: ycheukf/report
 function go()
 {
     $headertop = "";
     //设置头标题上部份
     $headerfoot = "";
     //设置头标题下部份
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
     $aOutput['total.output'] = self::_forma_pdf_total($aOutput['total.output']);
     $aOutput['detail.output'] = self::_format_pdf_list($aOutput['detail.output']);
     if (isset($aInput["custom"]["image"]) && !empty($aInput["custom"]["image"])) {
         $image = $aInput["custom"]["image"];
         $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
         \YcheukfReport\Lib\ALYS\ALYSFunction::removeLifeFile($_ALYSconfig['pdf']['path'], $_ALYSconfig['pdf']['lifetime'], $_ALYSconfig['pdf']['remove']);
         if (isset($aInput["custom"]["headertop"]) || isset($aInput["custom"]["headerfoot"])) {
             $headertop = $aInput["custom"]["headertop"];
             $headerfoot = $aInput["custom"]["headerfoot"];
             $pagefooter = @$aInput["custom"]["pagefooter"];
         } else {
             $aHeader = \YcheukfReport\Lib\ALYS\ALYSFunction::loadPlugin("Css");
             $aHeader = $aHeader->ALYSfmtOuputPdfTitle();
             $headertop = $aHeader["titletop"];
             $headerfoot = $aHeader["titlefoot"];
             $pagefooter = @$aHeader["pagefooter"];
         }
         $aOutput['output'] = self::_createPdf($image, $aOutput['total.output'], $aOutput['detail.output'], "f", $headertop, $headerfoot, $pagefooter);
         \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
     }
 }
예제 #6
0
파일: Html.php 프로젝트: ycheukf/report
 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);
 }
예제 #7
0
파일: Csv.php 프로젝트: ycheukf/report
 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);
 }
예제 #8
0
파일: Xml.php 프로젝트: ycheukf/report
 function go()
 {
     $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
     $sXmlTh = "";
     foreach ($aInput['groups'] 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']);
             $sXmlTh .= "\n\t\t<th>" . $label . "</th>";
         }
     }
     $sXmlTh = "\t<thead>\n" . $sXmlTh . "\n\t</thead>\n";
     $aryListData = $this->aOutput['detail'];
     $xmlDataEntity = "";
     for ($i = 0; $i < count($aryListData); $i++) {
         if (isset($aryListData[$i]) && is_array($aryListData[$i])) {
             $xmlDataEntity .= "\n\t\t<entity>";
             foreach ($aryListData[$i] as $key => $aTmp) {
                 foreach ($aTmp as $ii => $item) {
                     if ($ii == 0 && $key == 'dimens') {
                         continue;
                     }
                     $label = isset($item['label']) ? $item['label'] : '';
                     //$label = strip_tags(preg_replace('/'.$separator.'/', " ", $label));
                     $label = strip_tags(str_replace("\t", " ", $label));
                     $label = strip_tags(str_replace("\r\n", " ", $label));
                     $label = strip_tags(str_replace("\n", " ", $label));
                     $xmlDataEntity .= "\n\t\t\t<column>" . $label . "</column>";
                 }
             }
             $xmlDataEntity .= "\n\t\t</entity>";
         }
     }
     $xmlDataEntity = "\t<data>\n" . $xmlDataEntity . "\n\t</data>\n";
     $xmlPage = "";
     if (isset($aInput['input']['detail']['page'])) {
         foreach ($aInput['input']['detail']['page'] as $key => $v) {
             $xmlPage .= "\n\t\t<{$key}>" . $v . "</{$key}>";
         }
     }
     $xmlPage = "\t<pagenation>\n" . $xmlPage . "\n\t</pagenation>\n";
     //		var_export($aRe);
     $this->aOutput['detail.output'] = "<list>\n" . $sXmlTh . $xmlDataEntity . $xmlPage . "\n</list>\n";
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
 }
예제 #9
0
파일: Multdate.php 프로젝트: ycheukf/report
 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();
 }
예제 #10
0
파일: Html.php 프로젝트: ycheukf/report
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aOutput['total.output'] = isset($aOutput['total.output']) ? parent::_forma_html_total($aOutput['total.output']) : "";
     $aOutput['detail.output'] = isset($aOutput['detail.output']) ? parent::_format_html_list($aOutput['detail.output']) : "";
     $sHTML = "";
     $sHTML .= isset($aOutput['flash.output']) ? $aOutput['flash.output'] : "";
     $sHTML .= "\r\n\r\n";
     $sHTML .= isset($aOutput['total.output']) ? $aOutput['total.output'] : "";
     $sHTML .= "\r\n\r\n";
     $sHTML .= isset($aOutput['detail.output']) ? $aOutput['detail.output'] : "";
     $sHTML .= "\r\n\r\n";
     $aOutput['output'] = $sHTML;
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
예제 #11
0
파일: Json.php 프로젝트: ycheukf/report
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aJson = array();
     if (isset($aOutput['flash.output'])) {
         $aJson['flash'] = $aOutput['flash.output'];
     }
     if (isset($aOutput['total.output'])) {
         $aJson['total'] = $aOutput['total.output'];
     }
     if (isset($aOutput['detail.output'])) {
         $aJson['detail'] = $aOutput['detail.output'];
     }
     $aOutput['output'] = json_encode($aJson);
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
예제 #12
0
파일: Bubble.php 프로젝트: ycheukf/report
 /**
  * 	格式化成concatKey作为key
  */
 public function _formatAssoc($type)
 {
     $aMainTable = $this->aInput['input'][$type]['mainTable'];
     //echo "aMainTable=";print_r($aMainTable);
     $aDatas = array();
     $countField = count($aMainTable['showField']);
     $aOData = empty($this->aOutput[$type][0]) ? array() : $this->aOutput[$type][0];
     if (is_array($aOData)) {
         foreach ($aOData as $i => $aData) {
             $concatKey = $aData['concatKey'];
             unset($aData['concatKey']);
             $aDatas[$concatKey] = $aData;
         }
     }
     $this->aOutput[$type] = $aDatas;
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
 }
예제 #13
0
파일: Total.php 프로젝트: ycheukf/report
 /**
  * 	格式化成concatKey作为key
  */
 public function _formatAssoc($type)
 {
     $aMainTable = $this->aInput['input'][$type]['mainTable'];
     //echo "aMainTable['showField']=";print_r($aMainTable['showField']);
     $aDataN = array();
     //echo "this->aOutput[$type]=";print_r($this->aOutput[$type]);
     foreach ($this->aOutput[$type] as $date_i => $aDatas) {
         foreach ($aDatas as $i => $aData) {
             foreach ($aMainTable['showField'] as $j => $showField) {
                 $aDataN[$date_i][$i][$showField] = $aData[$showField];
             }
         }
     }
     $this->aOutput[$type] = $aDataN;
     //echo "this->aOutput[$type]=";print_r($this->aOutput[$type]);
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
 }
예제 #14
0
파일: Json.php 프로젝트: ycheukf/report
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
     $aJson = array();
     $aReturn = "";
     foreach ($aOutput['flash'] as $i => $aTmp) {
         foreach ($aTmp as $x => $aTmp2) {
             foreach ($aTmp2 as $metric => $v) {
                 $aReturn[$i][$x]['x'] = $x;
                 $aReturn[$i][$x]['y'] = \YcheukfReport\Lib\ALYS\ALYSLang::_("metric_" . $metric);
                 $aReturn[$i][$x]['v'] = $v;
             }
         }
     }
     $aOutput['flash.output'] = $aReturn;
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
예제 #15
0
파일: Json.php 프로젝트: ycheukf/report
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     //		\YcheukfReport\Lib\ALYS\ALYSFunction::debug($aOutput,'a', 'aOutputaOutput');
     $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
     $trendType = $aInput['input']['flash']['type'] = isset($aInput['input']['flash']['type']) ? $aInput['input']['flash']['type'] : "trend";
     $aTmp2 = array();
     foreach ($aOutput['total'] as $i => $aTmp) {
         $ii = 0;
         foreach ($aTmp as $metric => $v) {
             $aTmp2[$i][$ii]['label'] = \YcheukfReport\Lib\ALYS\ALYSLang::_("metric_" . $metric);
             $aTmp2[$i][$ii]['value'] = $v;
             $ii++;
         }
     }
     $aOutput['total.output'] = $aTmp2;
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
예제 #16
0
파일: Xml.php 프로젝트: ycheukf/report
 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);
 }
예제 #17
0
파일: Tablebar.php 프로젝트: ycheukf/report
 /**
  * 为柱状条格式化TD 属性
  */
 public function _percent($type)
 {
     $sSelectedMetric = $this->aInput['input']['detail']['selected'];
     $sTotalMetric = $this->aInput['input']['detail']['totalselected'];
     //total的字段名 用于计算百分比
     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);
         //去掉最后的“不加”标识
     }
     /*
     $temps = array();
     foreach($this->aOutput[$type] as $k => $v){
     	foreach($v as $kk => $vv){
     		$temps[] = $vv[$sSelectedMetric];
     	}
     }
     $sum = array_sum($temps);
     */
     //计算总和
     //取得total总和
     $sum = $this->aInput['internal']['total']['datas'][0][0][$sTotalSelectedMetric];
     //组织伪指标中的内容
     $aOrgData = $this->aInput['internal'][$type]['datas'];
     //原始数据 用于计算
     foreach ($this->aOutput[$type] as $k => $v) {
         foreach ($v as $kk => $vv) {
             $percent = ($sum > 0 ? round($aOrgData[$k][$kk][$sSelectedMetric] / $sum * 100, 2) : 0) . "%";
             $this->aOutput[$type][$k][$kk][$this->sThLabel] = "<div class='tbbar'><div  style='width:{$percent}'><span >{$percent}</span></div></div>";
         }
     }
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
     //为th增加一列伪指标:百分比
     array_push($this->aMetric, $this->sThLabel);
     //		var_export($this->aMetric);
 }
예제 #18
0
파일: Output.php 프로젝트: ycheukf/report
 /**
  * 格式小数位数等
  */
 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);
 }
예제 #19
0
파일: Html.php 프로젝트: ycheukf/report
 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);
 }
예제 #20
0
파일: Detail.php 프로젝트: ycheukf/report
 /**
  * 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);
 }
예제 #21
0
파일: Csv.php 프로젝트: ycheukf/report
 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);
 }
예제 #22
0
파일: Array.php 프로젝트: ycheukf/report
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aOutput['total.output'] = isset($aOutput['total']) ? $aOutput['total'] : null;
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
예제 #23
0
파일: Csv.php 프로젝트: ycheukf/report
 function go()
 {
     $aOutput = \YcheukfReport\Lib\ALYS\Report\Start::getOutput();
     $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
     $trendType = $aInput['input']['flash']['type'] = isset($aInput['input']['flash']['type']) ? $aInput['input']['flash']['type'] : "trend";
     $separator = isset($this->aInput['output']['csvSeparator']) ? $this->aInput['output']['csvSeparator'] : "\t";
     $sCsv = $sCsvTitle = "";
     $nIndex = 0;
     //维度标题的标签转换
     $aInputFlash = $aInput['input']['flash'];
     $aDimen = @array_keys($aInputFlash['tables'][$aInputFlash['mainTable']['table']]['dimen']['dimenkey2field']);
     $sDimen = @current($aDimen);
     switch (strtolower($trendType)) {
         default:
         case "trend":
             $aId2Label = $this->_getId2Label($sDimen, $aOutput['flash'][0]);
             if (is_array($aOutput['flash'][0])) {
                 foreach ($aOutput['flash'][0] as $date => $aTmp) {
                     if ($nIndex == 0) {
                         $sCsvTitle .= '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_($sDimen) . '"' . $separator . '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_(current(array_keys($aTmp))) . "\"\r\n";
                         $nIndex = 1;
                     }
                     $sCsv .= '"' . (empty($aId2Label[$date]) ? $date : $aId2Label[$date]) . '"' . $separator . '"' . current(array_values($aTmp)) . "\"\r\n";
                 }
             }
             break;
         case "geography":
             $aId2Label = $this->_getId2Label($sDimen, $aOutput['flash'][0]);
             if (is_array($aOutput['flash'][0])) {
                 foreach ($aOutput['flash'][0] as $date => $aTmp) {
                     $sCsvTitle .= '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_($sDimen) . '"' . $separator . '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_($date) . "\"\r\n";
                     if (is_array($aTmp)) {
                         foreach ($aTmp as $k => $v) {
                             $sCsv .= '"' . (empty($aId2Label[$k]) ? $k : $aId2Label[$k]) . '"' . $separator . '"' . $v . "\"\r\n";
                         }
                     }
                 }
             }
             break;
         case "bubble":
             $aId2Label = $this->_getId2Label($sDimen, $aOutput['flash']);
             $oDict = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Metric');
             if (is_array($aOutput['flash']) && !empty($aOutput['flash'])) {
                 $aInputFlash = $aInput['input']['flash'];
                 $aDimen = array_keys($aInputFlash['tables'][$aInputFlash['mainTable']['table']]['dimen']['dimenkey2field']);
                 $sDimen = $aDimen[0];
                 $sCsvTitle .= \YcheukfReport\Lib\ALYS\ALYSLang::_($sDimen);
                 if (is_array($aInput['input']['flash']['mainTable']['showField'])) {
                     foreach ($aInput['input']['flash']['mainTable']['showField'] as $v) {
                         $sCsvTitle .= $separator . '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_($v) . '"';
                     }
                 }
                 $sCsvTitle .= "\r\n";
                 if (is_array($aOutput['flash'])) {
                     foreach ($aOutput['flash'] as $key => $values) {
                         $tmp = array();
                         if (is_array($aInput['input']['flash']['mainTable']['showField'])) {
                             foreach ($aInput['input']['flash']['mainTable']['showField'] as $v) {
                                 if (isset($values[$v])) {
                                     $tmp[] = $oDict->ALYSmetricFormat($v, $values[$v]);
                                 } else {
                                     $tmp[] = '';
                                 }
                             }
                         }
                         $sCsv .= '"' . (empty($aId2Label[$key]) ? $key : $aId2Label[$key]) . '"' . $separator . '"' . implode('"' . $separator . '"', $tmp) . "\"\r\n";
                     }
                 }
             }
             break;
         case "multdate":
             $sCsvTitle .= '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_("ALYSDATE");
             if (is_array($aOutput['flash'])) {
                 foreach ($aOutput['flash'] as $i => $aTmp) {
                     $sDate = $aInput['date'][$i]['s'];
                     $eDate = $aInput['date'][$i]['e'];
                     $sTmp = $sDate . "~" . $eDate;
                     foreach ($aTmp as $date => $aTmp) {
                         if ($nIndex == 0) {
                             $sCsvTitle .= '"' . $separator . '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_($sDimen) . $separator . '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_(current(array_keys($aTmp))) . "\"\r\n";
                             $nIndex = 1;
                         }
                         $sCsv .= '"' . $date . '"' . $separator . '"' . $sTmp . '"' . $separator . '"' . current(array_values($aTmp)) . "\"\r\n";
                     }
                 }
             }
             break;
         case "multmetric":
             $aId2Label = $this->_getId2Label($sDimen, $aOutput['flash'][0]);
             $sCsvTitle .= '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_($sDimen) . '"';
             if (is_array($aOutput['flash'])) {
                 foreach ($aOutput['flash'] as $i => $aTmp) {
                     foreach ($aTmp as $date => $aTmp2) {
                         foreach ($aTmp2 as $guiline => $v) {
                             $sCsvTitle .= $separator . '"' . \YcheukfReport\Lib\ALYS\ALYSLang::_($guiline) . '"';
                             break;
                         }
                         break;
                     }
                 }
             }
             $sCsvTitle .= "\r\n";
             if (is_array($aOutput['flash'][0])) {
                 foreach ($aOutput['flash'][0] as $date => $aTmp) {
                     $sCsv .= '"' . (empty($aId2Label[$date]) ? $date : $aId2Label[$date]) . '"';
                     for ($i = 0; $i < count($aOutput['flash']); $i++) {
                         $sCsv .= $separator . '"' . current(array_values($aOutput['flash'][$i][$date])) . '"';
                     }
                     $sCsv .= "\r\n";
                 }
             }
             break;
     }
     $aOutput['flash.output'] = $sCsvTitle . $sCsv;
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($aOutput);
 }
예제 #24
0
 private function _fmtListData()
 {
     $iDefaultMetricValue = 0;
     //无值时的默认值
     $aInput = $this->aInput['input'][$this->_type];
     $mainTable = $aInput['mainTable']['table'];
     //维度key
     $xDimen = @$aInput['table'][$mainTable]['xdimen_key'][0];
     $yDimens = $aInput['table'][$mainTable]['ydimen_key'];
     //dimen与xdimen是否有重复
     $boolIsDimenHasXDimen = in_array($xDimen, $yDimens) ? true : false;
     //维度 数据
     $aXField = $this->_getXField();
     $aYField = $this->aInput['input'][$this->_type]['dimenpage']['yfield'];
     $aXFieldLabelRet = $this->_chgId2LabelForXField($xDimen, $aXField);
     $aXFieldLabel = $aXFieldLabelRet[$xDimen];
     $aMetricInGroup = $this->_getMetricInGroup();
     $data = $this->aOutput[$this->_type][0];
     //单时段 所以用0
     $return_data = array();
     $arrDimenData = array();
     $aMetric = array();
     $aNewMetricInGroup = array();
     //var_dump($data);//exit;
     if (is_array($aYField)) {
         foreach ($aYField as $yF) {
             $sKey = $this->_splitAppend($yF);
             $return_data[$sKey] = $yF;
             if (is_array($aXField)) {
                 foreach ($aXField as $xF) {
                     $sKeySplit = $boolIsDimenHasXDimen ? $sKey : $this->_splitAppend($yF + array($xF));
                     if (is_array($this->aMetric)) {
                         foreach ($this->aMetric as $mk) {
                             $sMKey = $this->_splitAppend(array($xF, $mk));
                             if (!isset($aMetric[$sMKey])) {
                                 $aMetric[$sMKey] = $sMKey;
                             }
                             if (!isset($aNewMetricInGroup[$sMKey])) {
                                 $aNewMetricInGroup[$sMKey] = $aMetricInGroup[$mk];
                                 $aNewMetricInGroup[$sMKey]['label'] = isset($aXFieldLabel[$xF]) ? $aXFieldLabel[$xF] : '';
                             }
                             if (isset($data[$sKeySplit]) && ($boolIsDimenHasXDimen && $data[$sKeySplit][$xDimen] == $xF || !$boolIsDimenHasXDimen)) {
                                 $return_data[$sKey][$sMKey] = $data[$sKeySplit][$mk];
                             } else {
                                 $return_data[$sKey][$sMKey] = $iDefaultMetricValue;
                             }
                         }
                     }
                 }
             }
         }
     }
     //var_dump($return_data);//exit;
     //重组metric
     if (!empty($aMetric)) {
         $this->aMetric = $aMetric;
     }
     $this->_setMetricInGroup($aNewMetricInGroup);
     //数据赋值
     $this->aOutput['detail'] = array($return_data);
     //分页用的数据
     $iYtotal = $aInput['page']['total'];
     $iXtotal = $aInput['dimenpage']['total'];
     //每页条数
     $iYperpage = $aInput['page']['items_per_page'];
     $iXperpage = $aInput['dimenpage']['items_per_page'];
     $this->aOutput['detail.page'] = array('total' => $iYtotal, 'items_per_page' => $iYperpage);
     $this->aOutput['detail.dimenpage'] = array('total' => $iXtotal, 'items_per_page' => $iXperpage);
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
 }
예제 #25
0
파일: Fusion.php 프로젝트: ycheukf/report
 /**
  * 返回参数
  */
 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');
 }
예제 #26
0
파일: Flash.php 프로젝트: ycheukf/report
 /**
  * 补全数据, 为趋势图数据补零
  */
 public function _fillTrendZero($type)
 {
     $mainTable = $this->aInput['input'][$type]['mainTable']['table'];
     $aDimens = $this->aInput['input'][$type]['tables'][$mainTable]['dimen'];
     //维度
     $nTotalMetric = count($this->aMetric);
     //\YcheukfReport\Lib\ALYS\ALYSFunction::debug($aDimens,'a', __CLASS__.'/'.__FUNCTION__.'/'.__LINE__);
     if (count($aDimens['key']) > 1) {
         throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSFLASH_CONFIG_WRONG', 'can not set more than one group dimen at flash. ' . __FILE__ . '/' . __LINE__);
     }
     $timeslotType = $this->getDimenTimeType($type, $aDimens['key'][0]);
     $sSelected = $aDimens['dimenkey2selected'][$aDimens['key'][0]];
     $aTrendConfig = array();
     $iTrend = 0;
     switch ($this->aInput['input'][$type]['type']) {
         case 'multDate':
             foreach ($this->aInput['date'] as $i => $aDate) {
                 //循环多时段
                 $aTrendConfig[$iTrend]['date'] = $aDate;
                 $aTrendConfig[$iTrend]['metric'] = $this->aMetric[0];
                 $iTrend++;
             }
             break;
         case 'multMetric':
             foreach ($this->aMetric as $i => $metric) {
                 //循环多指标
                 $aTrendConfig[$iTrend]['date'] = $this->aInput['date'][0];
                 $aTrendConfig[$iTrend]['metric'] = $metric;
                 $iTrend++;
             }
             break;
         case 'trend':
             $aTrendConfig[$iTrend]['metric'] = $this->aMetric[0];
             $aTrendConfig[$iTrend]['date'] = $this->aInput['date'][0];
             $iTrend++;
             break;
         case 'sort':
             switch ($this->aInput['input']['detail']['type']) {
                 case 'perspective':
                     foreach ($this->aInput['input'][$type]['sort_indexs'] as $nSort) {
                         $aTrendConfig[$iTrend]['metric'] = $this->aMetric[0];
                         $aTrendConfig[$iTrend]['date'] = $this->aInput['date'][0];
                         $aTrendConfig[$iTrend]['xdimen'] = $this->aInput['internal']['xdimen'];
                         $iTrend++;
                     }
                     break;
                 default:
                 case 'sort':
                     foreach ($this->aInput['input'][$type]['sort_indexs'] as $nSort) {
                         $aTrendConfig[$iTrend]['metric'] = $this->aMetric[0];
                         $aTrendConfig[$iTrend]['date'] = $this->aInput['date'][0];
                         $iTrend++;
                     }
                     break;
             }
             break;
         case 'geography':
         default:
             return false;
             break;
     }
     //
     //var_dump($aTrendConfig);
     foreach ($aTrendConfig as $i => $aConfig) {
         $aFlashDataNew = $aFlashDataTmp = array();
         $aFlashDataNew = isset($this->aOutput[$type][$i]) ? $this->aOutput[$type][$i] : array();
         $metric = $aConfig['metric'];
         $nextDay = $aConfig['date']['s'];
         $eDate = $aConfig['date']['e'];
         if ($timeslotType == 1) {
             //日期补全
             while ($eDate >= $nextDay) {
                 $sNextSlot = $timeSolt = $this->_getTimeSlot($nextDay, $sSelected);
                 // if($sSelected == 'week'){
                 // $sNextSlot = $timeSolt.$this->splitChar.$aMultTrendConfig['sDate'].$this->splitChar.$aMultTrendConfig['eDate'];
                 // }
                 if (isset($aFlashDataNew[$sNextSlot])) {
                     $aFlashDataTmp[$sNextSlot] = $aFlashDataNew[$sNextSlot];
                 } else {
                     //若该天没有数据则补零
                     $aFlashDataTmp[$sNextSlot][$metric] = 0;
                     $aFlashDataTmp[$sNextSlot][$sSelected] = $sNextSlot;
                 }
                 $nextDay = date("Y-m-d", strtotime("+1 day", strtotime($nextDay)));
             }
         } elseif ($timeslotType == 2) {
             //小时
             for ($ii = 0; $ii < 24; $ii++) {
                 $hour = $ii . ":00";
                 if (isset($aFlashDataNew[$hour][$metric])) {
                     $aFlashDataTmp[$hour] = $aFlashDataNew[$hour];
                 } else {
                     $aFlashDataTmp[$hour][$metric] = 0;
                     $aFlashDataTmp[$hour][$sSelected] = $hour;
                 }
             }
         } else {
             if (isset($aConfig['xdimen'])) {
                 //透视图补全
                 foreach ($aConfig['xdimen'] as $sDimenTmp) {
                     $aFlashDataTmp[$sDimenTmp][$metric] = isset($aFlashDataNew[$sDimenTmp][$metric]) ? $aFlashDataNew[$sDimenTmp][$metric] : 0;
                 }
             } else {
                 $aFlashDataTmp = isset($this->aOutput[$type][$i]) ? $this->aOutput[$type][$i] : array();
             }
         }
         $this->aOutput[$type][$i] = $aFlashDataTmp;
     }
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
     //		\YcheukfReport\Lib\ALYS\ALYSFunction::debug($this->aOutput,'a', __CLASS__.'/'.__FUNCTION__.'/'.__LINE__);
 }
예제 #27
0
파일: Tablepie.php 프로젝트: ycheukf/report
 /**
  * 为柱状条格式化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);
 }
예제 #28
0
파일: Table.php 프로젝트: ycheukf/report
 /**
  * 格式化成维度与指标分开
  */
 public function _fmtDimen_Metric($type)
 {
     $this->aOutput[$type] = $this->_fmtTdStyle($type);
     \YcheukfReport\Lib\ALYS\Report\Start::setOutput($this->aOutput);
 }