'civicrm_address' => array(
'dao' => 'CRM_Core_DAO_Address',
'fields' => array(
- 'name' => array(
+ 'address_name' => array(
'title' => ts('Address Name'),
'default' => CRM_Utils_Array::value('name', $defaults, FALSE),
+ 'name' => 'name',
),
'street_address' => array(
'title' => ts('Street Address'),
return $entryFound;
}
+ /**
+ * Do AlterDisplay processing on Address Fields.
+ *
+ * @param array $row
+ * @param array $rows
+ * @param int $rowNum
+ *
+ * @return bool
+ */
+ public function alterDisplayContactFields(&$row, &$rows, &$rowNum) {
+ $entryFound = FALSE;
+ if (array_key_exists('civicrm_contact_prefix_id', $row)) {
+ $prefixes = CRM_Contact_BAO_Contact::buildOptions('prefix_id');
+ if ($value = $row['civicrm_contact_prefix_id']) {
+ $rows[$rowNum]['civicrm_contact_prefix_id'] = $prefixes[$rows[$rowNum]['civicrm_contact_prefix_id']];
+ }
+ $entryFound = TRUE;
+ }
+ if (array_key_exists('civicrm_contact_suffix_id', $row)) {
+ $suffixes = CRM_Contact_BAO_Contact::buildOptions('suffix_id');
+ if ($value = $row['civicrm_contact_suffix_id']) {
+ $rows[$rowNum]['civicrm_contact_suffix_id'] = $suffixes[$rows[$rowNum]['civicrm_contact_suffix_id']];
+ }
+ $entryFound = TRUE;
+ }
+ if (array_key_exists('civicrm_contact_gender_id', $row)) {
+ $genders = CRM_Contact_BAO_Contact::buildOptions('gender_id');
+ if ($value = $row['civicrm_contact_gender_id']) {
+ $rows[$rowNum]['civicrm_contact_gender_id'] = $genders[$rows[$rowNum]['civicrm_contact_gender_id']];
+ }
+ $entryFound = TRUE;
+ }
+ return $entryFound;
+ }
+
/**
* Adjusts dates passed in to YEAR() for fiscal year.
*
);
}
+ /**
+ * Get a standard set of contact fields.
+ *
+ * @return array
+ */
+ public function getBasicContactFields() {
+ return array(
+ 'sort_name' => array(
+ 'title' => ts('Contact Name'),
+ 'required' => TRUE,
+ 'default' => TRUE,
+ ),
+ 'id' => array(
+ 'no_display' => TRUE,
+ 'required' => TRUE,
+ ),
+ 'prefix_id' => array(
+ 'title' => ts('Contact Prefix'),
+ ),
+ 'first_name' => array(
+ 'title' => ts('First Name'),
+ ),
+ 'middle_name' => array(
+ 'title' => ts('Middle Name'),
+ ),
+ 'last_name' => array(
+ 'title' => ts('Last Name'),
+ ),
+ 'suffix_id' => array(
+ 'title' => ts('Contact Suffix'),
+ ),
+ 'postal_greeting_display' => array('title' => ts('Postal Greeting')),
+ 'email_greeting_display' => array('title' => ts('Email Greeting')),
+ 'contact_type' => array(
+ 'title' => ts('Contact Type'),
+ ),
+ 'contact_sub_type' => array(
+ 'title' => ts('Contact Subtype'),
+ ),
+ 'gender_id' => array(
+ 'title' => ts('Gender'),
+ ),
+ 'birth_date' => array(
+ 'title' => ts('Birth Date'),
+ ),
+ 'age' => array(
+ 'title' => ts('Age'),
+ 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())',
+ ),
+ 'job_title' => array(
+ 'title' => ts('Contact Job title'),
+ ),
+ 'organization_name' => array(
+ 'title' => ts('Organization Name'),
+ ),
+ );
+ }
+
/**
* Add contact to group.
*
$this->_columns = array(
'civicrm_contact' => array(
'dao' => 'CRM_Contact_DAO_Contact',
- 'fields' => array(
- 'sort_name' => array(
- 'title' => ts('Contact Name'),
- 'no_repeat' => TRUE,
- ),
- 'postal_greeting_display' => array('title' => ts('Postal Greeting')),
- 'id' => array(
- 'no_display' => TRUE,
- 'required' => TRUE,
- ),
- 'contact_type' => array(
- 'title' => ts('Contact Type'),
- ),
- 'contact_sub_type' => array(
- 'title' => ts('Contact Subtype'),
- ),
- ),
+ 'fields' => $this->getBasicContactFields(),
'grouping' => 'contact-fields',
'group_bys' => array(
'id' => array('title' => ts('Contact ID')),
}
$entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound;
+ $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'contribute/detail') ? TRUE : $entryFound;
// skip looking further in rows, if first row itself doesn't
// have the column we need
protected $_customGroupGroupBy = FALSE;
/**
- */
- /**
+ * Class constructor.
*/
public function __construct() {
$this->_columns = array(
'civicrm_contact' => array(
'dao' => 'CRM_Contact_DAO_Contact',
- 'fields' => array(
- 'sort_name' => array(
- 'title' => ts('Contact Name'),
- 'required' => TRUE,
- 'default' => TRUE,
- ),
- 'id' => array(
- 'no_display' => TRUE,
- 'required' => TRUE,
- ),
- 'first_name' => array(
- 'title' => ts('First Name'),
- ),
- 'id' => array(
- 'no_display' => TRUE,
- 'required' => TRUE,
- ),
- 'last_name' => array(
- 'title' => ts('Last Name'),
- ),
- 'contact_type' => array(
- 'title' => ts('Contact Type'),
- ),
- 'contact_sub_type' => array(
- 'title' => ts('Contact Subtype'),
- ),
- ),
+ 'fields' => $this->getBasicContactFields(),
'filters' => array(
'sort_name' => array(
'title' => ts('Contact Name'),
),
'grouping' => 'member-fields',
),
- 'civicrm_address' => array(
- 'dao' => 'CRM_Core_DAO_Address',
- 'fields' => array(
- 'street_address' => NULL,
- 'city' => NULL,
- 'postal_code' => NULL,
- 'state_province_id' => array(
- 'title' => ts('State/Province'),
- ),
- 'country_id' => array(
- 'title' => ts('Country'),
- ),
- ),
- 'grouping' => 'contact-fields',
- ),
'civicrm_email' => array(
'dao' => 'CRM_Core_DAO_Email',
'fields' => array('email' => NULL),
),
'grouping' => 'contri-fields',
),
- );
+ ) + $this->getAddressColumns(array(
+ // These options are only excluded because they were not previously present.
+ 'order_by' => FALSE,
+ 'group_by' => FALSE,
+ ));
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
if (array_key_exists('fields', $table)) {
foreach ($table['fields'] as $fieldName => $field) {
if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
- if ($tableName == 'civicrm_address') {
- $this->_addressField = TRUE;
- }
- elseif ($tableName == 'civicrm_email') {
+ if ($tableName == 'civicrm_email') {
$this->_emailField = TRUE;
}
elseif ($tableName == 'civicrm_phone') {
ON {$this->_aliases['civicrm_membership_status']}.id =
{$this->_aliases['civicrm_membership']}.status_id ";
- //used when address field is selected
- if ($this->_addressField) {
+ 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";
}
+
//used when email field is selected
if ($this->_emailField) {
$this->_from .= "
$entryFound = TRUE;
}
}
+ $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'member/detail', 'List all memberships(s) for this ') ? TRUE : $entryFound;
+ $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'member/detail') ? TRUE : $entryFound;
if (!$entryFound) {
break;