}
}
else {
+ if ((CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_INT) && is_array($field['default'])) {
+ $this->_defaults["{$fieldName}_min"] = CRM_Utils_Array::value('min', $field['default']);
+ $this->_defaults["{$fieldName}_max"] = CRM_Utils_Array::value('max', $field['default']);
+ }
$this->_defaults["{$fieldName}_value"] = $field['default'];
}
}
public function groupBy() {
$groupBys = array();
if (!empty($this->_params['group_bys']) &&
- is_array($this->_params['group_bys']) &&
- !empty($this->_params['group_bys'])
+ is_array($this->_params['group_bys'])
) {
foreach ($this->_columns as $tableName => $table) {
if (array_key_exists('group_bys', $table)) {
}
/**
- * Check for empty order_by configurations and remove them; also set
- * template to hide them.
+ * Check for empty order_by configurations and remove them.
+ *
+ * Also set template to hide them.
*
* @param array $formValues
*/
'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'),
* @param array $rows
* @param int $rowNum
* @param string $baseUrl
- * @param string $urltxt
+ * @param string $linkText
*
* @return bool
*/
- public function alterDisplayAddressFields(&$row, &$rows, &$rowNum, $baseUrl, $urltxt) {
+ public function alterDisplayAddressFields(&$row, &$rows, &$rowNum, $baseUrl, $linkText) {
$criteriaQueryParams = CRM_Report_Utils_Report::getPreviewCriteriaQueryParams($this->_defaults, $this->_params);
$entryFound = FALSE;
// handle country
);
$rows[$rowNum]['civicrm_address_country_id_link'] = $url;
$rows[$rowNum]['civicrm_address_country_id_hover'] = ts("%1 for this country.",
- array(1 => $urltxt)
+ array(1 => $linkText)
);
}
);
$rows[$rowNum]['civicrm_address_county_id_link'] = $url;
$rows[$rowNum]['civicrm_address_county_id_hover'] = ts("%1 for this county.",
- array(1 => $urltxt)
+ array(1 => $linkText)
);
}
$entryFound = TRUE;
);
$rows[$rowNum]['civicrm_address_state_province_id_link'] = $url;
$rows[$rowNum]['civicrm_address_state_province_id_hover'] = ts("%1 for this state.",
- array(1 => $urltxt)
+ array(1 => $linkText)
);
}
$entryFound = TRUE;
return $entryFound;
}
+ /**
+ * Do AlterDisplay processing on Address Fields.
+ *
+ * @param array $row
+ * @param array $rows
+ * @param int $rowNum
+ * @param string $baseUrl
+ * @param string $linkText
+ *
+ * @return bool
+ */
+ public function alterDisplayContactFields(&$row, &$rows, &$rowNum, $baseUrl, $linkText) {
+ $entryFound = FALSE;
+ // There is no reason not to add links for all fields but it seems a bit odd to be able to click on
+ // 'Mrs'. Also, we don't have metadata about the title. So, add selectively to addLinks.
+ $addLinks = array('gender_id' => 'Gender');
+ foreach (array('prefix_id', 'suffix_id', 'gender_id') as $fieldName) {
+ if (array_key_exists('civicrm_contact_' . $fieldName, $row)) {
+ if (($value = $row['civicrm_contact_' . $fieldName]) != FALSE) {
+ $rows[$rowNum]['civicrm_contact_' . $fieldName] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', $fieldName, $value);
+ if (($title = CRM_Utils_Array::value($fieldName, $addLinks)) != FALSE) {
+ $this->addLinkToRow($rows[$rowNum], $baseUrl, $linkText, $value, $fieldName, 'civicrm_contact', $title);
+ }
+ }
+ $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'),
+ ),
+ 'nick_name' => array(
+ 'title' => ts('Nick 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')),
+ 'addressee_display' => array('title' => ts('Address 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'),
+ ),
+ 'external_identifier' => array(
+ 'title' => ts('Contact identifier from external system'),
+ ),
+ );
+ }
+
/**
* Add contact to group.
*
);
}
+ /**
+ * Add link fields to the row.
+ *
+ * Function adds the _link & _hover fields to the row.
+ *
+ * @param array $row
+ * @param string $baseUrl
+ * @param string $linkText
+ * @param string $value
+ * @param string $fieldName
+ * @param string $tablePrefix
+ * @param string $fieldLabel
+ *
+ * @return mixed
+ */
+ protected function addLinkToRow(&$row, $baseUrl, $linkText, $value, $fieldName, $tablePrefix, $fieldLabel) {
+ $criteriaQueryParams = CRM_Report_Utils_Report::getPreviewCriteriaQueryParams($this->_defaults, $this->_params);
+ $url = CRM_Report_Utils_Report::getNextUrl($baseUrl,
+ "reset=1&force=1&{$criteriaQueryParams}&" .
+ $fieldName . "_op=in&{$fieldName}_value={$value}",
+ $this->_absoluteUrl, $this->_id
+ );
+ $row["{$tablePrefix}_{$fieldName}_link"] = $url;
+ $row["{$tablePrefix}_{$fieldName}_hover"] = ts("%1 for this %2.",
+ array(1 => $linkText, 2 => $fieldLabel)
+ );
+ }
+
+
+ public function getPermissionedFTQuery(&$query, $alias = NULL) {
+ CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);
+ if (empty($financialTypes)) {
+ $contFTs = "0";
+ $liFTs = implode(',' , array_keys(CRM_Contribute_Pseudoconstant::financialType()));
+ }
+ else {
+ $contFTs = $liFTs = implode(',' , array_keys($financialTypes));
+ }
+ if ($alias) {
+ $temp = $query->_aliases['civicrm_line_item'];
+ $query->_aliases['civicrm_line_item'] = $alias;
+ }
+ if (empty($query->_where)) {
+ $query->_where = "WHERE {$query->_aliases['civicrm_contribution']}.id IS NOT NULL ";
+ }
+ CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS civicrm_contribution_temp");
+
+ $sql = "CREATE TEMPORARY TABLE civicrm_contribution_temp AS SELECT {$query->_aliases['civicrm_contribution']}.id {$query->_from}
+ LEFT JOIN civicrm_line_item {$query->_aliases['civicrm_line_item']}
+ ON {$query->_aliases['civicrm_contribution']}.id = {$query->_aliases['civicrm_line_item']}.contribution_id AND
+ {$query->_aliases['civicrm_line_item']}.entity_table = 'civicrm_contribution'
+ AND {$query->_aliases['civicrm_line_item']}.financial_type_id NOT IN (" . $liFTs . ")
+ {$query->_where}
+ AND {$query->_aliases['civicrm_contribution']}.financial_type_id IN (" . $contFTs . ")
+ AND {$query->_aliases['civicrm_line_item']}.id IS NULL
+ GROUP BY {$query->_aliases['civicrm_contribution']}.id";
+ CRM_Core_DAO::executeQuery($sql);
+ $query->_from .= "
+ INNER JOIN civicrm_contribution_temp temp ON {$query->_aliases['civicrm_contribution']}.id = temp.id ";
+ if (isset($temp)) {
+ $query->_aliases['civicrm_line_item'] = $temp;
+ }
+ }
+
}