本文整理汇总了PHP中CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly方法的具体用法?PHP CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly怎么用?PHP CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contribute_BAO_Contribution_Utils
的用法示例。
在下文中一共展示了CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
//get the submitted form values.
$submittedValues = $this->controller->exportValues($this->_name);
// get the chart type.
$chartType = CRM_Utils_Array::value('chart_type', $submittedValues, 'bvg');
//take contribution information monthly
require_once 'CRM/Contribute/BAO/Contribution/Utils.php';
$selectedYear = CRM_Utils_Array::value('select_year', $submittedValues, date('Y'));
$chartInfoMonthly = CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly($selectedYear);
$chartData = $abbrMonthNames = array();
if (is_array($chartInfoMonthly)) {
for ($i = 1; $i <= 12; $i++) {
$abbrMonthNames[$i] = strftime('%b', mktime(0, 0, 0, $i, 10, 1970));
}
foreach ($abbrMonthNames as $monthKey => $monthName) {
$val = CRM_Utils_Array::value($monthKey, $chartInfoMonthly['By Month'], 0);
// don't include zero value month.
if (!$val && $chartType != 'bvg') {
continue;
}
//build the params for chart.
$chartData['by_month']['values'][$monthName] = $val;
}
$chartData['by_month']['legend'] = 'By Month' . ' - ' . $selectedYear;
// handle onclick event.
$chartData['by_month']['on_click_fun_name'] = 'byMonthOnClick';
$chartData['by_month']['yname'] = ts('Contribution');
}
//take contribution information by yearly
$chartInfoYearly = CRM_Contribute_BAO_Contribution_Utils::contributionChartYearly();
//get the years.
$this->_years = $chartInfoYearly['By Year'];
$hasContributions = false;
if (is_array($chartInfoYearly)) {
$hasContributions = true;
$chartData['by_year']['legend'] = 'By Year';
$chartData['by_year']['values'] = $chartInfoYearly['By Year'];
// handle onclick event.
$chartData['by_year']['on_click_fun_name'] = 'byYearOnClick';
$chartData['by_year']['yname'] = ts('Contribution');
}
$this->assign('hasContributions', $hasContributions);
// process the data.
require_once 'CRM/Utils/OpenFlashChart.php';
$chartCnt = 1;
$monthlyChart = $yearlyChart = false;
foreach ($chartData as $chartKey => &$values) {
$chartValues = CRM_Utils_Array::value('values', $values);
if (!is_array($chartValues) || empty($chartValues)) {
continue;
}
if ($chartKey == 'by_year') {
$yearlyChart = true;
}
if ($chartKey == 'by_month') {
$monthlyChart = true;
}
$values['divName'] = "open_flash_chart_{$chartKey}";
$funName = $chartType == 'bvg' ? 'barChart' : 'pieChart';
// build the chart objects.
eval("\$values['object'] = CRM_Utils_OpenFlashChart::" . $funName . '( $values );');
//build the urls.
$urlCnt = 0;
foreach ($chartValues as $index => $val) {
$urlParams = null;
if ($chartKey == 'by_month') {
$monthPosition = array_search($index, $abbrMonthNames);
$startDate = CRM_Utils_Date::format(array('Y' => $selectedYear, 'M' => $monthPosition));
$endDate = date('Ymd', mktime(0, 0, 0, $monthPosition + 1, 0, $selectedYear));
$urlParams = "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0";
} else {
if ($chartKey == 'by_year') {
$startDate = CRM_Utils_Date::format(array('Y' => $index));
$endDate = date('Ymd', mktime(0, 0, 0, 13, 0, $index));
$urlParams = "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0";
}
}
if ($urlParams) {
$values['on_click_urls']["url_" . $urlCnt++] = CRM_Utils_System::url('civicrm/contribute/search', $urlParams, true, false, false);
}
}
// calculate chart size.
$xSize = 400;
$ySize = 300;
if ($chartType == 'bvg') {
$ySize = 250;
$xSize = 60 * count($chartValues);
//hack to show tooltip.
if ($xSize < 150) {
$xSize = 150;
}
}
$values['size'] = array('xSize' => $xSize, 'ySize' => $ySize);
//.........这里部分代码省略.........
示例2: postProcess
/**
* Process the form after the input has been submitted and validated.
*/
public function postProcess()
{
$config = CRM_Core_Config::singleton();
$chartType = 'bvg';
if ($this->_chartType) {
$chartType = $this->_chartType;
}
$selectedYear = date('Y');
if ($this->_year) {
$selectedYear = $this->_year;
}
//take contribution information monthly
$chartInfoMonthly = CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly($selectedYear);
$chartData = $abbrMonthNames = array();
if (is_array($chartInfoMonthly)) {
for ($i = 1; $i <= 12; $i++) {
$abbrMonthNames[$i] = strftime('%b', mktime(0, 0, 0, $i, 10, 1970));
}
foreach ($abbrMonthNames as $monthKey => $monthName) {
$val = CRM_Utils_Array::value($monthKey, $chartInfoMonthly['By Month'], 0);
// don't include zero value month.
if (!$val && $chartType != 'bvg') {
continue;
}
//build the params for chart.
$chartData['by_month']['values'][$monthName] = $val;
}
$chartData['by_month']['legend'] = 'By Month' . ' - ' . $selectedYear;
// handle onclick event.
$chartData['by_month']['on_click_fun_name'] = 'byMonthOnClick';
$chartData['by_month']['yname'] = ts('Contribution');
}
//take contribution information by yearly
$chartInfoYearly = CRM_Contribute_BAO_Contribution_Utils::contributionChartYearly();
//get the years.
$this->_years = $chartInfoYearly['By Year'];
$hasContributions = FALSE;
if (is_array($chartInfoYearly)) {
$hasContributions = TRUE;
$chartData['by_year']['legend'] = 'By Year';
$chartData['by_year']['values'] = $chartInfoYearly['By Year'];
// handle onclick event.
$chartData['by_year']['on_click_fun_name'] = 'byYearOnClick';
$chartData['by_year']['yname'] = ts('Total Amount');
}
$this->assign('hasContributions', $hasContributions);
// process the data.
$chartCnt = 1;
$monthlyChart = $yearlyChart = FALSE;
foreach ($chartData as $chartKey => &$values) {
$chartValues = CRM_Utils_Array::value('values', $values);
if (!is_array($chartValues) || empty($chartValues)) {
continue;
}
if ($chartKey == 'by_year') {
$yearlyChart = TRUE;
if (!empty($config->fiscalYearStart) && ($config->fiscalYearStart['M'] !== 1 || $config->fiscalYearStart['d'] !== 1)) {
$values['xLabelAngle'] = 45;
} else {
$values['xLabelAngle'] = 0;
}
}
if ($chartKey == 'by_month') {
$monthlyChart = TRUE;
}
$values['divName'] = "open_flash_chart_{$chartKey}";
$funName = $chartType == 'bvg' ? 'barChart' : 'pieChart';
// build the chart objects.
$values['object'] = CRM_Utils_OpenFlashChart::$funName($values);
//build the urls.
$urlCnt = 0;
foreach ($chartValues as $index => $val) {
$urlParams = NULL;
if ($chartKey == 'by_month') {
$monthPosition = array_search($index, $abbrMonthNames);
$startDate = CRM_Utils_Date::format(array('Y' => $selectedYear, 'M' => $monthPosition));
$endDate = date('Ymd', mktime(0, 0, 0, $monthPosition + 1, 0, $selectedYear));
$urlParams = "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0";
} elseif ($chartKey == 'by_year') {
if (!empty($config->fiscalYearStart) && ($config->fiscalYearStart['M'] != 1 || $config->fiscalYearStart['d'] != 1)) {
$startDate = date('Ymd', mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d'], substr($index, 0, 4)));
$endDate = date('Ymd', mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d'], substr($index, 0, 4) + 1));
} else {
$startDate = CRM_Utils_Date::format(array('Y' => substr($index, 0, 4)));
$endDate = date('Ymd', mktime(0, 0, 0, 13, 0, substr($index, 0, 4)));
}
$urlParams = "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0";
}
if ($urlParams) {
$values['on_click_urls']["url_" . $urlCnt++] = CRM_Utils_System::url('civicrm/contribute/search', $urlParams, TRUE, FALSE, FALSE);
}
}
// calculate chart size.
$xSize = 400;
$ySize = 300;
if ($chartType == 'bvg') {
$ySize = 250;
//.........这里部分代码省略.........
示例3: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
//get the submitted form values.
$submittedValues = $this->controller->exportValues($this->_name);
//take contribution information monthly
require_once 'CRM/Contribute/BAO/Contribution/Utils.php';
$selectedYear = CRM_Utils_Array::value('select_year', $submittedValues, date('Y'));
$chartInfoMonthly = CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly($selectedYear);
$pChartParams = array();
$monthlyData = false;
$abbrMonthNames = array();
if (is_array($chartInfoMonthly)) {
$monthlyData = true;
for ($i = 1; $i <= 12; $i++) {
$abbrMonthNames[$i] = strftime('%b', mktime(0, 0, 0, $i, 10, 1970));
}
foreach ($abbrMonthNames as $monthKey => $monthName) {
if (!CRM_Utils_Array::value($monthKey, $chartInfoMonthly['By Month'])) {
//set zero value to month which is not in db
$chartInfoMonthly['By Month'][$monthKey] = 0;
}
}
//sort the array.
ksort($chartInfoMonthly['By Month']);
//build the params for pChart.
$pChartParams['by_month']['values'] = array_combine($abbrMonthNames, $chartInfoMonthly['By Month']);
$pChartParams['by_month']['legend'] = 'By Month' . ' - ' . $selectedYear;
}
$this->assign('monthlyData', $monthlyData);
//take contribution information by yearly
$chartInfoYearly = CRM_Contribute_BAO_Contribution_Utils::contributionChartYearly();
//get the years.
$this->_years = $chartInfoYearly['By Year'];
$hasContributions = false;
if (is_array($chartInfoYearly)) {
$hasContributions = true;
$pChartParams['by_year']['legend'] = 'By Year';
$pChartParams['by_year']['values'] = $chartInfoYearly['By Year'];
}
$this->assign('hasContributions', $hasContributions);
//handle pchart functionality.
if (!empty($pChartParams)) {
$filesValues = array();
require_once 'CRM/Utils/PChart.php';
if ('p3' == CRM_Utils_Array::value('chart_type', $submittedValues, 'bvg')) {
//assign shape for map
$this->assign('shape', 'poly');
$this->assign('chartType', 'pie');
$chartParams = array();
if ($monthlyData) {
$chartParams = array($pChartParams['by_month'], $pChartParams['by_year']);
} else {
$chartParams = array($pChartParams['by_year']);
}
//build the pie graph
$filesValues = CRM_Utils_PChart::pieGraph($chartParams);
} else {
//assign shape for map
$this->assign('shape', 'rect');
$this->assign('chartType', 'bar');
$chartParams = array();
if ($monthlyData) {
$chartParams = array($pChartParams['by_month'], $pChartParams['by_year']);
} else {
$chartParams = array($pChartParams['by_year']);
}
//build the bar graph.
$filesValues = CRM_Utils_PChart::barGraph($chartParams);
}
$formatMonthly = true;
foreach ($filesValues as $chartIndex => $values) {
if ($monthlyData && $formatMonthly) {
$this->assign('monthCoords', $values['coords']);
$this->assign('monthFilePath', $values['file_name']);
//build the month urls for map.
$monthUrls = array();
foreach ($values['coords'] as $month => $value) {
$monthPosition = array_search($month, $abbrMonthNames);
$startDate = CRM_Utils_Date::format(array('Y' => $selectedYear, 'M' => $monthPosition));
$endDate = date('Ymd', mktime(0, 0, 0, $monthPosition + 1, 0, $selectedYear));
$monthUrls[$month] = CRM_Utils_System::url('civicrm/contribute/search', "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0");
}
$this->assign('monthUrls', $monthUrls);
$formatMonthly = false;
} else {
$this->assign('yearCoords', $values['coords']);
$this->assign('yearFilePath', $values['file_name']);
//build year urls for map
$yearUrls = array();
foreach ($values['coords'] as $year => $value) {
$startDate = CRM_Utils_Date::format(array('Y' => $year));
if ($year) {
$endDate = date('Ymd', mktime(0, 0, 0, 13, 0, $year));
}
//.........这里部分代码省略.........