X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FReport%2FForm%2FContribute%2FLybunt.php;h=1fa3a79327deec7a098b52e5b62a7e0d41f5058a;hb=276ee0a0d34630e77fab855111697bc46b20222b;hp=c36e78aba50f7fa9deac90b6c666e4dbcae5bba0;hpb=5667521530926d61b370a4bb0806b7e5ad63ccbc;p=civicrm-core.git diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index c36e78aba5..1fa3a79327 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -47,10 +47,8 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { protected $lifeTime_where = NULL; /** - * */ /** - * */ public function __construct() { $yearsInPast = 10; @@ -72,102 +70,102 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'grouping' => 'contact-field', - 'fields' => array( - 'sort_name' => array( - 'title' => ts('Donor Name'), - 'default' => TRUE, - 'required' => TRUE, - ), - 'first_name' => array( - 'title' => ts('First Name'), - ), - 'last_name' => array( - 'title' => ts('Last Name'), - ), - 'contact_type' => array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( - 'title' => ts('Contact Subtype'), - ), + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'grouping' => 'contact-field', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'default' => TRUE, + 'required' => TRUE, + ), + 'first_name' => array( + 'title' => ts('First Name'), + ), + 'last_name' => array( + 'title' => ts('Last Name'), + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), + ), + ), + 'filters' => array( + 'sort_name' => array( + 'title' => ts('Donor Name'), + 'operator' => 'like', ), - 'filters' => array( - 'sort_name' => array( - 'title' => ts('Donor Name'), - 'operator' => 'like', - ), + ), + ), + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'grouping' => 'contact-field', + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), + 'default' => TRUE, ), ), - 'civicrm_email' => array( - 'dao' => 'CRM_Core_DAO_Email', - 'grouping' => 'contact-field', - 'fields' => array( - 'email' => array( - 'title' => ts('Email'), - 'default' => TRUE, - ), + ), + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'grouping' => 'contact-field', + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), + 'default' => TRUE, ), ), - 'civicrm_phone' => array( - 'dao' => 'CRM_Core_DAO_Phone', - 'grouping' => 'contact-field', - 'fields' => array( - 'phone' => array( - 'title' => ts('Phone'), - 'default' => TRUE, - ), + ), + ); + $this->_columns += $this->addAddressFields(); + $this->_columns += array( + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', + 'fields' => array( + 'contact_id' => array( + 'title' => ts('contactId'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'total_amount' => array( + 'title' => ts('Total Amount'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, + ), + 'receive_date' => array( + 'title' => ts('Year'), + 'no_display' => TRUE, + 'required' => TRUE, + 'no_repeat' => TRUE, ), ), - ) - + $this->addAddressFields() - + array( - 'civicrm_contribution' => array( - 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contact_id' => array( - 'title' => ts('contactId'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, - ), - 'total_amount' => array( - 'title' => ts('Total Amount'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, - ), - 'receive_date' => array( - 'title' => ts('Year'), - 'no_display' => TRUE, - 'required' => TRUE, - 'no_repeat' => TRUE, - ), + 'filters' => array( + 'yid' => array( + 'name' => 'receive_date', + 'title' => ts('This Year'), + 'operatorType' => CRM_Report_Form::OP_SELECT, + 'options' => $optionYear, + 'default' => date('Y'), ), - 'filters' => array( - 'yid' => array( - 'name' => 'receive_date', - 'title' => ts('This Year'), - 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => $optionYear, - 'default' => date('Y'), - ), - 'financial_type_id' => array( - 'title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'contribution_status_id' => array( - 'title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array('1'), - ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + ), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array('1'), ), ), - ); + ), + ); // If we have a campaign, build out the relevant elements if ($campaignEnabled && !empty($this->activeCampaigns)) { @@ -197,7 +195,6 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $current_year = $this->_params['yid_value']; $previous_year = $current_year - 1; - foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { @@ -277,8 +274,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { WHERE " . self::fiscalYearOffset('contri.receive_date') . " = $previous_year AND contri.is_test = 0)"; } - elseif (CRM_Utils_Array::value('type', $field) & - CRM_Utils_Type::T_DATE + elseif (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE ) { $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); @@ -320,8 +316,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { } public function groupBy() { - $this->_groupBy = - "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id, " . + $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id, " . self::fiscalYearOffset($this->_aliases['civicrm_contribution'] . '.receive_date') . " WITH ROLLUP"; $this->assign('chartSupported', TRUE); @@ -384,8 +379,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}"; } else { - $sql = - "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" . + $sql = "{$this->_select} {$this->_from} WHERE {$this->_aliases['civicrm_contact']}.id IN (" . implode(',', $contactIds) . ") AND {$this->_aliases['civicrm_contribution']}.is_test = 0 {$this->_statusClause} {$this->_groupBy} "; } @@ -445,8 +439,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { 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]; + $display[$previous_year] = CRM_Utils_Array::value($previous_year, $display) + $row[$previous_year]; } $config = CRM_Core_Config::Singleton(); @@ -503,8 +496,8 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { } } - // Override "This Year" $op options /** + * Override "This Year" $op options * @param string $type * @param null $fieldName * @@ -514,7 +507,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { if ($fieldName == 'yid') { return array( 'calendar' => ts('Is Calendar Year'), - 'fiscal' => ts('Fiscal Year Starting') + 'fiscal' => ts('Fiscal Year Starting'), ); } return parent::getOperationPair($type, $fieldName);