function buildChart(&$rows) { $graphRows = array(); $count = 0; $display = array(); $current_year = $this->_params['yid_value']; $previous_year = $current_year - 1; $interval[$previous_year] = $previous_year; $interval['life_time'] = 'life_time'; foreach ($rows as $key => $row) { $display['life_time'] = CRM_Utils_Array::value('life_time', $display) + $row['civicrm_life_time_total']; $display[$previous_year] = CRM_Utils_Array::value($previous_year, $display) + $row[$previous_year]; } $graphRows['value'] = $display; $chartInfo = array('legend' => ts('Lybunt Report'), 'xname' => ts('Amount'), 'yname' => ts('Year')); if ($this->_params['charts']) { $graphs = CRM_Utils_PChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo); $this->assign('graphFilePath', $graphs['0']['file_name']); $this->_graphPath = $graphs['0']['file_name']; } }
function buildChart(&$rows) { $graphRows = array(); $count = 0; $membershipTypeValues = CRM_Member_PseudoConstant::membershipType(); $isMembershipType = CRM_Utils_Array::value('membership_type_id', $this->_params['group_bys']); $isJoiningDate = CRM_Utils_Array::value('join_date', $this->_params['group_bys']); if (CRM_Utils_Array::value('charts', $this->_params)) { foreach ($rows as $key => $row) { if ($isMembershipType) { $join_date = CRM_Utils_Array::value('civicrm_membership_join_date_start', $row); $displayInterval = CRM_Utils_Array::value('civicrm_membership_join_date_interval', $row); if ($join_date) { list($year, $month) = explode('-', $join_date); } if (CRM_Utils_Array::value('civicrm_membership_join_date_subtotal', $row)) { switch ($this->_interval) { case 'Month': $displayRange = $displayInterval . ' ' . $year; break; case 'Quarter': $displayRange = 'Quarter ' . $displayInterval . ' of ' . $year; break; case 'Week': $displayRange = 'Week ' . $displayInterval . ' of ' . $year; break; case 'Year': $displayRange = $year; break; } $membershipType = $displayRange . "-" . $membershipTypeValues[$row['civicrm_membership_membership_type_id']]; } else { $membershipType = $membershipTypeValues[$row['civicrm_membership_membership_type_id']]; } $interval[$membershipType] = $membershipType; $display[$membershipType] = $row['civicrm_contribution_total_amount_sum']; } else { $graphRows['receive_date'][] = CRM_Utils_Array::value('civicrm_membership_join_date_start', $row); $graphRows[$this->_interval][] = CRM_Utils_Array::value('civicrm_membership_join_date_interval', $row); $graphRows['value'][] = $row['civicrm_contribution_total_amount_sum']; $count++; } } if ($isMembershipType) { $graphRows['value'] = $display; $chartInfo = array('legend' => 'MemberShip Summary', 'xname' => 'Amount', 'yname' => 'Year'); $graphs = CRM_Utils_PChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo); } else { $graphs = CRM_Utils_PChart::chart($graphRows, $this->_params['charts'], $this->_interval); } $this->assign('graphFilePath', $graphs['0']['file_name']); $this->_graphPath = $graphs['0']['file_name']; } }
function buildChart(&$rows) { $graphRows = array(); $count = 0; $current_year = $this->_params['yid_value']; $previous_year = $current_year - 1; $previous_two_year = $current_year - 2; $previous_three_year = $current_year - 3; $upto = $current_year - 4; $interval[$previous_year] = $previous_year; $interval[$previous_two_year] = $previous_two_year; $interval[$previous_three_year] = $previous_three_year; $interval["upto_{$upto}"] = "upto_{$upto}"; foreach ($rows as $key => $row) { $display["upto_{$upto}"] = CRM_Utils_Array::value("upto_{$upto}", $display) + CRM_Utils_Array::value("civicrm_upto_{$upto}", $row); $display[$previous_year] = CRM_Utils_Array::value($previous_year, $display) + CRM_Utils_Array::value($previous_year, $row); $display[$previous_two_year] = CRM_Utils_Array::value($previous_two_year, $display) + CRM_Utils_Array::value($previous_two_year, $row); $display[$previous_three_year] = CRM_Utils_Array::value($previous_three_year, $display) + CRM_Utils_Array::value($previous_three_year, $row); } $graphRows['value'] = $display; $chartInfo = array('legend' => 'Sybunt Report', 'xname' => 'Amount', 'yname' => 'Year'); if ($this->_params['charts']) { $graphs = CRM_Utils_PChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo); $this->assign('graphFilePath', $graphs['0']['file_name']); $this->_graphPath = $graphs['0']['file_name']; } }
function buildChart(&$rows) { $graphRows = array(); $count = 0; if (CRM_Utils_Array::value('charts', $this->_params)) { foreach ($rows as $key => $row) { if ($row['civicrm_contribution_receive_date_subtotal']) { $graphRows['receive_date'][] = $row['civicrm_contribution_receive_date_start']; $graphRows[$this->_interval][] = $row['civicrm_contribution_receive_date_interval']; $graphRows['value'][] = $row['civicrm_contribution_total_amount_sum']; $count++; } } if (CRM_Utils_Array::value('receive_date', $this->_params['group_bys'])) { foreach (array('receive_date', $this->_interval, 'value') as $ignore) { unset($graphRows[$ignore][$count - 1]); } $graphs = CRM_Utils_PChart::chart($graphRows, $this->_params['charts'], $this->_interval); $this->assign('graphFilePath', $graphs['0']['file_name']); $this->_graphPath = $graphs['0']['file_name']; } } }
function buildChart(&$rows) { $this->_interval = 'events'; $countEvent = null; if (CRM_Utils_Array::value('charts', $this->_params)) { foreach ($rows as $key => $value) { $graphRows['totalAmount'][] = $rows[$key]['totalAmount']; $graphRows[$this->_interval][] = substr($rows[$key]['civicrm_event_title'], 0, 12) . "..(" . $rows[$key]['civicrm_event_id'] . ") "; $graphRows['value'][] = $rows[$key]['totalAmount']; } if ($rows[$key]['totalAmount'] == 0) { $countEvent = count($rows); } if (!empty($rows) && $countEvent != 1) { $chartInfo = array('legend' => 'Event Summary', 'xname' => 'Total Amount', 'yname' => 'Event'); if (!empty($graphRows)) { foreach ($graphRows[$this->_interval] as $key => $val) { $graph[$val] = $graphRows['value'][$key]; } $chartInfo['values'] = $graph; $params[] = $chartInfo; if (CRM_Utils_Array::value('charts', $this->_params) == 'barGraph') { $graphs = CRM_Utils_PChart::barGraph($params, 85); } else { unset($params[0]['xname'], $params[0]['yname']); $graphs = CRM_Utils_PChart::pieGraph($params); } $this->assign('graphFilePath', $graphs['0']['file_name']); $this->_graphPath = $graphs['0']['file_name']; } } } }
function postProcess() { $this->_params = $this->controller->exportValues($this->_name); if (empty($this->_params) && $this->_force) { $this->_params = $this->_formValues; } $this->_formValues = $this->_params; $this->processReportMode(); $this->select(); $this->from(); $this->where(); $this->groupBy(); $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}"; $dao = CRM_Core_DAO::executeQuery($sql); $rows = $graphRows = array(); $count = 0; while ($dao->fetch()) { $row = array(); foreach ($this->_columnHeaders as $key => $value) { $row[$key] = $dao->{$key}; } require_once 'CRM/Utils/PChart.php'; if (CRM_Utils_Array::value('charts', $this->_params) && $row['civicrm_contribution_receive_date_subtotal']) { $graphRows['receive_date'][] = $row['civicrm_contribution_receive_date_start']; $graphRows[$this->_interval][] = $row['civicrm_contribution_receive_date_interval']; $graphRows['value'][] = $row['civicrm_contribution_total_amount_sum']; $count++; } $rows[] = $row; } $this->formatDisplay($rows); $this->assign_by_ref('columnHeaders', $this->_columnHeaders); $this->assign_by_ref('rows', $rows); $this->assign('statistics', $this->statistics($rows)); require_once 'CRM/Utils/PChart.php'; if (CRM_Utils_Array::value('charts', $this->_params)) { foreach (array('receive_date', $this->_interval, 'value') as $ignore) { unset($graphRows[$ignore][$count - 1]); } $graphs = CRM_Utils_PChart::chart($graphRows, $this->_params['charts'], $this->_interval); $this->assign('graphFilePath', $graphs['0']['file_name']); } parent::endPostProcess(); }
/** * 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)); } $yearUrls[$year] = CRM_Utils_System::url('civicrm/contribute/search', "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0"); } $this->assign('yearUrls', $yearUrls); } } } }