Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
    /**
    *	负责Email发送
    
    @param string staticKey 静态html链接的key
    @return array 处理过后的email数组
    @description 处理
    */
    public function ALYSbefore_email($staticKey)
    {
        $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
        $aInput = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
        //配置静态页面时间
        $time = $_ALYSconfig['cache']['report_static_html']['lifeTime'];
        $nDate = intval($time / (3600 * 24));
        //配置静态页面链接
        $url = $_ALYSconfig['rooturl'] . "demo/advance_get_statichtml.php";
        //配置email信息
        $aEmail = array();
        $mailBody = isset($aInput['custom']['email']['mailBody']) ? $aInput['custom']['email']['mailBody'] : "hello world";
        $aEmail['subject'] = 'report engine';
        $aEmail['fromEmail'] = '*****@*****.**';
        $aEmail['toEmail'] = isset($aInput['custom']['email']['toEmail']) ? join(',', $aInput['custom']['email']['toEmail']) : "'ycheukf@gmail.com,ruzhuo_feng@allyes.com'";
        //逗号分割
        $aEmail['body'] = <<<OUTPUT
\t\t\t<p>您好: 
\t\t\t{$mailBody}
\t\t\t<p>\t请点击链接查看报表
\t\t\t<p>\t{$url}?id={$staticKey}
\t\t\t<p>\t本条链接在{$nDate}天内有效
OUTPUT;
        //var_export($aEmail);
        return $aEmail;
    }
Ejemplo n.º 3
0
 public function pdf($filePath, $exportName)
 {
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     $path = $_ALYSconfig['pdf']['path'];
     $path = $path . $filePath;
     self::_download($path, $exportName);
 }
