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); }
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); }
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); }
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); }
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); }
/** * 格式化series的html提示 @return array 处理过后的数据结构 */ function ALYSfmtSeriesTips($aShowField) { list($aChartStyles, $aTrendStyle) = $this->ALYSoutput_flash_trend_html_style(); $sHtml = "<ol>"; foreach ($aShowField as $i => $row) { $sHtml .= "<li _color='#" . $aTrendStyle[$i]['color'] . "'><b></b>" . \YcheukfReport\Lib\ALYS\ALYSLang::_($row) . "</li>"; } $sHtml .= "<ol>"; return $sHtml; }
/** * 将数据表中获取得的相关ID转换成对应的文字 * @param array aDimenkey2selected 存储需要转换的pName, array('timeslot', 'domainId', ...) * @param array aryIdSet 存储需要转换的pName与id序列, array('timeslot'=>array('2012-10-10', '2012-10-12'), 'domainId'=>array(1, 2, 3), ...) * @param array aConfig 将要输出的html * @return array 处理过后的html * @description 将数据表中获取得的相关ID转换成对应的文字 * */ public function ALYSchgId2Label($aDimenkey2selected = array(), $aryIdSet = array(), $aConfig = array()) { $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get(); define('__DEBUG__', $_ALYSconfig['debug']); $aryReturn = array(); $aryTmp = array(); if (empty($aryIdSet)) { return $aryReturn; } // var_export($aDimenkey2selected); foreach ($aDimenkey2selected as $dimenKey => $sSelected) { if (is_int($dimenKey)) { $dimenKey = $sSelected; } if (empty($aryIdSet[$dimenKey])) { $aryIdSet[$dimenKey] = array(); } if (preg_match('/' . addslashes($this->combinationFieldSplitChar) . '/', $dimenKey)) { $a4Combin = $this->getCombinationFieldAry($dimenKey); $dimenKey = $a4Combin['name']; } switch ($dimenKey) { case 'none': break; case 'dbconfigop': foreach ($aryIdSet[$dimenKey] as $v) { $aryReturn[$dimenKey][$v] = "<a _val='" . $v . "' class='edit' href='javascript::void()'>" . \YcheukfReport\Lib\ALYS\ALYSLang::_('RE_DIMEN_EDIT') . "</a> <a _val='" . $v . "' class='upgrade' href='javascript::void()'>" . \YcheukfReport\Lib\ALYS\ALYSLang::_('RE_DIMEN_UPGRADE') . "</a> <a _val='" . $v . "' class='downgrade' href='javascript::void()'>" . \YcheukfReport\Lib\ALYS\ALYSLang::_('RE_DIMEN_DOWNGRADE') . "</a> <a _val='" . $v . "' class='config' href='javascript::void()'>" . \YcheukfReport\Lib\ALYS\ALYSLang::_('RE_DIMEN_CONFIG') . "</a>"; } break; case 'domainId': $idStr = "'" . implode("', '", array_unique($aryIdSet[$dimenKey])) . "'"; $aryTmp = $this->_getDomainListNameList('`DomainList`.ID in (' . $idStr . ')'); for ($ii = 0; $ii < count($aryTmp); $ii++) { extract($aryTmp[$ii]); $aryReturn[$dimenKey][$domainId] = htmlspecialchars((__DEBUG__ ? $domainId . ',' : '') . $domain . "(" . $advName . ")"); } break; case 'advertiserId': $idStr = "'" . implode("', '", array_unique($aryIdSet[$dimenKey])) . "'"; $aryTmp = $this->_getAdverNameList('ID in (' . $idStr . ')'); for ($ii = 0; $ii < count($aryTmp); $ii++) { extract($aryTmp[$ii]); $aryReturn[$dimenKey][$ID] = htmlspecialchars((__DEBUG__ ? $ID . ',' : '') . $Name); } break; case 'channelGroupId': $aTmpSid = $aTmpCgId = array(-1); $aS2Name = $aCg2Name = array(); for ($ii = 0; $ii < count($aryIdSet[$dimenKey]); $ii++) { list($aTmpSid[], $aTmpCgId[]) = explode($this->resourceSplitChar, $aryIdSet[$dimenKey][$ii]); } $sidStr = implode(", ", array_unique($aTmpSid)); $cgidStr = implode(", ", array_unique($aTmpCgId)); $aryTmp = $this->_getSiteNameList('ID in (' . $sidStr . ')'); for ($ii = 0; $ii < count($aryTmp); $ii++) { $aS2Name[$aryTmp[$ii]['ID']] = $aryTmp[$ii]['Sitename']; } $aryTmp = $this->_getChannelGroupNameList('ID in (' . $cgidStr . ')'); for ($ii = 0; $ii < count($aryTmp); $ii++) { $aCg2Name[$aryTmp[$ii]['ID']] = $aryTmp[$ii]['pactCGName']; } for ($ii = 0; $ii < count($aryIdSet[$dimenKey]); $ii++) { list($sSId, $sCgId) = explode($this->resourceSplitChar, $aryIdSet[$dimenKey][$ii]); $sSName = isset($aS2Name[$sSId]) ? $aS2Name[$sSId] : $this->_('fieldNotSet'); $sCgName = isset($aCg2Name[$sCgId]) ? $aCg2Name[$sCgId] : $this->_('fieldNotSet'); $aryReturn[$dimenKey][$aryIdSet[$dimenKey][$ii]] = $sSName . '/' . $sCgName; } break; case 'location': switch ($sSelected) { case 'country': case 'sony_location': case 'sony_city': case 'province': case 'city': default: $idStr = "'" . implode("','", array_unique($aryIdSet[$dimenKey])) . "'"; $aConfig['countryNameFlag'] = !isset($aConfig['countryNameFlag']) ? 1 : $aConfig['countryNameFlag']; $aryTmp = $this->_getLocationNameList($sSelected, $idStr, $aConfig); for ($ii = 0; $ii < count($aryTmp); $ii++) { extract($aryTmp[$ii]); if (!empty($country)) { $aryReturn[$dimenKey][$country] = (__DEBUG__ ? $country . '/' : '') . $name_country; } if (!empty($province)) { $aryReturn[$dimenKey][$province] = (__DEBUG__ ? $province . '/' : '') . $name_province; } if (!empty($city)) { $aryReturn[$dimenKey][$city] = (__DEBUG__ ? $city . '/' : '') . $name_city; } } // var_export($sSelected); // var_export($aryReturn[$dimenKey]); break; } break; case 'fansPropertyKey': $aryReturn[$dimenKey] = array('f' => '女', 'm' => '男', 'n' => '未知'); break; case 'timeslot2': for ($ii = 0; $ii < count($aryIdSet[$dimenKey]); $ii++) { $aryReturn[$dimenKey][$aryIdSet[$dimenKey][$ii]] = "AA"; } break; case 'num2citykey': // var_export(11); //var_dump($aryIdSet[$dimenKey]);exit; //根据$aryIdSet[$dimenKey]取得城市代码的映射 $tmp_arr = array(); foreach ($tmp_arr as $k => $v) { $aryReturn[$dimenKey][$v] = $k; } break; default: switch ($sSelected) { case 'country': case 'sony_location': case 'sony_city': case 'province': case 'city': default: foreach ($aryIdSet[$dimenKey] as $v) { $aryReturn[$dimenKey][(string) $v] = $v; } // var_export($sSelected); // var_export($aryReturn[$dimenKey]); break; } break; } } return $aryReturn; }
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); }
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); }
/** * 根据那年的那一周返回那一周的第一天和最后一天 * */ function _getMonthPeriod($yearmonth, $periodFlag = 1, $sDate = '', $eDate = '') { $sDateStamp = strtotime($sDate); $eDateStamp = strtotime($eDate); $aPeriod = array(); $year = substr($yearmonth, 0, 4) . ''; $month = substr($yearmonth, 5, 2); $startdate = mktime(0, 0, 0, $month, 1, $year); $enddate = strtotime($yearmonth . "-" . date("t", strtotime($yearmonth . "-01"))); $startdate = $startdate < $sDateStamp ? $sDateStamp : $startdate; $enddate = $enddate > $eDateStamp ? $eDateStamp : $enddate; return $periodFlag == 1 ? \YcheukfReport\Lib\ALYS\ALYSLang::_('ALYSmonthPositon', array(intval($year), intval($month))) . "(" . date('Y-m-d', $startdate) . "~" . date('Y-m-d', $enddate) . ")" : \YcheukfReport\Lib\ALYS\ALYSLang::_('ALYSmonthPositon', array(intval($year), intval($month))); }
/** * 明细列表html列表头的定制 *@param array groups 列表头数据 *@return string HTML字符串 */ public function ALYSfmt_list_title($groups, $format = 'html') { $bIsPerspective = $this->_isPerspective(); // $aDimens = array(); $aMetrics = array(); $aMetricKeys = array(); $html = "<th _listtdcss0 ><div>" . \YcheukfReport\Lib\ALYS\ALYSLang::_('NO') . ('pdf' == $format ? '' : " <span _listThSpan _listspan0 >" . \YcheukfReport\Lib\ALYS\ALYSLang::_('select') . "</span>") . "</div></th>"; if (is_array($groups)) { foreach ($groups as $k => $aTmp) { foreach ($aTmp as $key => $aGroup) { $key = $aGroup['key']; $label = \YcheukfReport\Lib\ALYS\ALYSLang::_($aGroup['key']); if ('dimen' == $k) { //$label = \YcheukfReport\Lib\ALYS\ALYSLang::_($aGroup['key']); $tipLabel = "title='" . \YcheukfReport\Lib\ALYS\ALYSLang::_($aGroup['key'] . "-tip") . "'"; $aDimens[] = $aGroup['key']; } else { //$label = ($bIsPerspective?$aGroup['label']:\YcheukfReport\Lib\ALYS\ALYSLang::_($aGroup['key'])); $tipLabel = ''; $aMetrics[$aGroup['label']] = $aGroup['label']; $aMetricKeys[$aGroup['key']] = $aGroup['key']; } $aThClass = isset($aGroup['thclass']) && count($aGroup['thclass']) ? $aGroup['thclass'] : array('td150'); $aTipClass = isset($aGroup['tipclass']) && count($aGroup['tipclass']) ? $aGroup['tipclass'] : array('jp_tip'); if ($aGroup['sortAble']) { $aThClass[] = 'sortable'; } if (isset($aGroup['orderbyClass']) && !empty($aGroup['orderbyClass'])) { $aThClass[] = $aGroup['orderbyClass']; } // var_export($aThClass); $sThClass = $sTipClass = ""; //根据不同的输出类型处理样式 switch ($format) { default: case 'html': $sTipClass = " class='" . join(" ", $aTipClass) . "'"; $sThClass = " class='" . join(" ", $aThClass) . "'"; break; case 'pdf': //pdf中需要把这些class分别替换 foreach ($aTipClass as $c) { $sTipClass = " class='" . $c . "'"; } foreach ($aThClass as $c) { $sThClass = " class='" . $c . "'"; } break; } $html .= "\n<th nowrap _" . $k . "listthcss0 data-key='{$key}' {$sThClass}><div>" . $label . "<span _" . $k . "listspan0 {$sTipClass} {$tipLabel}> </span></div></th>"; } } } //拼凑透视表的头 $return_html = ""; $sPerspective = '<th _listtdcss0 > </th>'; if ($bIsPerspective) { $return_html = "\n<tr _listtrtitle>\n"; $return_html .= $html; $return_html .= "\n</tr>"; if (is_array($aDimens)) { foreach ($aDimens as $dv) { $sPerspective .= "\n<th nowrap><div> <span > </span></div></th>"; } } $iRowSpan = count($aMetricKeys); if (is_array($aMetrics)) { foreach ($aMetrics as $mv) { $sPerspective .= "\n<th colspan='" . $iRowSpan . "'><div> <span >" . $mv . "</span></div></th>"; } } $return_html = '<tr>' . $sPerspective . '</tr>' . $return_html; } else { $return_html .= $html; } return $return_html; }
/** * 重写 * 获得数据入口 */ 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; }
/** * @生成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; }
/** * ����idigger */ public function _($name) { \YcheukfReport\Lib\ALYS\ALYSLang::_($name); }
function _getCompatibleCode($aryLabelSet4Geo) { $aryLabelSet4Geo['TW'] = \YcheukfReport\Lib\ALYS\ALYSLang::_('taiwan'); $aryLabelSet4Geo['CD'] = \YcheukfReport\Lib\ALYS\ALYSLang::_('CongoRepublic'); // $aryLabelSet4Geo['CG'] = $GLOBALS['lang']['taiwan']; return $aryLabelSet4Geo; }