00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00041 class OpportunitiesByStageChartView extends ChartView implements PortletViewInterface
00042 {
00043 public function renderContent()
00044 {
00045 $accessContent = $this->resolveContentIfCurrentUserCanAccessChartByModule(
00046 'OpportunitiesModule', 'OpportunitiesModulePluralLabel');
00047 if ($accessContent != null)
00048 {
00049 return $accessContent;
00050 }
00051 $chartDataProviderType = $this->getChartDataProviderType();
00052 $chartDataProvider = ChartDataProviderFactory::createByType($chartDataProviderType);
00053 ControllerSecurityUtil::resolveCanCurrentUserAccessModule(
00054 $chartDataProvider->getModel()->getModuleClassName(), true);
00055 $chartData = $chartDataProvider->getChartData();
00056 Yii::import('ext.amcharts.AmChartMaker');
00057 $amChart = new AmChartMaker();
00058 $amChart->data = $chartData;
00059 $amChart->id = $this->uniqueLayoutId;
00060 $amChart->type = $this->resolveViewAndMetadataValueByName('type');
00061 $amChart->addSerialGraph('value', 'column');
00062 $amChart->xAxisName = $chartDataProvider->getXAxisName();
00063 $amChart->yAxisName = $chartDataProvider->getYAxisName();
00064 $amChart->yAxisUnitContent = Yii::app()->locale->getCurrencySymbol(Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay());
00065 $javascript = $amChart->javascriptChart();
00066 Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->uniqueLayoutId, $javascript);
00067 $cClipWidget = new CClipWidget();
00068 $cClipWidget->beginClip("Chart");
00069 $cClipWidget->widget('application.core.widgets.AmChart', array(
00070 'id' => $this->uniqueLayoutId,
00071 ));
00072 $cClipWidget->endClip();
00073 return $cClipWidget->getController()->clips['Chart'];
00074 }
00075
00076 public function getPortletParams()
00077 {
00078 return array();
00079 }
00080
00081 public function renderPortletHeadContent()
00082 {
00083 return null;
00084 }
00085
00086 public static function getDefaultMetadata()
00087 {
00088 return array(
00089 'perUser' => array(
00090 'title' => "eval:Zurmo::t('OpportunitiesModule', 'Opportunities By Sales Stage', LabelUtil::getTranslationParamsForAllModules())",
00091 'type' => ChartRules::TYPE_COLUMN_2D,
00092 ),
00093 'global' => array(
00094 ),
00095 );
00096 }
00097
00102 public static function getPortletRulesType()
00103 {
00104 return 'Chart';
00105 }
00106
00110 public static function getModuleClassName()
00111 {
00112 return 'OpportunitiesModule';
00113 }
00114
00115 public function getChartDataProviderType()
00116 {
00117 return 'OpportunitiesByStage';
00118 }
00119
00123 public static function getPortletDescription()
00124 {
00125 }
00126 }
00127 ?>