Ejemplo n.º 4
0
    /**
     * 格式化 flash输出的html
     *
     * @param string xmlData flash中的字符串
     * @param string flashType flash类型
     * @param height int 该flash所展示的高度
     * @return array array(html字符串,装载该flash的div id)
     */
    function ALYSfmtOutputFusionScript($xmlData, $flashType, $height)
    {
        $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
        $html = '';
        $src = $_ALYSconfig['fusion']['src'][$flashType];
        $callpdf = $_ALYSconfig['fusion']['exportCallpdf'];
        $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();
        $sServerUrl = $_SERVER['PHP_SELF'] . (empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']);
        $html = <<<OUTPUT
\t\t\t<div id='{$divId}_div' class='ALYSflash_trend_div'></div>
\t\t\t<script language='JavaScript' type='text/javascript'>
\t\t\tif(!ALYSre_export)
\t\t\t\tvar ALYSre_export = {chartObjects:[]};
\t\t\tif(!ALYSre_export.pdf_export_location)
\t\t\t\tALYSre_export.pdf_export_location = "{$sServerUrl}";
\t\t\t(function(){
\t\t\t\tvar oChart = new FusionCharts("{$src}?ChartNoDataText={$ChartNoDataText}&PBarLoadingText={$PBarLoadingText}&XMLLoadingText={$XMLLoadingText}&ParsingDataText={$ParsingDataText}&RenderingChartText={$RenderingChartText}&LoadDataErrorText={$LoadDataErrorText}&InvalidXMLText={$InvalidXMLText}", '{$divId}', '100%', '{$height}', '0', '1', '','noScale');
\t\t\t\toChart.setTransparent(1);
\t\t\t\toChart.setDataXML("{$xmlData}");
\t\t\t\toChart.render('{$divId}_div');
\t\t\t})();
\t\t\t</script>
OUTPUT;
        return array($html, $divId);
    }
Ejemplo n.º 5
0
 public function onBootstrap(MvcEvent $event)
 {
     //        if (PHP_SAPI === 'cli') return;
     $app = $event->getApplication();
     $sm = $app->getServiceManager();
     \YcheukfReport\Lib\ALYS\ALYSConfig::set('dbHandle', $sm->get('Zend\\Db\\Adapter\\Adapter'));
     \YcheukfReport\Lib\ALYS\ALYSConfig::set('smHandle', $sm);
 }
Ejemplo n.º 6
0
 /**
  * 语言数组, 键值会转换为大写后再输出
  */
 public function _getLangAry()
 {
     $aLang = array('SELECT' => '', 'DBCONFIGOP' => '操作', 'CUSTOMERID' => '客户ID', 'SERVERNAME' => '主机名', 'MASTERHOST' => '主机IP', 'RE_DIMEN_EDIT' => '编辑属性', 'RE_DIMEN_UPGRADE' => 'DB升级', 'RE_DIMEN_DOWNGRADE' => 'DB降级', 'RE_DIMEN_CONFIG' => '调整配置', 'NEWESTVERSION ' => '最新版本', 'CURRENTVERSION ' => '当前版本');
     $smHandle = \YcheukfReport\Lib\ALYS\ALYSConfig::get('smHandle');
     $aRe = array();
     foreach ($aLang as $k => $v) {
         $aRe[strtoupper(trim($k))] = $smHandle->get('translator')->translate($v, 'reportengine');
     }
     return $aRe;
 }
Ejemplo n.º 7
0
 public static function getDateFeildByTable($type = '', $table = '')
 {
     if (empty($type) || empty($table)) {
         return \YcheukfReport\Lib\ALYS\ALYSConfig::get('dateField');
     }
     $Input = \YcheukfReport\Lib\ALYS\Report\Start::getInput();
     $aInput = $Input['input'][$type];
     $dateFeild = @$aInput['table'][$table]['dateFeild'];
     if (empty($dateFeild)) {
         $dateFeild = \YcheukfReport\Lib\ALYS\ALYSConfig::get('dateField');
     }
     return $dateFeild;
 }
Ejemplo n.º 8
0
 public function __construct($aConfig)
 {
     $this->runFlag = true;
     $this->aConfig = $aConfig;
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     $this->_get_preconfigmemo();
     $this->aConfig['temdir'] = $_ALYSconfig['cache']['shell']['cacheDir'];
     if (isset($this->aConfig['remotepassword'])) {
         $this->aConfig['remotepassword'] = $this->_generalSshpsw($this->aConfig['remotepassword']);
     }
     if (isset($this->aConfig['password'])) {
         $this->aConfig['password'] = $this->_generalSshpsw($this->aConfig['password']);
     }
 }
Ejemplo n.º 9
0
 function get($key)
 {
     // 获取缓存数据
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     if ($key == 'w2fdebug' && $_ALYSconfig['debug'] != 1) {
         return "";
     }
     if ($this->cacheType == 'file') {
         $life = (int) json_decode($this->cac->get($key))->lifetime;
         $last = (int) $this->cac->lastModified();
         $add = $last + $life;
         $now = $this->_secTime();
         $diff = $add - $now;
         $buffer = $diff > 0 ? json_decode($this->cac->get($key))->data : $this->cac->setLifeTime(0);
         return $buffer;
     } elseif ($this->cacheType == 'mmc') {
         return $this->cac->get($key);
     } else {
         return false;
     }
 }
Ejemplo n.º 10
0
 function send($to, $subject, $body, $file = '')
 {
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     \YcheukfCommon\Lib\Functions::sendEmailByMQ($_ALYSconfig['smHandle'], $to, $subject, $body);
     return true;
     //旧的逻辑
     $this->hdrs['From'] = $this->config['mail']['username'];
     //发信地址
     $this->hdrs['To'] = strtr($to, ';', ',');
     //收信地址
     $this->hdrs['Subject'] = $subject;
     //邮件标题
     $this->mime = new Mail_mime();
     $this->mime->_build_params['html_charset'] = "utf-8";
     //设置编码格式
     $this->mime->_build_params['head_charset'] = "utf-8";
     //设置编码格式
     $this->mime->setHTMLBody($body);
     //设置邮件正文
     if ($file != "") {
         $this->mime->addAttachment($file, 'application/octet-stream');
         //设置附件纯文本内容text/html或设置成		application/octet-stream 附件下载
     }
     $new_body = $this->mime->get();
     $headers = $this->mime->headers($this->hdrs);
     $ret = $this->mail_object->send($this->hdrs['To'], $headers, $new_body);
     //发送邮件
     //var_dump($ret);
     if (PEAR::isError($ret)) {
         //检测错误
         $s = $ret->getMessage();
         throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEMAIL_ERROR', $s);
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 11
0
 /**
  * 不同的部分
  */
 public function go_diff()
 {
     $geoType = $this->dateType;
     $showLabels = 0;
     $type = 'flash';
     $aInput = $this->aInput['input'][$type];
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     $noDataShowLabel = empty($_ALYSconfig['fusion']['geography']['noDataShowLabel']) ? 0 : 1;
     $geographyRange = empty($aInput['geoRangeStyle']) ? 'common' : $aInput['geoRangeStyle'];
     unset($this->aChartStyles['range']);
     $field = $aInput['mainTable']['showField'][0];
     $oId2Label = \YcheukfReport\Lib\ALYS\ALYSFunction::loadDictionary('Id2label');
     $aTmp = $oId2Label->ALYSchgId2Label($this->dimenkey2selected);
     $aryLabelSet4Geo = $aTmp[key($this->dimenkey2selected)];
     $Data = $this->aDatas[0][$field];
     $DataN = $this->aFlashDatas[0][$field];
     //$Data = $DataN = array(58=>900);
     //		var_dump($aTmp);
     //翻译citykey
     $sCitykey = 'num2citykey';
     $aIDs = array();
     if (is_array($DataN)) {
         foreach ($DataN as $k => $v) {
             $aIDs[$sCitykey][] = $k;
         }
     }
     $aLabel = $oId2Label->ALYSchgId2Label(array($sCitykey => $sCitykey), $aIDs);
     $aCityMap = $aLabel[$sCitykey];
     //var_dump($aCityMap,$Data);exit;
     $fieldLabel = \YcheukfReport\Lib\ALYS\ALYSLang::_($field);
     if ($geoType == 'country') {
         $aCountrySN2Id = $this->_getCountryShortName2Id();
         $aryLabelSet4Geo = $this->_getCompatibleCode($aryLabelSet4Geo);
         foreach ($aryLabelSet4Geo as $shortName => $geoLabel) {
             $fusionCountryId = $this->_chgLocationCode2FusionCode($shortName);
             if (empty($aCountrySN2Id[$fusionCountryId])) {
                 continue;
             }
             $iniId = $aCountrySN2Id[$fusionCountryId];
             if ($Data[$fusionCountryId]) {
                 if (!empty($_ALYSconfig['fusion']['geography']['linkble'])) {
                     $event = $shortName == 'CN' ? "link=\\\"JavaScript:changeGeoMap('country', '" . $shortName . "');\\\"" : "";
                 }
                 $value = $DataN[$fusionCountryId];
                 $entitys .= "<entity id='" . $iniId . "' value='" . $value . "' showLabel='1' displayValue='" . $geoLabel . "' toolText='" . $fieldLabel . ',' . $geoLabel . ',' . $Data[$fusionCountryId] . "' " . $event . "/>";
             } else {
                 $entitys .= "<entity id='" . $iniId . "' value='0' displayValue='" . $geoLabel . "' toolText='" . $geoLabel . "' showLabel='" . $noDataShowLabel . "' />";
             }
         }
     } elseif ($geoType == 'province') {
         unset($Data['CN00']);
         foreach ($aryLabelSet4Geo as $shortName => $geoLabel) {
             list($t, $geoLabel) = explode('-', $geoLabel);
             $countryCode = substr($shortName, 0, 2);
             if ($countryCode == 'CN') {
                 $provinceCode = substr($shortName, 2, 2);
                 $fusionProvinceId = 'CN.' . $provinceCode;
                 $fusionProvinceId = $this->_chgLocationCode2FusionCode($fusionProvinceId);
                 if (!empty($_ALYSconfig['fusion']['geography']['linkble'])) {
                     $event = " link=\\\"JavaScript:changeGeoMap('province', '" . $countryCode . '.' . $provinceCode . "');\\\"";
                 }
                 if (!empty($aCityMap[$shortName])) {
                     $shortName = $aCityMap[$shortName];
                 }
                 if ($Data[$shortName]) {
                     //$selectedProvince = ($geoType == 'city' && strtoupper($provinceCode)==strtoupper($aryData['geoTypeProvinceCode']))? "fontBold='1' fontSize='16' fontColor='0' color='FF9933'":"";
                     $value = $DataN[$shortName];
                     $entitys .= "<entity id='" . $fusionProvinceId . "' value='" . $value . "' showLabel='1' displayValue='" . $geoLabel . "' toolText='" . $fieldLabel . ',' . $geoLabel . ',' . $Data[$shortName] . "' {$event} {$selectedProvince}/>";
                 } else {
                     $entitys .= "<entity id='" . $fusionProvinceId . "' value='0' displayValue='" . $geoLabel . "' toolText='" . $geoLabel . "' showLabel='" . $noDataShowLabel . "'  {$event}/>";
                 }
             } else {
                 unset($Data[$shortName]);
             }
         }
         $showLabels = 1;
     }
     //echo "aryLabelSet4Geo=";print_r($aryLabelSet4Geo);
     //$colorRange = $this->_getFusionColorRange($field, @max($DataN));
     if ('percent' == $geographyRange) {
         $colorRange = $this->_rangeColor1to10percent(@max($DataN));
     } elseif ('5hundred' == $geographyRange) {
         $colorRange = $this->_rangeColor1to5hun(@max($DataN));
     } else {
         $colorRange = $this->_getFusionColorRange($field, @max($DataN));
     }
     $s1 = "";
     $sUrlBase = \YcheukfCommon\Lib\Functions::getBaseUrl($_ALYSconfig['smHandle']);
     if (count($this->aChartStyles)) {
         foreach ($this->aChartStyles as $k => $v) {
             $s1 .= " {$k}='{$v}'";
         }
         if (isset($_ALYSconfig['fusion']['exportHandler'])) {
             $s1 .= " exportHandler='" . $sUrlBase . '/' . $_ALYSconfig['fusion']['exportHandler'] . "'";
         }
     }
     $this->xmlData = "<map showLabels ='" . $showLabels . "' legendCaption='" . $fieldLabel . "' {$s1}>" . $colorRange . "<data>" . $entitys . '</data></map>';
 }
Ejemplo n.º 12
0
 /**
  *	加载DB句柄
  **/
 public static function loadDb()
 {
     $sDbHandle = 'dbHandle';
     $oDbHandle = \YcheukfReport\Lib\ALYS\ALYSConfig::get($sDbHandle);
     return $oDbHandle;
 }
Ejemplo n.º 13
0
 /**
  * set db object
  */
 public function setOdbp()
 {
     $sDboperator = \YcheukfReport\Lib\ALYS\ALYSConfig::get('dboperator');
     self::$oInstant = \YcheukfReport\Lib\ALYS\ALYSFunction::loadClass("dboperate." . $sDboperator);
 }
Ejemplo n.º 14
0
 /**
  * 将数据表中获取得的相关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> &nbsp; <a _val='" . $v . "' class='upgrade' href='javascript::void()'>" . \YcheukfReport\Lib\ALYS\ALYSLang::_('RE_DIMEN_UPGRADE') . "</a> &nbsp; <a _val='" . $v . "' class='downgrade' href='javascript::void()'>" . \YcheukfReport\Lib\ALYS\ALYSLang::_('RE_DIMEN_DOWNGRADE') . "</a>&nbsp; <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;
 }
Ejemplo n.º 15
0
 /**
     获取所有搜索结果
     @parm array aConf 同sql_getByConfig参数
 */
 function getAll($aConf)
 {
     $oSmHandle = \YcheukfReport\Lib\ALYS\ALYSConfig::get('smHandle');
     $aParams = $this->_getBySqlConfig($oSmHandle, $aConf);
     $aReturn = \Application\Model\Common::getResourceList2($oSmHandle, $aParams);
     return array($aReturn['dataset'], $aReturn['count']);
 }
Ejemplo n.º 16
0
 /**
  * 拼装不同的flash xml字符串.
  */
 public function go_diff()
 {
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     $functionName = $this->trendType . 'Function';
     if ($this->trendType == 'trend') {
         $functionName = 'multdateFunction';
     }
     //echo "this->trendType=";print_r($this->trendType);
     list($categories, $datasets, $sCount) = $this->{$functionName}();
     $labelStep = intval(intval($sCount) / $this->trend_step);
     $categories = '<categories>' . $categories . '</categories>';
     $s1 = "";
     //		$sUrlBase = (\YcheukfCommon\Lib\Functions::getBaseUrl($_ALYSconfig['smHandle']));
     if (count($this->aChartStyles)) {
         foreach ($this->aChartStyles as $k => $v) {
             $s1 .= " {$k}='{$v}'";
         }
         if (isset($_ALYSconfig['fusion']['bgSWF']) and $this->flashType != 'MSCombiDY2D' and $this->trendType != 'bubble') {
             $s1 .= " bgSWF='" . $_ALYSconfig['smHandle']->get('zendviewrendererphprenderer')->basePath() . '/' . $_ALYSconfig['fusion']['bgSWF'] . "'";
         }
         if (isset($_ALYSconfig['fusion']['exportHandler'])) {
             $s1 .= " exportHandler='" . $_ALYSconfig['fusion']['exportHandler'] . "'";
         }
     }
     //bubble图读取chart属性中的动态配置 主要是标题
     if ('bubble' == $this->trendType) {
         $sXkey = $this->aMainTable['showField'][0];
         $sYkey = $this->aMainTable['showField'][1];
         $seresName = \YcheukfReport\Lib\ALYS\ALYSLang::_($sXkey);
         $s1 .= " xAxisName='" . \YcheukfReport\Lib\ALYS\ALYSFunction::_htmlspecialchars(\YcheukfReport\Lib\ALYS\ALYSLang::_($sXkey)) . "'";
         $s1 .= " yAxisName='" . \YcheukfReport\Lib\ALYS\ALYSFunction::_htmlspecialchars(\YcheukfReport\Lib\ALYS\ALYSLang::_($sYkey)) . "'";
     }
     $this->xmlData = "<chart labelStep='" . $labelStep . "' {$s1}>" . $categories . $datasets . '</chart>';
 }
Ejemplo n.º 17
0
 /**
  * 为柱状条格式化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);
 }
Ejemplo n.º 18
0
 /**
  * check common input param
  */
 public function _checkInputParam()
 {
     $aInput = self::getInput();
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     $aInputkey = array('dbHandle', 'date', 'filters', 'input', 'output', 'custom', 'groups', 'nodateFlag');
     if (!is_array($aInput)) {
         throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', json_encode($aInput));
     }
     foreach ($aInput as $key => $val) {
         if (!in_array($key, $aInputkey)) {
             throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', "::" . $key);
         }
     }
     $aInput['dbHandle'] = isset($aInput['dbHandle']) ? $aInput['dbHandle'] : 'Zend\\Db\\Adapter\\Adapter';
     $aInput['filters'] = isset($aInput['filters']) ? $aInput['filters'] : array();
     if (!isset($aInput['dbHandle'])) {
         throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_VALUE_WRONG', 'dbHandle');
     }
     //兼容没有date的情况
     $aInput['nodateFlag'] = false;
     if (!isset($aInput['date']) || empty($aInput['date'])) {
         $aInput['nodateFlag'] = true;
         $aInput['date'] = array(array('s' => '1979-01-01', 'e' => '1979-01-01'));
     }
     $aDateKey = array('s', 'e');
     $dateReg = "/\\d{4}-\\d{2}-\\d{2}/";
     foreach ($aInput['date'] as $Date) {
         $DateKey = array_keys($Date);
         foreach ($DateKey as $key) {
             if (!in_array($key, $aDateKey)) {
                 throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', 'date');
             }
             if (!preg_match($dateReg, $Date[$key])) {
                 throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_VALUE_WRONG', 'date');
             }
         }
     }
     $aFiltersKey = array('key', 'op', 'value', 'group');
     foreach ($aInput['filters'] as $Filters) {
         $FiltersKey = array_keys($Filters);
         foreach ($FiltersKey as $key) {
             if (!in_array($key, $aFiltersKey)) {
                 throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', 'filters');
             }
         }
     }
     foreach ($aInput['input'] as $p => $inputType) {
         if (!in_array($p, array('flash', 'total', 'detail'))) {
             throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_INPUT_KEY_WRONG', $p);
         }
     }
     self::setInput($aInput);
 }
Ejemplo n.º 19
0
 /**
  *	生成文件 供下载
  *
  */
 public function exportAllData()
 {
     $this->chkAndParseInput();
     //最大执行时间设置为无限长
     set_time_limit(0);
     $csvLoading = false;
     $exportType = $this->_aInput['output']['exportInfo']['type'];
     $exportProperty = array();
     $fileName = @$this->_aInput['output']['exportInfo']['fileName'];
     switch ($exportType) {
         case 'file':
             $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
             $fileDir = @$_ALYSconfig['cache']['csv']['cacheDir'];
             if (!is_dir($fileDir)) {
                 $ret = mkdir($fileDir, 777, true);
                 if (!$ret) {
                     throw new \YcheukfReport\Lib\ALYS\ALYSException('ALYSEXPT_KEY_WRONG', 'make dir fail:' . $fileDir);
                 }
             }
             $csvLoading = @$this->_aInput['output']['csvLoading'];
             //进度信息输出
             $fileName = rtrim($fileDir, '/') . '/' . $this->_conv($fileName) . '.csv';
             //先删除文件
             if (file_exists($fileName)) {
                 @unlink($fileName);
             }
             $exportProperty['fileName'] = $fileName;
             break;
         case 'download':
         default:
             ob_clean();
             //no cache
             header('Expires: ' . date(DATE_RFC1123));
             header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
             header('Pragma: no-cache');
             header('Last-Modified: ' . date(DATE_RFC1123));
             header('Pragma: public');
             $fileName = str_replace(array(';', '"', "\n", "\r"), '-', $fileName);
             $fileName = $this->_conv($fileName) . '.csv';
             header('Content-Description: File Transfer');
             header('Content-Disposition: attachment; filename="' . $fileName . '"');
             header('Content-Type: text/comma-separated-values');
             header('Content-Transfer-Encoding: binary');
             //header("Content-Length: ".$len);
             break;
     }
     //flash & total
     $flash_and_total = $this->_getFlsTotal();
     if (false !== $flash_and_total) {
         $flash_and_total = $this->_conv($flash_and_total);
         $this->_processData($flash_and_total, $exportType, $exportProperty);
     }
     $this->_aInput['input']['detail']['page']['items_per_page'] = self::MAX_DATA_COUNT;
     //每页条数
     $doWhile = true;
     $iCurrentPage = 0;
     $sAtt = '';
     for ($i = 0; $i < 1020; $i++) {
         $sAtt .= " ";
     }
     $total_start = microtime(true);
     if ($csvLoading) {
         ob_start();
         ob_end_flush();
         echo "running...<br/>" . $sAtt . "\n";
         ob_flush();
         flush();
     }
     while ($doWhile) {
         $this->_aInput['input']['detail']['page']['current_page'] = $iCurrentPage++;
         $start = microtime(true);
         $ret = $this->_getData();
         if ($csvLoading) {
             echo 'page ' . $iCurrentPage . ' spends time(sec):' . round(microtime(true) - $start, 2) . "\n<br/>";
             ob_flush();
             flush();
         }
         //转成GBK输出
         $ret['data'] = $this->_conv($ret['data']);
         $this->_processData($ret['data'], $exportType, $exportProperty);
         $this->_aInput['input']['detail']['page']['startItem'] = $iCurrentPage * self::MAX_DATA_COUNT;
         if ($ret['num'] < self::MAX_DATA_COUNT || $iCurrentPage >= self::MAX_DATA_PAGE) {
             $doWhile = false;
         }
     }
     if ($csvLoading) {
         echo 'total time:' . round(microtime(true) - $total_start, 2);
     }
     return true;
 }
Ejemplo n.º 20
0
 function setInfo($name = '', $type, $top, $headFoot, $pageFooter)
 {
     // Set some content to print
     if (!is_null($name)) {
         $this->_name = $name;
     }
     $this->_type = $type;
     $_ALYSconfig = \YcheukfReport\Lib\ALYS\ALYSConfig::get();
     $this->pdf->SetHeaderData($_ALYSconfig['pdf']['img'], 40, $top, $headFoot);
     $this->pdf->setLanguageArray(array('w_page' => $pageFooter));
     return $this->_name;
 }