* @copyright CiviCRM LLC (c) 2004-2018
*/
class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
- protected $_addressField = FALSE;
-
- protected $_emailField = FALSE;
protected $_summary = NULL;
if (!empty($field['required']) ||
!empty($this->_params['fields'][$fieldName])
) {
- if ($tableName == 'civicrm_address') {
- $this->_addressField = TRUE;
- }
- if ($tableName == 'civicrm_email') {
- $this->_emailField = TRUE;
- }
// only include statistics columns if set
if (!empty($field['statistics'])) {
}
- if (!empty($this->_params['fields']['phone'])) {
- $this->_from .= "
- LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
- ON ({$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND
- {$this->_aliases['civicrm_phone']}.is_primary = 1)";
- }
//for contribution batches
if (!empty($this->_params['fields']['batch_id']) ||
!empty($this->_params['bid_value'])
AND {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn')";
}
- if ($this->_addressField OR
- (!empty($this->_params['state_province_id_value']) OR
- !empty($this->_params['country_id_value']))
- ) {
- $this->_from .= "
- LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
- ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND
- {$this->_aliases['civicrm_address']}.is_primary = 1\n";
- }
-
- if ($this->_emailField) {
- $this->_from .= "
- LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
- ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND
- {$this->_aliases['civicrm_email']}.is_primary = 1\n";
- }
+ $this->joinAddressFromContact();
+ $this->joinPhoneFromContact();
+ $this->joinEmailFromContact();
}
/**
ON {$this->_aliases['civicrm_membership_status']}.id =
{$this->_aliases['civicrm_membership']}.status_id ";
- if ($this->isTableSelected('civicrm_address')) {
- $this->_from .= "
- LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
- ON {$this->_aliases['civicrm_contact']}.id =
- {$this->_aliases['civicrm_address']}.contact_id AND
- {$this->_aliases['civicrm_address']}.is_primary = 1\n";
- }
+ $this->joinAddressFromContact();
+ $this->joinPhoneFromContact();
+ $this->joinEmailFromContact();
- if ($this->isTableSelected('civicrm_email')) {
- $this->_from .= "
- LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
- ON {$this->_aliases['civicrm_contact']}.id =
- {$this->_aliases['civicrm_email']}.contact_id AND
- {$this->_aliases['civicrm_email']}.is_primary = 1\n";
- }
- //used when phone field is selected
- if ($this->isTableSelected('civicrm_phone')) {
- $this->_from .= "
- LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
- ON {$this->_aliases['civicrm_contact']}.id =
- {$this->_aliases['civicrm_phone']}.contact_id AND
- {$this->_aliases['civicrm_phone']}.is_primary = 1\n";
- }
//used when contribution field is selected.
if ($this->isTableSelected('civicrm_contribution')) {
$this->_from .= "
class CRM_Report_Form_Member_Lapse extends CRM_Report_Form {
protected $_summary = NULL;
- protected $_addressField = FALSE;
- protected $_emailField = FALSE;
- protected $_phoneField = FALSE;
protected $_charts = array('' => 'Tabular');
protected $_customGroupExtends = array(
'Membership',
if (!empty($field['required']) ||
!empty($this->_params['fields'][$fieldName])
) {
- // to include optional columns address ,email and phone only if checked
- if ($tableName == 'civicrm_address') {
- $this->_addressField = TRUE;
- }
- elseif ($tableName == 'civicrm_email') {
- $this->_emailField = TRUE;
- }
- elseif ($tableName == 'civicrm_phone') {
- $this->_phoneField = TRUE;
- }
$select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}";
$this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field);
$this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'];
}
public function from() {
- $this->_from = NULL;
-
$this->_from = "
FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom}
INNER JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
ON {$this->_aliases['civicrm_membership']}.membership_type_id =
{$this->_aliases['civicrm_membership_type']}.id";
- // include address field if address column is to be included
- if ($this->_addressField) {
- $this->_from .= "
- LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
- ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_address']}.contact_id AND {$this->_aliases['civicrm_address']}.is_primary = 1\n";
- }
-
- // include email field if email column is to be included
- if ($this->_emailField) {
- $this->_from .= "
- LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
- ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_email']}.contact_id AND {$this->_aliases['civicrm_email']}.is_primary = 1\n";
- }
-
- // include phone field if phone column is to be included
- if ($this->_phoneField) {
- $this->_from .= "
- LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']}
- ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id
- AND {$this->_aliases['civicrm_phone']}.is_primary = 1\n";
- }
+ $this->joinAddressFromContact();
+ $this->joinPhoneFromContact();
+ $this->joinEmailFromContact();
}
public function where() {