예제 #1
0
 /**
  * Build chart.
  *
  * @param array $rows
  */
 public function buildChart(&$rows)
 {
     $graphRows = array();
     if (!empty($this->_params['charts'])) {
         if (!empty($this->_params['group_bys']['receive_date'])) {
             $contrib = !empty($this->_params['fields']['total_amount']) ? TRUE : FALSE;
             $softContrib = !empty($this->_params['fields']['soft_amount']) ? TRUE : FALSE;
             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'];
                     if ($softContrib && $contrib) {
                         // both contri & soft contri stats are present
                         $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
                         $graphRows['multiValue'][1][] = $row['civicrm_contribution_soft_soft_amount_sum'];
                     } elseif ($softContrib) {
                         // only soft contributions
                         $graphRows['multiValue'][0][] = $row['civicrm_contribution_soft_soft_amount_sum'];
                     } else {
                         // only contributions
                         $graphRows['multiValue'][0][] = $row['civicrm_contribution_total_amount_sum'];
                     }
                 }
             }
             if ($softContrib && $contrib) {
                 $graphRows['barKeys'][0] = ts('Contributions');
                 $graphRows['barKeys'][1] = ts('Soft Credits');
                 $graphRows['legend'] = ts('Contributions and Soft Credits');
             } elseif ($softContrib) {
                 $graphRows['legend'] = ts('Soft Credits');
             }
             // build the chart.
             $config = CRM_Core_Config::Singleton();
             $graphRows['xname'] = $this->_interval;
             $graphRows['yname'] = "Amount ({$config->defaultCurrency})";
             CRM_Utils_OpenFlashChart::chart($graphRows, $this->_params['charts'], $this->_interval);
             $this->assign('chartType', $this->_params['charts']);
         }
     }
 }
예제 #2
0
 /**
  * @param $rows
  */
 public 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 (!empty($this->_params['charts'])) {
         foreach ($rows as $key => $row) {
             if (!($row['civicrm_membership_join_date_subtotal'] && $row['civicrm_membership_membership_type_id'])) {
                 continue;
             }
             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 (!empty($row['civicrm_membership_join_date_subtotal'])) {
                     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++;
             }
         }
         // build chart.
         if ($isMembershipType) {
             $graphRows['value'] = $display;
             $chartInfo = array('legend' => 'Membership Summary', 'xname' => 'Member Since / Member Type', 'yname' => 'Fees');
             CRM_Utils_OpenFlashChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo);
         } else {
             CRM_Utils_OpenFlashChart::chart($graphRows, $this->_params['charts'], $this->_interval);
         }
     }
     $this->assign('chartType', $this->_params['charts']);
 }
예제 #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};
         }
         if (!empty($this->_params['charts']) && $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));
     if (!empty($this->_params['charts'])) {
         foreach (array('receive_date', $this->_interval, 'value') as $ignore) {
             unset($graphRows[$ignore][$count - 1]);
         }
         // build chart.
         CRM_Utils_OpenFlashChart::chart($graphRows, $this->_params['charts'], $this->_interval);
     }
     parent::endPostProcess();
 }
 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'])) {
             // build the chart.
             $config = CRM_Core_Config::Singleton();
             $graphRows['xname'] = $this->_interval;
             $graphRows['yname'] = "Amount ({$config->defaultCurrency})";
             CRM_Utils_OpenFlashChart::chart($graphRows, $this->_params['charts'], $this->_interval);
             $this->assign('chartType', $this->_params['charts']);
         }
     }
 }