Example #1
0
 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'];
         }
     }
 }
Example #2
0
 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'];
     }
 }
Example #3
0
 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();
 }